Context Adaptive Variable Length Coding (CAVLC) is a method used to encode residual, scan ordered blocks of transform coefficients.
coeff_token必须使用VLC Table来查找对应的二进制.
coeff_token 编码了 Toal-Coeffs 代表非 0 coefficient的个数,取值从0到16.同时也编码了 Trailiing 1s(T1s). 从 0 到 3. 代表有多少个coefficient数据是1 或者 -1,从高频到低频排序.
For Luma, Chroma DC (4:4:4) and Chroma AC.
(T1, numCoeff) will be coded based on nCContext. nCContext = (nCA + nCB + 1) >> 1. nCA is the number of nonzero coefficients available in the left 4x4 submacroblock and nCB is the number of nonzero coefficients available in the up 4x4 submacroblock.
如果nCb不可以用,nCC = nCb.
如果nCa不可以用,nCC = nCa.
如果两者都不可以用,nCC = 0;
根据nC,T1 ,numCoeff 编码 coeff_token,如下图
For ChromaDC.
If chroma_format_idc is equal to 1, nC is set equal to -1 |
---|
Otherwise,if chroma_format_idc is equal to 2, nC is set equal to -2 |
Otherwise (chroma_format_idc is equal to 3), nC is set equal to 0 |
顺序为从高频到低频, 0 = +1, 1 = -1.
level 由两个部分组成 prefix 和 suffix. 通俗的来说就是,prefix代表了高位的数据,suffix代表了低位的数据.
prefix总是以1结尾.
官方decoding代码
Encoding level算法
encoding level算法的例子.
假设如下4*4block
Reordered block:?2, 4, 3, ?3, 0, 0, ?1, ...
TotalCoeffs = 5
TotalZeros = 2
T1s = 1
For Luma, Chroma DC (4:4:4) and Chroma AC, the (total_zeros, numCoeff) table
For Chroma DC (4:2:0), the code for total_zeros
for Chroma DC (4:2:2)
原文:https://www.cnblogs.com/robsann/p/14736340.html