Each frame is one block of audio: this header, then one subframe per channel, then a footer. Frames start on a byte boundary and nothing else in them is aligned until the footer.
Sync and blocking strategy
A frame starts with the 15-bit sync code 111111111111100, then one bit
for the blocking strategy: 0 for a fixed block size, where the header
carries the frame number, and 1 for a variable block size, where it carries the number
of the frame’s first sample. As bytes, a frame starts FF F8 or
FF F9. The strategy must not change within a stream.
Block size
Four bits give the block size in samples.
| Code | Block size |
|---|---|
0000 | Reserved |
0001 | 192 |
0010 | 576 |
0011 | 1152 |
0100 | 2304 |
0101 | 4608 |
0110 | Uncommon: an 8-bit value after the coded number, block size minus 1 |
0111 | Uncommon: a 16-bit value after the coded number, block size minus 1. The value 65535 is forbidden |
1000 | 256 |
1001 | 512 |
1010 | 1024 |
1011 | 2048 |
1100 | 4096 |
1101 | 8192 |
1110 | 16384 |
1111 | 32768 |
Block sizes of 1 to 15 samples are allowed only in the last frame.
Sample rate
| Code | Sample rate |
|---|---|
0000 | Take it from STREAMINFO |
0001 | 88.2 kHz |
0010 | 176.4 kHz |
0011 | 192 kHz |
0100 | 8 kHz |
0101 | 16 kHz |
0110 | 22.05 kHz |
0111 | 24 kHz |
1000 | 32 kHz |
1001 | 44.1 kHz |
1010 | 48 kHz |
1011 | 96 kHz |
1100 | Uncommon: an 8-bit value after the block size, in kHz |
1101 | Uncommon: a 16-bit value after the block size, in Hz |
1110 | Uncommon: a 16-bit value after the block size, in tens of Hz |
1111 | Forbidden |
An uncommon rate must not be 0 when the stream has audio.
Channels and bit depth
Four bits give the channel assignment. Codes 8 to 10 are the stereo modes that store a side channel.
| Code | Channels |
|---|---|
0000 | 1: mono |
0001 | 2: left, right |
0010 | 3: left, right, centre |
0011 | 4: front left, front right, back left, back right |
0100 | 5: front left, front right, front centre, back left, back right |
0101 | 6: front left, front right, front centre, LFE, back left, back right |
0110 | 7: front left, front right, front centre, LFE, back centre, side left, side right |
0111 | 8: front left, front right, front centre, LFE, back left, back right, side left, side right |
1000 | 2: left and side |
1001 | 2: side and right |
1010 | 2: mid and side |
1011 to 1111 | Reserved |
Three bits give the bit depth, and one reserved bit after them must be zero.
| Code | Bit depth |
|---|---|
000 | Take it from STREAMINFO |
001 | 8 bits |
010 | 12 bits |
011 | Reserved |
100 | 16 bits |
101 | 20 bits |
110 | 24 bits |
111 | 32 bits |
Coded number
Next comes a number, in the same variable-length scheme as UTF-8, extended to 36 bits: the frame number for a fixed block size, up to 31 bits, or the number of the frame’s first sample for a variable block size, up to 36 bits. Numbers count from 0 and increase without gaps.
| Bytes | First byte | Largest value |
|---|---|---|
| 1 | 0xxxxxxx | 7F |
| 2 | 110xxxxx | 7FF |
| 3 | 1110xxxx | FFFF |
| 4 | 11110xxx | 1FFFFF |
| 5 | 111110xx | 3FFFFFF |
| 6 | 1111110x | 7FFFFFFF |
| 7 | 11111110 | FFFFFFFFF (36 bits) |
Each byte after the first is 10xxxxxx.
Uncommon values and CRC-8
Any uncommon block size and then uncommon sample rate follow the coded number, each
big-endian. The header ends with an 8-bit CRC of everything from the sync code up to
it: polynomial x⁸ + x² + x + 1 (0x07), starting from 0, most
significant bit first. A decoder that finds a wrong CRC treats the header as not being
a frame after all.
The streamable subset
A stream that can be decoded starting at any frame, without STREAMINFO, is in the
streamable subset: frames must spell out their sample rate and bit depth
(rate code not 0000, depth code not 000); blocks are at most
16384 samples, and at most 4608 at 48 kHz or below, where LPC is limited to order 12;
the Rice partition order is at most 8; and channels use the standard order, with no
speaker mask.