Introduction:
H.264, the latest video compression standard, uses CAVLC for encoding the coefficients after quantization. CAVLC encodes the coefficients (the coefficients may be positive or negative) into binary bit stream.
Original
Residue

DCT
Quantization
CAVLC
Predicted
NALU
In H.264 Encoder, the predicted submacroblock (of size 4x4) is subtracted from the original submacroblock (of size 4x4), resulting the residue submacroblock (of size 4x4). This residue is transformed by modified Discrete Cosine Transform. The transformed residue is also of size 4x4. Then this transformed residue is quantized (dividing by some defined number, QStep). This quantizedtransformed residue is encoded as follows. Encoding process:
There will be 16 coefficients in a 4x4 submacroblock. The total number of coefficients is tot_coef = 16.
(0,0)
(1,0)
(2,0)
(3,0)
(0,1)
(1,1)
(2,1)
(3,1)
(0,2)
(1,2)
(2,2)
(3,2)
(0,3)
(1,3)
(2,3)
(3,3)
The 16 coefficients are taken in a zigzag manner as shown in the above figure, and written in an array.
(0,0) – (0,1) – (1,0) – (2,0) – (1,1) – (0,2) – (0,3) – (1,2) – (2,1) – (3,0) – (3,1) – (2,2) – (1,3) – (2,3) – (3,2) – (3,3)
Note: For Chroma coding, two different blocks will come for coding. One is Chroma DC of 2x2 size (in case of 4:2:0), or 4x2 size (in case 4:2:2) or 4x4 size (in case of 4:4:4). Here, tot_coef = 4.
Another one is Chroma AC of 4x4 size. But in this Chroma AC, the DC Coefficient is 0 at (0,0). Here, tot_coef = 15.
The important parameters to be encoded.
1. Number of nonzero coefficients (numCoef) and Trailing Ones (T1) 2. The pattern of Trailing Ones (T1)
3. The nonzero coefficients (Levels)
4. Number of zeros embedded in the nonzero coefficients (Total_zeros) 5. The location of those embedded zeros (run_before)
1. Number of nonzero coefficients (numCoef) and Trailing Ones (T1)
CAVLC Encoder
2
Calculate number...