Frame header
A core frame starts with the sync word 7FFE8001 and the frame header of clause 5.3.1
of ETSI TS 102 114. Fields are packed with no padding, most significant bit first (in the
big-endian 16-bit form; the other byte forms are unpacked to it first). The header is 104 bits, or
120 when the CRC is present.
| Field | Bits | Meaning |
|---|---|---|
| SYNC | 32 | 0x7FFE8001 |
| FTYPE | 1 | 1 for a normal frame; 0 for a termination frame, the last of a stream, which may be shorter |
| SHORT | 5 | the deficit sample count minus 1: 31 (32 samples in each block) in a normal frame |
| CPF | 1 | 1 when the header and the side information carry CRC words |
| NBLKS | 7 | the number of 32-sample PCM blocks in the frame, minus 1; a multiple of 8 blocks in a normal frame, so a frame is 256 to 4,096 samples a channel |
| FSIZE | 14 | the frame size in bytes, minus 1 (at least 96 bytes in all) |
| AMODE | 6 | the channel arrangement, below |
| SFREQ | 4 | the sampling rate of the core, below |
| RATE | 5 | the transmission bit rate, below |
| FIXEDBIT | 1 | reserved |
| DYNF | 1 | 1 when each subframe carries a dynamic range coefficient |
| TIMEF | 1 | 1 when a 32-bit time stamp follows the audio data |
| AUXF | 1 | 1 when auxiliary data follow the audio data |
| HDCD | 1 | 1 when the source was HDCD mastered |
| EXT_AUDIO_ID | 3 | which extension the frame may carry: 0 XCh, 2 X96, 6 XXCh (other values reserved) |
| EXT_AUDIO | 1 | 1 when the extension named by EXT_AUDIO_ID is present |
| ASPF | 1 | 1 when a sync word (FFFF) follows every subsubframe, 0 when only every subframe |
| LFF | 2 | the LFE channel: 0 none, 1 present with a 128 times decimated signal, 2 present with 64 times (3 is invalid) |
| HFLAG | 1 | 1 when the prediction history of the previous frame is kept, 0 when it is cleared at the start of the frame |
| HCRC | 16 | only when CPF is 1: the CRC of the header |
| FILTS | 1 | 1 for the perfect-reconstruction filter bank coefficients, 0 for the non-perfect ones |
| VERNUM | 4 | the version of the encoder syntax (the decoder does not depend on it) |
| CHIST | 2 | the copy history |
| PCMR | 3 | the source resolution, below |
| SUMF | 1 | 1 when the front pair is coded as sum and difference |
| SUMS | 1 | 1 when the surround pair is coded as sum and difference |
| DIALNORM | 4 | the dialogue normalisation; its meaning depends on VERNUM (6 and 7 define it) |
AMODE: the channel arrangement
| AMODE | Channels | Arrangement |
|---|---|---|
| 0 | 1 | A (mono) |
| 1 | 2 | A + B (dual mono) |
| 2 | 2 | L + R (stereo) |
| 3 | 2 | (L + R) + (L − R) (sum and difference) |
| 4 | 2 | LT + RT (left and right total, matrix encoded) |
| 5 | 3 | C + L + R |
| 6 | 3 | L + R + S |
| 7 | 4 | C + L + R + S |
| 8 | 4 | L + R + SL + SR |
| 9 | 5 | C + L + R + SL + SR |
| 10 to 13 | 6 to 7 | arrangements with more front or surround channels (CL + CR + L + R + SL + SR and others); the core decoder refuses them |
| 14, 15 | 8 | user defined |
SFREQ, RATE and PCMR
| SFREQ | Core sampling rate |
|---|---|
| 1 | 8,000 Hz |
| 2 | 16,000 Hz |
| 3 | 32,000 Hz |
| 6 | 11,025 Hz |
| 7 | 22,050 Hz |
| 8 | 44,100 Hz |
| 11 | 12,000 Hz |
| 12 | 24,000 Hz |
| 13 | 48,000 Hz |
| 0, 4, 5, 9, 10, 14, 15 | invalid |
| RATE | Bit rate (kbit/s) |
|---|---|
| 0 to 7 | 32, 56, 64, 96, 112, 128, 192, 224 |
| 8 to 15 | 256, 320, 384, 448, 512, 576, 640, 768 |
| 16 to 24 | 960, 1,024, 1,152, 1,280, 1,344, 1,408, 1,411.2, 1,472, 1,536 |
| 29 | open (no fixed rate) |
| 31 | lossless (the core carries a lossless residual) |
| 25 to 28, 30 | invalid |
| PCMR | Source resolution |
|---|---|
| 0 | 16 bits |
| 1 | 16 bits, ES mastering |
| 2 | 20 bits |
| 3 | 20 bits, ES mastering |
| 5 | 24 bits |
| 6 | 24 bits, ES mastering |
| 4, 7 | invalid |
The ES flag (odd PCMR) says the source was mastered with the extra rear centre channel mixed into the surrounds, which XCh undoes.
Audio coding header
The primary audio coding header (clause 5.3.2) follows the frame header and holds what the decoder needs for every subframe of the frame. Each field below is repeated for each primary channel ch, in the order given (all the SUBS values, then all the VQSUB values and so on).
| Field | Bits | Meaning |
|---|---|---|
| SUBFS | 4 | the number of subframes, minus 1 |
| PCHS | 3 | the number of primary channels, minus 1; it must agree with AMODE |
| SUBS[ch] | 5 | the number of active subbands, minus 2 (so 2 to 32) |
| VQSUB[ch] | 5 | the subband from which the samples are vector quantised, minus 1 |
| JOINX[ch] | 3 | 0, or the channel (1 to 5) that supplies this channel’s high subbands by joint intensity coding |
| THUFF[ch] | 2 | the code book (A to D) of the transient position |
| SHUFF[ch] | 3 | the scale factor coding: 0 to 4 Huffman code books A to E, 5 a 6-bit value, 6 a 7-bit value (7 is invalid) |
| BHUFF[ch] | 3 | the bit allocation coding: 0 to 4 Huffman books A to E, 5 a 4-bit value, 6 a 5-bit value (7 is invalid) |
| SEL[k][ch] | 1, 2 or 3 | for each of the ten quantiser resolutions (k = 0 to 9, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 bits): which Huffman book codes the samples of that resolution (below the group size, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7); otherwise block codes for the first seven, and plain values for the rest |
| ADJ[k][ch] | 2 | present where SEL selects a Huffman book: a scale factor adjustment of 1.0, 1.125, 1.25 or 1.4375 |
| ACRC | 16 | only when CPF is 1: the CRC of the header |
After the coding header come the subframes: see audio data. After the last subframe come the optional time stamp (TIMEF), the auxiliary data (AUXF) and the extension data (EXT_AUDIO); the frame ends at FSIZE + 1 bytes.
Frame size and the byte forms
FSIZE + 1 is the size of the frame in the 16-bit big-endian form. A frame in the 14-bit forms holds the same bits in 14-bit words, so it takes 16/14 as many bytes (a whole number of 7-byte groups, 8 bytes in the file); a frame in a little-endian form has each pair of bytes swapped. A stream may hold a few bytes of padding after a frame, which readers skip by looking for the next sync word. A decoder accepts a frame as real only when its header is consistent: the deficit sample count, the number of blocks and the frame size of at least 96 bytes.