Saturday, January 09, 2010

JPEG

Basic BMP -> JPG process:
BMP -> YUV 420
YUV420 sampling. Using one 16x16 mcu, and six 8x8 DU: Y0,Y1,Y2,Y3,U,V
DCT to every DU
Quantize DU using table, zigzag scan
Huffman coding and get bits
Write bits to file
Y/U/V components of an image, which use fixed sampling factor 2x2 for Y (luminance), and 1x1 for U/V (chrominance). Using this sampling scheme, each pixel will only require 12 bit to record the color (2 pixels = (4Y + 1U + 1V)*4 = 24 bit, 1 pixel = 12 bit).

For each component, a DU (data unit) in JPEG represents a 8x8 byte matrix, by using huffman coding the zigzaged 64 FDCT coefficients;

By using the YUV12 sampling scheme, a MCU (minium coded unit) in JPEG represents a 16x16 (pixel) image block, by using 6 DUs in this sequence: YDU, YDU, YDU, YDU, UDU, VDU.

default quantization tables for luminance and chrominance
provided by "ISO/IEC 10918, 1993(e)" Annex K:

luminance quantization table:

16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
14 13 16 24 40 57 69 56
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99

chrominance quantization table:

17 18 24 47 99 99 99 99
18 21 26 66 99 99 99 99
24 26 56 99 99 99 99 99
47 66 99 99 99 99 99 99
99 99 99 99 99 99 99 99
99 99 99 99 99 99 99 99
99 99 99 99 99 99 99 99
99 99 99 99 99 99 99 99

In quantise: where vector is raw data, qt is the table.
for(i = 0; i <>

No comments:

Post a Comment