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.
Streams from before the blocking strategy bit
The blocking strategy bit was added in July 2007. Before that, the bit was a reserved 0 and
a variable block size stream was not marked as such. The coded number of such a frame is
the number of its first sample, but its header says 0 (a fixed block size). RFC 9639
Appendix B.1 gives the two ways a decoder had to detect such a stream: the minimum and
maximum block sizes in the STREAMINFO block differ (they are equal for a fixed block size
stream), or, without a STREAMINFO block, the block size changes during the stream. The
appendix also records that the block size codes 0001 to 0101 and
1000 to 1111 could at first be used only for fixed block size
streams, while 0110 and 0111 could be used for both; since the change all codes
0001 to 1111 are used for both. The viewer treats a frame with
bit 0 as old-format when STREAMINFO’s minimum and maximum block sizes differ and its
coded number equals the number of samples before it (and not the number of frames before
it); it then reads the number as a sample number and shows the frame header as
“variable (old format)”.
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 (RFC 9639 sections 4.1 and 9.1.6). Because a variable block size below 16 samples is therefore not allowed, a stream whose audio properties (rate, depth, channels) change within 16 samples of the last change or of the start cannot be stored in FLAC (section 9).
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/surround left, back/surround right |
0101 | 6: front left, front right, front centre, LFE, back/surround left, back/surround 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.
Changes between frames
Each frame header states its own sample rate, channel assignment and bit depth, so they may change from one frame to the next. RFC 9639 recommends against it: a stream whose properties change should be split, using a container such as Ogg, which starts a new chained stream.
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.