You are on page 1of 21

Compression Methods

MPEG-2 and JPEG

Compression, why and how ?


We want to remove as much data as possible without affecting the picture quality (bandwidth = money) Our eyes are less sensitive to high frequency components in a video frame The decoding must be done in realtime (but encoding can take some time) MPEG-2 (Moving Picture Expert Group) defines a set tools for compression. Compression rates can vary over time The video stream indicates the compression tools that are actually used together with parameters needed for decoding.

Bitrates of uncompressed video


8 bits/sample 720 samples/line 576 lines/frame 25 frames/s gives a bitrate of 83 Mbit/s for each of the three components Y, Cr and Cb Symbolrate of a typical transponder is 27 MSymbols/s which corresponds to a bitrate of 36Mbit/s for video Each transponder contains in average 6 different video streams The compression factor has to be (2 * 83) / ( 36 / 6) = 28 !!!

Compression of Fixed Pictures


8 8

Divide the picture into Macroblocks to facilitate DSP.

Two Digital Formats


Macroblock in 4:2:2

Macroblock in 4:2:0

16

Y 16

16 Cr 4

Cb

16

Y 4 Cr 16 4 Cb

= luminance sample = crominance sample

DCT (Discrete Cosine Transform)


Each macroblock (8x8 pixels) can be transformed from the time domain to the frequency domain. A matrix indicates the amplitude of each frequency component.

2 components

more components gives more details... ...but our eyes are less sensitive to high frequency components

3 components

4 components

Contribution of the DCT Coefficients


Horizontal Frequency
DC Coefficient

Vertical Frequency

Picture Quality

Only one DCT coefficient

3 Coefficients is enough for a nice picture.

Seems like we dont have to transmit the high frequqency components.....

Quantization and Treshholding

Read the Coefficients the Zig Zag way...

Apply RLC (Run Length Coding)....


G = Greean R = Red B = Blue

No Coding :G G G G G G G G G G G G G G G G B B B B B B B B B B R R R R R Run Length Coding : 16*G 10*B 5*R

Equal elements in a row do not have to be coded individually, just transmit the elementcode and the number of successive occurances !

..and VLC (Variable Length Coding)


? Example : alphabet coding 0 11 110 1101 11010 110101 11011 110100 1100 111 10 100 101 1 (most frequent letters are coded with fewer bits) A C G E H B F 0 10 111 1100 11011 110100 110101 40

Video signals also contains more or less frequent elements (DCT coefficients)

Some Remarks..
Picture data is now compressed by a factor 8 (at least)...

The process is the same as for JPEG Compression of Y, Cr and Cb is done separately The decompression must be done in realtime The process is referred to as intra-frame-coding (removes redundancy within a frame) There are still a lot of redundancy to remove if we consider several frames (inter-frame-coding)

Compression of Moving Pictures


MPEG-1 : maximum bitrate = 1.5Mb/s (CD_ROM storage) MPEG-2 : allows higher bitrates, supports interlaced pictures MPEG-2 is back compatible with MPEG 1 MPEG-2 can be divided into several profiles and levels
The level describes the resolution The profile describse the set of tools used for the compression Digital (DVB) TV uses MP@ML (Main Profile@ Main Level)

MPEG1/2 contains compressing tools for audio too...

I, P and B Pictures
I (Intra) pictures
Coded without reference to other pictures Contains all necessary ino for their reconstruction Comparable with a JPEG picture Relatively low compression rate (about 1:8) Coded from preceeding I or P pictures using motion compensation Higher compression rate (about 1:25) Coded by bidirectional interpolation between preceeding and following I and P pictures High compression rate (about 1:70) MP@ML has the parameters (M,N) = (3,12)

P (Predicted) pictures

B (bidirectional) pictures

I, P and B pictures are arranged in a Group of Pictures (GOP)

MPEG Video Layers


Sequence Layer Group of Pictures Layer (GOP)

I BB P BB P BB P BB I

.....

Macroblock Layer

Slice Layer
16

Y1 Y2 Y3 Y4 16

Cr

Cb 4 4

Block Layer

The Elementary Stream


Sequence header Video sequence Sequence header Video sequence Sequence header GOP GOP GOP

GOP header

Picture

Picture

Picture

Picture Header

Slice

Slice

Slice

Slice Header

Macroblock

Macroblock

Macroblock

Macroblock header Block1(Y)

Block2(Y)

Block3(Y)

Block4(Y)

Block5(C)

Block6(C)

Reordering of pictures
Display Order

1 I

2 B

3 B

4 P

5 B

6 B

7 P

8 B

9 B

1 0 P

1 1 B

12 13 B I

Video Stream Order

1 I

4 P

2 B

3 B

7 P

5 B

6 B

1 0 P

8 B

9 B

13 I

1 1 B

12 B

Both I and P pictures are needed in advance to code/decode the B picture

Motion Estimation
Search Window (Block Matching)

Frame1

Frame2

Only the motion (displacement) vectors of the macroblocks are transmitted

I and P pictures can differ a lot so a difference picture is encoded (pixel by pixel difference) Also called predicted error For the same reason as for I pictures, DCT, VLC and RLC coding is applied to the predicted pictures Both motion vectors and predicted errors defines the P picture (motion compensation)

Coding P pictures

Coding B picture
Linear Interpolation (of prediction error and motion vectors) between previous and following I and (or) P pictures I and P pictures needed in advance to create B pictures

You might also like