3. What is MPEG?
•
•
•
Moving Picture Experts Group
standards for audio video compression and transmission
asymmetric: encoder more complex than decoder
4. MPEG standards
•
MPEG-1
• first standard for audio and video (lossy compression)
• composed of 5 parts: Systems, Video, Audio,
Compliance testing, Software simulation
• up to 1.5 Mbit/s
• moderate quality
• MP3 audio format
6. Frames
Types of pictures:
I (intra) frame
compressed using only intra-frame coding
Moderate compression but faster random access
P (predicted) frame
Coded with motion compression using past I frames or P frames
Can be used as reference pictures for additional motion compensation
B (bidirectional) frame
Coded by motion compensation by either past or future I or P frames
D (DC) frame
Limited use: encodes only DC components of intra-frame coding
Only found in MPEG-1
7. Macroblocks
Macroblocks
-blocks of 16 x 16 pixels
-the smallest unit of data that can select a method of
compression, therefore they can be considered as the
minimum coded units in a picture.
Blocks
-are 8 x 8 blocks of pixels. There are six of these blocks
in each macroblock
8. Color Space
•
conversion to YcbCr (luma, chroma blue, chroma red)
the human eye is more sensitive to changes in brightness
=> chroma subsampling
•
- 4:2:0 subsampling - Cb and Cr are
subsampled at a factor of 2 both
horizontally and vertically
9. Motion Estimation
●
Base compression method for a variety of Codecs
●
Idea:
●
create a prediction frame (previous frame + motion)
●
determine the prediction error
●
storage needed: prediction error (small) + one 2D vector per block
●
●
Small prediction errors easy to compress with DCT+Quantization+Entropy
Encoding
Many possible approaches for Motion Estimation:
●
●
Hierachical Block Matching
●
Optical Flow
●
Netravali-Robbins Algorithm
●
●
Block Matching (Sum of Mean Difference, Sum of Absolute Difference)
...
Encoding speed highly dependend on used Motion Estimation Algorithm
10. Motion Estimation
Sum of absolute Differences
●
Search for the minimum sum of absolute difference between a Macroblock in
previous- and a shifted Macroblock in current frame
●
Macroblock with minimum SAD inherits a shift -> Motion Vector
●
Build a prediction picture from previous frame + Motion Vectors
●
Compute delta(current image, predicition image)
●
Store difference image + motion vector
lot's of motion -> hard to compress
minor motion -> good to compress
11. DCT
●
●
8x8 block values are coded by means of the discrete cosine
transform
main idea is to determine the brightness (64 pixels) and scale it
to some limits
–
●
0 – 255, 0 is black while 255 white (In MPEG a range from -256 to 255 is
used.)
64values
–
5values by using the following formulas
Where f(x,y) is the brightness of the pixel at position [x,y].
12. Example
the matrix is transfered to the receiver in zigzag scan order
So the trasmited code is:
700 90 90 -89 0 100 0 0 0 .... 0
Of course, the zeros are not transferred. An End-Of-Block sign is
coded instead.
13. Quantization
●
●
●
●
The decoder can reconstruct the pixel values by the following formula called inverse discrete cosine
transform (IDCT):
Where F(u,v) is the transform matrix value at position [u,v].
The results are exactly the original pixel values. Therefore the MPEG compression could be
regarded as loss-less.
But that isn't true, because the transformed values are quantized.
–
–
–
–
That means they are (integer) divided by a certain value.
To reduce them under the byte length at least the quantization value 8 is applied.
The decoder multiplies the result by the same value. Of course the result differs from the
original value. But again because of some properties of the human eye the error isn't visible.
In MPEG there is a quantization matrix which defines a different quantization value for every
transform value depending on its position.
14. Entropy coding
●
●
●
●
Huffman table, small
value -> small code
Input has many 0's
and values near 0
Implemented RunLevel coding for AC
DC coding regular->
15. Run level coding
●
All AC values has at
least 8 bits
●
●
RS = 00000000 -> EOB
R = 1111 can mean ZRL
but is ignored
Arranged as
RRRRSSSS
●
RS = 11110000 means
●
R is run length of 0's
●
15 0's with a 0 after it.
●
S is category 1-15
●
●
Not done on the GPU
because of wierd errors.
16. Implementation
•
•
•
MPEG-1 supports resolutions up to 4095×4095 and
bitrates up to 100 Mbit/s
The algorithms used in compression allow SIMD
operations
Implementation done with GPU computing using the
OpenCL standard