CSEP 590 Data Compression
CSEP 590 Data Compression
Autumn 2007
Video Compression
Video Encoding
Frame-by-Frame coding
Encoder video frames decoding each frame requires the previous frame
Group-of-Frames coding
Group of 144 4 2Frames 444 3
Coding Techniques
Frame-by-frame coding with prediction
Very low bit rates low delay Not error resilient
Group-of-frames coding
Higher bit rates within a group prediction is used Error resilient Random Access Higher delay
CSEP 590 - Lecture 13 - Autumn 2007 5
Motion Compensation
Previous Frame
Frame
8
Motion Vectors
Motion Vectors
Motion Compensation
For each motion compensation block
Find the block in the previous decoded frame that gives the least distortion. If the distortion is too high then code the block independently. (intra block) Otherwise code the difference (inter block)
The previous decoded frame is used because both the encoder and decoder have access to it.
12
Issues
Distortion measured in squared error or absolute error
Absolute error is quicker to calculate
Block size
Too small then too many motion vectors Too large then there may be no good match
Prediction resolution
Full pixel, half-pixel, quarter-pixel resolution Higher resolution takes longer, but better prediction results
CSEP 590 - Lecture 13 - Autumn 2007 13
Linear Interpolation
Calculate an interpolated pixel as the average of overlapping pixels. Better interpolation methods exist. Half
a1 a a3 a4 a2
a=
a1 4
a2 4
a3 4
a4 4
Quarter
a1 a3
a2 a4
a=
3a1 16
9a 2 16
a3 16
3a 4 16
15
Rate Control
Encoded frames buffer Decoder frame player
16
Underflow Problem
Set up
Constant rate channel at C bits per second Frame rate F in frames per second. bi is the number of bits in compressed frame i Initial occupancy of buffer B
Example
C/F = 60
20
buffer Decoder
100
initial
Decoder
40 20 20 60 bits that arrived
Decoder
100 20
18
Example
Decoder
100 20
Decoder
80 20 20 20 100
Decoder
20 80 20 20
Decoder
20 20 100 20
19
Rate Control
The rate control buffer is seeded to allow for variability in number of bits per frame and variability in channel rate. Causes of variability in bits per frame.
Encoder does not predict well how many bits will be used in a frame - scalar quantization. Encoder allocates more bits in frames that are hard to encode because they are not predicted well - scene changes.
Off-line solution
Attempt to allocate bits to frames to assure even fidelity. Seed the buffer with enough frames to prevent underflow.
CSEP 590 - Lecture 13 - Autumn 2007 21
H.261
Application low bit rate streaming video Frame-by-frame encoder DCT based with 8x8 coding block
Uses JPEG style coding
22
H.261
P-Frame
I-Frame
23
H.261(QCIF)
176 pixels Block Macroblock 144 pixels
99 motion vectors
24
H.261
Within a group of blocks (GOB) prediction is used with motion vectors for coding.
GOB
25
H.261 Organization
176 Picture Header GOB 1 Picture Frame 144 GOB 2 GOB 9 Group of Blocks Macroblock GOB Header MB 1 MB 2 MB 11
MB Header
Y1 Y3
Block
EOB
P-Frame
Inter Intra
27
Intra-Macroblock Distribution
Forman Video
28
MPEG-1
Application Video coding for random access Group-of-frames encoder DCT based with 8x8 coding block
Uses JPEG style coding
Motion compensation based on 16x16 macroblocks. Forward and Backward Prediction within a group of frames
29
MPEG-1
P-frames predicted by I-frames or P-frames B-frames predicted by I-frames and P-frames
P-Frame B-Frame
I-Frame
CSEP 590 - Lecture 13 - Autumn 2007 30
Orders
Display Order 10 9 8 7 6 5 4 3 2 1
Coding/Decoding Order 9 8 10 6 5 7 3 2 4 1
MPEG-1 Notes
Random access unit = Group-of-Frames
Called GOP for group-of-pictures
Error resilient
B-frames can be damaged without propagation
Added delay
Coding order different than display order
32
Beyond MPEG-1
MPEG-2
Application independent standard
MPEG-4
Multimedia applications Model based coding
H.263
More error resilience
33
Newest Trends
H.264
Just out in 2003, many new features Quarter pixel motion compensation Variable size motion blocks Multiple frame prediction
GTV
Group testing for video Bits per frame can be controlled enabling off-line rate control to succeed.
CSEP 590 - Lecture 13 - Autumn 2007 34