video compression mpeg-4 avc/h · -main profile: digital tv broadcast-extended profile: streaming...

58
Video compression MPEG-4 AVC/H.264 Frederic Dufaux Montpellier, April 30, 2013 Frederic Dufaux LTCI - UMR 5141 - CNRS TELECOM ParisTech [email protected]

Upload: others

Post on 13-Aug-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video compressionMPEG-4 AVC/H.264

Frederic Dufaux

Montpellier, April 30, 2013

Frederic DufauxLTCI - UMR 5141 - CNRS TELECOM [email protected]

Page 2: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Context and Background

Direction scientifique2

Page 3: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Trends

Direction scientifique3

• More, more, more– Higher spatial and temporal resolutions, higher pixel depths,

higher number of views, more colors

Page 4: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Trends

– 300 million photos uploaded per day

Direction scientifique4

– 60 hours of video uploaded every minute,– more than 3 billion views per day, – over 3 billion hours of video watched each month

Page 5: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video Coding Standards: MPEG & H.26x

• MPEG-1(1992)– video on CD-ROM

(1.5Mbit/s)

• H.261 (1988)– Video-conferencing over ISDN

(p*64 Kb/s)

International Organization for Standardization

International Telecommunication Union

Direction scientifique5

– video on CD-ROM (1.5Mbit/s)

• MPEG-2 (1994)– Digital TV (5-10Mbit/s)

• MPEG-4 (1998-99)– Multimedia applications

(10kbit/s-10Mbit/s)• MPEG-4 AVC (2003)

– Advanced video coding

– Video-conferencing over ISDN (p*64 Kb/s)

• H.262 (1994)– Digital TV (5-10Mbit/s)

• H.263 (1996)– Video-telephony over POTS and

Internet (8-64 Kb/s)• H.264 (2003)

– Advanced video coding

Under development: HEVC

Page 6: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

• Compression efficiency – Typically 50% gain every 5 years– Adding more efficient coding tools / modes– Functionalities such as scalability, error resilience, interactivity,

low complexity, random access, …

Video Coding Standards:MPEG & H.26x

Direction scientifique6

Page 7: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats• ITU-R 601 (CCIR 601)

– EU: 704 x 576, 25 f/s, int.; USA/Japan: 704 x 480, 30 f/s, int.– 4:2:2

CrCb

Y

Direction scientifique7

– 4:2:0

• CIF: 352 x 288, 30 f/s, YCbCr 4:2:0, prog.• QCIF: 176 x 144, 30 f/s, YCbCr 4:2:0, prog.

Y

CrCb

Y

Page 8: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique8

Page 9: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique9

Page 10: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique10

Page 11: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique11

Page 12: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique12

Page 13: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique13

Page 14: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique14

Page 15: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique15

Page 16: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique16

Page 17: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Video formats

Direction scientifique17

Page 18: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Fundamental concepts in video compression

Direction scientifique18

Page 19: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Compression: general concepts

• Exploit the correlation in the data– Reduce redundancies– Lossless

Direction scientifique19

• Exploit the human visual system– Remove imperceptible data– Introduce (hardly) noticeable distortions

Page 20: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Spatial redundancies

Direction scientifique20

Page 21: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Spatial transform coding

2DDCT

lossless coding

Direction scientifique21

2DIDCT

lossless decoding

Page 22: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Entropy coding

• Modeling– Estimate probabilities of the symbols

• Coding– Produce a bit sequence based on these probabilities– Most common symbols use the shortest codes

P =0.5, P =0.25, P =0.125, P =0.125

Direction scientifique22

• Huffman coding• Arithmetic coding

1

001

00

001

000

AT

C

G

PA=0.5, PT=0.25, PC=0.125, PG=0.125

Page 23: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Temporal redundancies

Direction scientifique23

Page 24: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Temporal predictive coding

� Prediction by frame difference: 1

~ˆ−= kk ff

current frame prediction errorkkk ffe ˆ−=

Direction scientifique24

previous frame

Page 25: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Motion estimation and compensation

