Table of Contents

Serialized quantization unit tree IDs

The frequency space data of the quantization units is generally Huffman encoded. There are two tree sets, which will be called tree set A and tree set B. Each of the tree sets consists of 8 trees for each quantization precision (except precision 0 which means that no data is present). Some of the trees are duplicate.

As opposed to the quantization unit levels, which are stored for all quantization units up to the last quantization unit with a non-zero precision, Tree IDs are not stored for quantization units with a zero precision at all, even if the zero quantized quantization unit is followed by a quantization unit with a non-zero precision.

The tree choice may either be complete (each quantization unit chooses one of the eight trees for it's quantization precision) or restricted (each quantization unit chooses one of the four most common trees for it's precision). The choice between complete or restricted selection is global for the whole substream, not just for the channel! Thus the bit is not described here, in the per-channel tree choice data, but in the parent page substream data.

Another catch is that the Tree ID is reused as a joint stereo flag. If the quantization precision is zero for the slave channel, but non-zero for the master channel, the slave channel has (contradicting to the simplified introduction) still one bit stored. If this bit is zero, The data from the master channel is reused, if this bit is one, the precision value of zero is taken literally (as it is always for the master channel) and the frequency data is completely zero.

If quantization unit specific info is given at all (i.e. not mode 3 on master channel), then a bit indicates whether tree IDs are stored for all quantization units that need them, or only for the some first quantization units (number given) and the remaining tree IDs are implicitly zero.

Encoding Modes

Mode 0: direct encoding

The value to encode for each quantization unit is directly encoded as binary number. It's a three bit number for complete tree access, a two-bit-number for restricted tree access or a one-bit joint-stereo flag.

Mode 1: Huffman encoding

For a complete tree ID, the value is from the full tree ID tree. For a restricted ID, the value is from the restricted tree ID tree. In the case of a join-stereo flag instead tree ID, that bit is stored directly.

Mode 2: Delta encoding

For quantization units needing a joint-stereo flag this mode works like mode 0 and mode 1 do, too, it just fetches a bit. Otherwise, the Tree ID for the first quantization unit is loaded as in mode 1 (if needed). All further tree IDs are encoded relatively to the last tree ID (starting at 0 if the first quantization unit has no tree ID) using a code from the restricted tree ID tree or delta-to-prev tree ID tree. The application of the differences wraps around after 3 or 7 respectively.

Mode 3 on master channel: Just zero

All Tree IDs are just zero, and the "don't copy" flag is always cleared.

Mode 3 on slave channel: Difference to master

For quantization units needing a joint-stereo flag, this modes works like all other modes providing data: It's just a single bit. For quantization units needing a tree ID, the difference to the tree ID of same quantization unit in the master is encoded using restricted tree ID tree or delta-to-master tree ID tree, depending on whether this frame uses complete or restricted tree IDs.

Encoding

Encoding mode 0: direct encoding

Encoding mode 1: Huffman encoding

Encoding mode 2: Delta encoding

Encoding mode 3 on master channel: Just zero

This encoding mode needs no data

Encoding mode 3 on slave channel: Difference to master