[theora-dev] theora-dev Digest, Vol 80, Issue 6

Timothy B. Terriberry tterribe at xiph.org
Tue Mar 22 12:55:38 PDT 2011


> How add zero-ACs coeff to AC(1..61) planes? Or i skip them in this
> planes and add store only non-zero coeff to plabes?

I recommend looking at how libtheora does this. The encoder translates 
things into the "tokens" which represent various combinations of 
coefficient values, zero runs, and "End Of Block" (EOB) markers. See the 
Theora specification for details. It stores these values to an 
intermediate buffer (for the purposes of re-ordering them) before 
translating them into Huffman codes. You won't have a token for every 
coefficient, but the token value (along with some amount of "extra 
bits", which varies depending on the token value) encodes all the 
information you need about whether or not there is a zero run at a given 
position, how long it is, etc.

libtheora has to go through some trickery to handle the DC values, 
because DC prediction occurs in raster order, not coded order. Since 
you're generating tokens in raster order, this shouldn't be an issue for 
you, as you can do DC prediction before tokenization.

However, you won't be able to use runs of EOBs, because these operate 
across blocks in coded order (as opposed to runs of zero coefficients 
operate within a single block). You may be able to fix this up in a 
separate post-processing stage (e.g., as part of the translation to 
Huffman codes). I.e., instead of writing out an EOB token immediately, 
buffer it and if the next token is also an EOB token, then extend the 
previous one into a longer run of EOBs, otherwise write out the buffered 
EOB token, if any.


More information about the theora-dev mailing list