Subframes
The core codes each channel as 32 subbands. A subband sample is one output of a 32-band analysis filter, so a block of 32 PCM samples gives one sample in each subband. Samples go in groups of 8 (a subsubframe, 256 PCM samples). A subframe holds 1 to 4 subsubframes (the SSC field), and a frame holds SUBFS + 1 subframes; the subsubframes of all the subframes together are NBLKS ÷ 8 in a well-formed frame (a decoder refuses a frame with more). Each subframe has two parts: its side information, then its audio data.
Side information
- SSC (2 bits): the subsubframe count minus 1, and PSC (3 bits, ignored by the decoder): the partial subsubframe sample count.
- PMODE (1 bit for each channel and each active subband): whether the subband’s samples are predicted from the four before them.
- PVQ (12 bits, where PMODE is 1): which of 4,096 sets of four prediction coefficients to use.
- ABITS (for each channel and each subband below the VQ start): the quantiser resolution of the subband, 0 to 26. Coded with the Huffman book of BHUFF or as a plain 4 or 5-bit value. 0 means no samples are sent; 1 to 26 select a quantiser with from 3 levels up to 8,388,608.
- TMODE (only in a subframe of more than one subsubframe, for each subband with ABITS above 0): the subsubframe, 0 to 3, where a transient begins; 0 means none. A subband with a transient has two scale factors, one before and one from that subsubframe.
- SCALES: the scale factor of each subband (two for a transient). Huffman coded as differences from the previous one (SHUFF 0 to 4), or as a 6 or 7-bit index into a table of 64 or 128 values (nominally 2.2 dB and 1.1 dB apart). The subbands from the VQ start have a scale factor even though they carry no ABITS.
- JOINTSHUFF (3 bits) and JOINTSCALES: for a channel that takes subbands from another (JOINX), the scale factors, from a table of 129 values, that scale the source channel’s samples into this channel.
- DRC (8 bits, when DYNF is 1) and a 16-bit CRC when CPF is 1.
Audio data
- VQ samples: for each subband from the VQ start, 10 bits that index a table of 1,024 vectors of 32 samples (8-bit values), scaled by the subband’s scale factor.
- LFE: 2 × LFF × subsubframes samples of 8 bits (2 or 4 for every 256 PCM samples), then an 8-bit scale factor index into the 7-bit scale table. The samples are multiplied by the scale and a step of 0.035.
- Subband samples: for each subsubframe, for each channel, for each subband below
the VQ start, 8 samples coded by the subband’s ABITS: Huffman codes (when the SEL field of that
resolution selects a book), block codes (a pair of integers that pack the samples as digits in
base 3 to 25, up to resolution 7), or 8 plain two’s-complement values. After the last channel of
a subsubframe, a 16-bit
FFFFsync word if ASPF is 1 or if it is the last subsubframe of the subframe.
Rebuilding the subband samples
Each sample is its code times the quantiser step of its ABITS times the scale factor (a Huffman coded subband’s scale is first multiplied by its ADJ value). Where PMODE is set the decoder adds the prediction: the sum of the four previous samples of the subband (the last four of the previous frame at the start, unless HFLAG is 0) times the four coefficients of PVQ. Last, a channel with JOINX takes the subbands above its own SUBS from the source channel, scaled by the JOINTSCALES. The 32 subband streams of a channel then go through the synthesis filter bank (see the overview) and the sum and difference channels (SUMF, SUMS, and AMODE 3) are turned back into left and right.