For every block in a current frame, the most similar block in a reference frame is searched for.

Direction scientifique25

f(x,y,t -∆t) f(x,y,t)

• Assumptions- The motion of pixels within the same block is uniform.

Page 26: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Backward motion compensation

1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

1 2 3 54

6 7 8 9 1011 12 13 14 15

Direction scientifique26

11 12 13 14 15

16 17 18 19 20

11 12 13 14 1516 17 18 19 20

Previous frame Current predicted frame

Page 27: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Block matching motion estimation

dxdy

dxdy

Matching block

Direction scientifique27

f(x,y,t) f(x,y,t -∆t)

dx dx

Search window

• Parameters- Search strategy: number of candidate blocks, search order, maximum

displacement- Matching function- Block size

Page 28: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Block matching motion estimation

� Similarity measure

� Search methods• full-search

∑ ∆−−−−B

yx ttdydxftyxf ),,(),,(min

Direction scientifique28

• logarithmic• N-step• conjugate• pyramidal• …

Page 29: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Block matching motion estimation� Advantages

• Explicit minimization of prediction errors• Regular structure (specially in full search): suitable for VLSI

implementation• Low overhead (one motion vector per block)• Robustness to noise

� Drawbacks

Direction scientifique29

� Drawbacks• Complex• High prediction errors in the border regions of moving objects• Blocking artifact

Page 30: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Hybrid video coding - Encoder

input frame

Direction scientifique30

input framesplit in 16x16 MBand 8x8 Block

Page 31: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Hybrid video coding - Decoder

Direction scientifique31

Page 32: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Hybrid video coding

• Hybrid motion compensated DCT– 8x8 block DCT– 16x16 Macroblock motion compensation with ½ pixel accuracy– Scalar quantization– Zig-zag scan– Variable-length coding and run-length coding

Direction scientifique32

Page 33: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

I-/P-/B-frames

• Intra-frames (I)– Independently coded (JPEG-like)– Low compression, low complexity– Random access– Error robustness

• Predicted-frames (P)

I P P P

Direction scientifique33

• Predicted-frames (P)– Predicted from previous I/P frame– High compression, high complexity

• Bidirectional-frames (B)– Predicted from previous and next I/P frames– Coding delay

I B B P

Page 34: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Group of Pictures (GOP)

• Start with an I-frames

Direction scientifique34

Page 35: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

MPEG-4 AVC / H.264

Direction scientifique35

Page 36: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

H.264/AVC

�Advanced Video Coding• State-of-the-art video coding performance • Also known as MPEG-4 Part 10, AVC, H.264

� International standard since 2003�Better compression efficiency when compared

to earlier standards (H.263, MPEG-2, MPEG-4)

Direction scientifique36

to earlier standards (H.263, MPEG-2, MPEG-4)• Mainly due to a better prediction

�But more complex• Remains reasonable especially as decoder

Page 37: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Block Diagram: H.264/AVC Encoder

Direction scientifique37

Page 38: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

4x4 integer transform

� 4x4 DCT-like transform• Efficient implementation

(additions, subtractions, bit shifts)• Avoid mismatch between

encoder and decoder• 2nd level transform on the 16 DC

coefficients of a 16x16 MB

1 1- 1- 1

2- 1- 1 2

1 1 1 1

Direction scientifique38

• 2 level transform on the 16 DC coefficients of a 16x16 MB

� Quantization• Non-linear step size control

1- 2 2- 1

Page 39: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Intra prediction

� Directional spatial prediction• 16x16 (luma, 4 modes)

horizontal vertical

Direction scientifique39

average planar

Page 40: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Intra prediction

� Directional spatial prediction• 4x4 (luma, 9 modes)

Q A B C D E F G HI a b c dJ e f g hK i j k lL m n o pMNOP

Direction scientifique40

Page 41: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Temporal prediction

� Flexible block MC• Variable motion block sizes

0

16x16

0 1

8x16MB

Types

8x80 1

2 3

16x8

1

0

Direction scientifique41

• Motion estimation at ¼ pixel accuracy (6-tap filter)(1/8 sample bilinear for chroma)

8x8

0

4x8

0 10 1

2 3

4x48x4

1

08x8Types

Page 42: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Temporal prediction and mode selection

� Lagragian optimization• Mode selection:

• D: Bloc distortion (e.g. MSE), include prediction, transform and quantization

• R: associated bitrate (MV, residual, signaling)

Direction scientifique42

• R: associated bitrate (MV, residual, signaling)• Motion estimation:

• D: e.g. SAD from block matching• R: bitrate to encode motion vectors

• (This process is not normative!!)

Page 43: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Temporal prediction

Direction scientifique43

Page 44: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Generalized P- and B- frames

� Generalized P- and B-frames• Flexible choice of reference frame for motion compensation• Multiple reference frames (up to 5)• List of reference frames• B-frames with arbitrary weights

Direction scientifique44

Page 45: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

In-loop Deblocking

� Post-filtering• Independent of the encoding/decoding• Out of scope of the standard• Flexible design

� In-loop deblocking

Direction scientifique45

� In-loop deblocking• Filtering is applied in the prediction loop• Process is normalized• Better performances (subjective and objective)

Page 46: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

In-loop Deblocking

Direction scientifique46

Page 47: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Two entropy codes: CAVLC and CABAC

� Entropy coding• CAVLC: Context-Adaptive Variable Length Coding

• CABAC: Context-Adaptive Binary Arithmetic Coding• Binary arithmetic coding similar to JPEG 2000• More complex but 5~10 % better compression efficiency

Direction scientifique47

• More complex but 5~10 % better compression efficiency

Page 48: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Weighted Prediction

� Weighted prediction• Inter-picture prediction with scaling and offset• Encoder-specified or timing-derived weights• Multiple weights per picture supported• Tremendous advantage for fade-in, fade-out, and

cross-fades

Direction scientifique48

cross-fades

Page 49: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Flexible Marcoblock Ordering (FMO)

� FMO• Simple type of Multiple Description Coding• Improve error robustness

Direction scientifique49

Page 50: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Profiles / levels

� Profiles• Set of tools targeting specific classes of

applications- Baseline Profile: low-cost applications, error robustness- Main Profile: digital TV broadcast- Extended Profile: streaming video- High Profile: HDTV, blu-ray

Direction scientifique50

- High Profile: HDTV, blu-ray- High 10: 10 bits per sample- High 4:2:2: 4:2:2 chroma sampling, up to 10 bits- High 4:4:4: 4:4:4 chroma sampling, up to 14 bits- (21 profiles!)

� Levels• Set of constraints: maximum picture resolution,

frame rate, bit rate, etc…

Page 51: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Test: Mobile & Calendar (CIF)

Direction scientifique51

Page 52: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Test: Bus (CIF)

Direction scientifique52

Page 53: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Scalable Video Coding (SVC)

• Extension of AVC – Encode once, decode many times– Universal Media Access (UMA)

Direction scientifique53

Page 54: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Scalable Video Coding (SVC)

• Layered coding– Base layer

� H.264/AVC compatible� can be decoded by all H.264/AVC decoders

– Enhancement layers:� Useless without the base layer� Spatial resolution

Direction scientifique54

� Spatial resolution� Temporal resolution� Quality

Page 55: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Scalable Video Coding (SVC)

Direction scientifique55

Page 56: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Scalable Video Coding (SVC)

• Video transmission without scalability

Direction scientifique56

Page 57: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Scalable Video Coding (SVC)

• Video transmission with scalability

Direction scientifique57

Page 58: Video compression MPEG-4 AVC/H · -Main Profile: digital TV broadcast-Extended Profile: streaming video-High Profile: HDTV, blu -ray 50 Direction scientifique-High 10: 10 bits per

Multiview Video Coding (MVC)– Multiple cameras capturing overlapped images from the same

scene with different viewing position

Direction scientifique58

• Extension of AVC– Predictive coding along time and

across views– Very complex encoder– Cameras have to communicate