240 likes | 447 Views
CS529 Multimedia Networking. Video Compression. Material from: Sanjiv Malik, http ://www.slideshare.net/sanjivmalik/video-compression-basics#btnNext Iain Richardson, http://www.vcodex.com/files/videocoding2b.pdf. Need for Compression.
E N D
CS529Multimedia Networking Video Compression Material from: Sanjiv Malik, http://www.slideshare.net/sanjivmalik/video-compression-basics#btnNext Iain Richardson, http://www.vcodex.com/files/videocoding2b.pdf
Need for Compression • Color image, 352x288 pixels, 24-bit “true” color 304 kbytes • 12-bit “reduced” color 152 kbytes • “VHS” quality (352x288, 12-bit, 25 f/s) 30.4 Mb/s • “Television” quality (704x576, 12-bit, 25 f/s) 121.7 Mb/s • Too much data for transmission or storage!
Compression Strategy • Entropy compression • Remove statistical redundancy from data • Encode common values with fewer bits • Good for text files, not so good for images since not a lot of natural entropy • Remove subjective redundancy of images
Blocks • Blocks are 8x8 samples • Convert RGB into YUV (Luminance and Chrominance) • Fewer bits for Chrominance
Discrete Cosine Transform (DCT) • Convert spatial domain to frequency domain • So, rather than pixel values, how pixels change across image • Possible to separate out (and discard) based on frequency • Human eye not very sensitive to high frequency changes in images, so can discard
Discrete Cosine Transform • Block can be represented by sum of 64 basis patterns • Output of DCT is weights for patterns (the DCT coefficients) • Multiply each base by weight and add to get original image block
Usefulness of DCT • Most images only contain a few significant coefficients (usually lowest frequencies)
Quantization DCT • DCT values are floating point – change to integers during quantization • Divide each DCT by integer, discard remainder • Loss of precision • Typically, many are then 0 Quant Matrix Final Matrix Next, Entropy encoding (lossless)
Zigzag Scanning • Process (“scan”) quantized coefficients in zig-zag order • Non-zero coefficients tend to be grouped
Run-level Encoding • Encode each coefficient as (run, level) pair • Run – number of zeros • Level – non-zero value
Huffman Encoding • Use variable length code where probability of number determines bits • More common, fewer bits and vice versa • Table sent/stored with encoding
Image Compression • Reverse stages to decompress • Information lost during quantization • Original image not the same • Too much lost, block edges show (“blockiness”) and high-frequency patterns appear (“mosquito noise”)
Video Compression • Moving pictures don’t change much from image to image • Add extra “motion model” to front end of image compression 10 F/S Video
Motion Estimation and Compensation • Subtract previous frame from current frame
Motion Estimation with Blocks • Divide frame into blocks (e.g. 16x16 MPEG) • Look for “match” within range (e.g. 64 pixels) • Calculate offset (motion vector)
Motion Vectors • Have direction and magnitude • Have error
Bi-directional Prediction • Can look forward or backward
Standards • MPEG (next paper) • MPEG-1: Initially storage (CD or Internet) • MPEG-4: general purpose, prevalent • Basis for QuickTime • H.261, H.263 • Video conferencing • H.264 uses best of both • Blue-ray, Vimeo, YouTube, Silverlight …