Data | Description |
---|---|
u(32) | "fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43 |
METADATA_BLOCK_STREAMINFO | This is the mandatory STREAMINFO metadata block that has the basic properties of the stream. |
METADATA_BLOCK* | Zero or more metadata blocks |
FRAME+ | One or more audio frames |
Data | Description |
---|---|
METADATA_BLOCK_HEADER | A block header that specifies the type and size of the metadata block data. |
METADATA_BLOCK_DATA |
Data | Description |
---|---|
u(1) | Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise. |
u(7) | BLOCK_TYPE |
u(24) | Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER) |
Value | Description |
---|---|
0 | STREAMINFO |
1 | PADDING |
2 | APPLICATION |
3 | SEEKTABLE |
4 | VORBIS_COMMENT |
5 | CUESHEET |
6 | PICTURE |
7 - 126 | reserved |
127 | invalid, to avoid confusion with a frame sync code |
Data | Description |
---|---|
METADATA_BLOCK_STREAMINFO || METADATA_BLOCK_PADDING || METADATA_BLOCK_APPLICATION || METADATA_BLOCK_SEEKTABLE || METADATA_BLOCK_VORBIS_COMMENT || METADATA_BLOCK_CUESHEET || METADATA_BLOCK_PICTURE | The block data MUST match the block type in the block header. |
Data | Description |
---|---|
u(16) | The minimum block size (in samples) used in the stream. |
u(16) | The maximum block size (in samples) used in the stream. (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream. |
u(24) | The minimum frame size (in bytes) used in the stream. A value of 0 signifies that the value is not known. |
u(24) | The maximum frame size (in bytes) used in the stream. A value of 0 signifies that the value is not known. |
u(20) | Sample rate in Hz. Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 655350 Hz. Also, a value of 0 is invalid. |
u(3) | (number of channels)-1. FLAC supports from 1 to 8 channels |
u(5) | (bits per sample)-1. FLAC supports from 4 to 32 bits per sample. Currently the reference encoder and decoders only support up to 24 bits per sample. |
u(36) | Total samples in stream. 'Samples' means inter-channel sample, i.e. one second of 44.1 kHz audio will have 44100 samples regardless of the number of channels. A value of zero here means the number of total samples is unknown. |
u(128) | MD5 signature of the unencoded audio data. This allows the decoder to determine if an error exists in the audio data even when the error does not result in an invalid bitstream. |
Data | Description |
---|---|
u(n) | n '0' bits (n MUST be a multiple of 8) |
Data | Description |
---|---|
u(32) | Registered application ID. (Visit the |
u(n) | Application data (n MUST be a multiple of 8) |
Data | Description |
---|---|
SEEKPOINT+ | One or more seek points. |
Data | Description |
---|---|
u(64) | Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point. |
u(64) | Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header. |
u(16) | Number of samples in the target frame. |
Data | Description |
---|---|
u(n) | Also known as FLAC tags, the contents of a vorbis comment packet as specified |
Data | Description |
---|---|
u(128*8) | Media catalog number, in ASCII printable characters 0x20-0x7E. In general, the media catalog number SHOULD be 0 to 128 bytes long; any unused characters SHOULD be right-padded with NUL characters. For CD-DA, this is a thirteen digit number, followed by 115 NUL bytes. |
u(64) | The number of lead-in samples. This field has meaning only for CD-DA cuesheets; for other uses it SHOULD be 0. For CD-DA, the lead-in is the TRACK 00 area where the table of contents is stored; more precisely, it is the number of samples from the first sample of the media to the first sample of the first index point of the first track. According to the Red Book, the lead-in MUST be silence and CD grabbing software does not usually store it; additionally, the lead-in MUST be at least two seconds but MAY be longer. For these reasons the lead-in length is stored here so that the absolute position of the first track can be computed. Note that the lead-in stored here is the number of samples up to the first index point of the first track, not necessarily to INDEX 01 of the first track; even the first track MAY have INDEX 00 data. |
u(1) | 1 if the CUESHEET corresponds to a Compact Disc, else 0. |
u(7+258*8) | Reserved. All bits MUST be set to zero. |
u(8) | The number of tracks. Must be at least 1 (because of the requisite lead-out track). For CD-DA, this number MUST be no more than 100 (99 regular tracks and one lead-out track). |
CUESHEET_TRACK+ | One or more tracks. A CUESHEET block is REQUIRED to have a lead-out track; it is always the last track in the CUESHEET. For CD-DA, the lead-out track number MUST be 170 as specified by the Red Book, otherwise it MUST be 255. |
Data | Description |
---|---|
u(64) | Track offset in samples, relative to the beginning of the FLAC audio stream. It is the offset to the first index point of the track. (Note how this differs from CD-DA, where the track's offset in the TOC is that of the track's INDEX 01 even if there is an INDEX 00.) For CD-DA, the offset MUST be evenly divisible by 588 samples (588 samples = 44100 samples/s * 1/75 s). |
u(8) | Track number. A track number of 0 is not allowed to avoid conflicting with the CD-DA spec, which reserves this for the lead-in. For CD-DA the number MUST be 1-99, or 170 for the lead-out; for non-CD-DA, the track number MUST for 255 for the lead-out. It is not REQUIRED but encouraged to start with track 1 and increase sequentially. Track numbers MUST be unique within a CUESHEET. |
u(12*8) | Track ISRC. This is a 12-digit alphanumeric code; see |
u(1) | The track type: 0 for audio, 1 for non-audio. This corresponds to the CD-DA Q-channel control bit 3. |
u(1) | The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. This corresponds to the CD-DA Q-channel control bit 5; see |
u(6+13*8) | Reserved. All bits MUST be set to zero. |
u(8) | The number of track index points. There MUST be at least one index in every track in a CUESHEET except for the lead-out track, which MUST have zero. For CD-DA, this number SHOULD NOT be more than 100. |
CUESHEET_TRACK_INDEX+ | For all tracks except the lead-out track, one or more track index points. |
Data | Description |
---|---|
u(64) | Offset in samples, relative to the track offset, of the index point. For CD-DA, the offset MUST be evenly divisible by 588 samples (588 samples = 44100 samples/s * 1/75 s). Note that the offset is from the beginning of the track, not the beginning of the audio data. |
u(8) | The index point number. For CD-DA, an index number of 0 corresponds to the track pre-gap. The first index in a track MUST have a number of 0 or 1, and subsequently, index numbers MUST increase by 1. Index numbers MUST be unique within a track. |
u(3*8) | Reserved. All bits MUST be set to zero. |
Data | Description |
---|---|
u(32) | The PICTURE_TYPE according to the ID3v2 APIC frame. |
u(32) | The length of the MIME type string in bytes. |
u(n*8) | The MIME type string, in printable ASCII characters 0x20-0x7E. The MIME type MAY also be --> to signify that the data part is a URL of the picture instead of the picture data itself. |
u(32) | The length of the description string in bytes. |
u(n*8) | The description of the picture, in UTF-8. |
u(32) | The width of the picture in pixels. |
u(32) | The height of the picture in pixels. |
u(32) | The color depth of the picture in bits-per-pixel. |
u(32) | For indexed-color pictures (e.g. GIF), the number of colors used, or 0 for non-indexed pictures. |
u(32) | The length of the picture data in bytes. |
u(n*8) | The binary picture data. |
Value | Description |
---|---|
0 | Other |
1 | 32x32 pixels 'file icon' (PNG only) |
2 | Other file icon |
3 | Cover (front) |
4 | Cover (back) |
5 | Leaflet page |
6 | Media (e.g. label side of CD) |
7 | Lead artist/lead performer/soloist |
8 | Artist/performer |
9 | Conductor |
10 | Band/Orchestra |
11 | Composer |
12 | Lyricist/text writer |
13 | Recording Location |
14 | During recording |
15 | During performance |
16 | Movie/video screen capture |
17 | A bright colored fish |
18 | Illustration |
19 | Band/artist logotype |
20 | Publisher/Studio logotype |
Data | Description |
---|---|
FRAME_HEADER | |
SUBFRAME+ | One SUBFRAME per channel. |
u(?) | Zero-padding to byte alignment. |
FRAME_FOOTER |
Data | Description |
---|---|
u(14) | Sync code '0b11111111111110' |
u(1) | FRAME HEADER RESERVED |
u(1) | BLOCKING STRATEGY |
u(4) | INTERCHANNEL SAMPLE BLOCK SIZE |
u(4) | SAMPLE RATE |
u(4) | CHANNEL ASSIGNMENT |
u(3) | SAMPLE SIZE |
u(1) | FRAME HEADER RESERVED2 |
u(?) | CODED NUMBER |
u(?) | BLOCK SIZE INT |
u(?) | SAMPLE RATE INT |
u(8) | FRAME CRC |
Value | Description |
---|---|
0 | mandatory value |
1 | reserved for future use |
Value | Description |
---|---|
0 | fixed-blocksize stream; frame header encodes the frame number |
1 | variable-blocksize stream; frame header encodes the sample number |
Value | Description |
---|---|
0b0000 | reserved |
0b0001 | 192 samples |
0b0010 - 0b0101 | 576 * (2^(n-2)) samples, i.e. 576, 1152, 2304 or 4608 |
0b0110 | get 8 bit (blocksize-1) from end of header |
0b0111 | get 16 bit (blocksize-1) from end of header |
0b1000 - 0b1111 | 256 * (2^(n-8)) samples, i.e. 256, 512, 1024, 2048, 4096, 8192, 16384 or 32768 |
Value | Description |
---|---|
0b0000 | get from STREAMINFO metadata block |
0b0001 | 88.2 kHz |
0b0010 | 176.4 kHz |
0b0011 | 192 kHz |
0b0100 | 8 kHz |
0b0101 | 16 kHz |
0b0110 | 22.05 kHz |
0b0111 | 24 kHz |
0b1000 | 32 kHz |
0b1001 | 44.1 kHz |
0b1010 | 48 kHz |
0b1011 | 96 kHz |
0b1100 | get 8 bit sample rate (in kHz) from end of header |
0b1101 | get 16 bit sample rate (in Hz) from end of header |
0b1110 | get 16 bit sample rate (in daHz) from end of header |
0b1111 | invalid, to prevent sync-fooling string of 1s |
Value | Description |
---|---|
0b0000 | 1 channel: mono |
0b0001 | 2 channels: left, right |
0b0010 | 3 channels: left, right, center |
0b0011 | 4 channels: front left, front right, back left, back right |
0b0100 | 5 channels: front left, front right, front center, back/surround left, back/surround right |
0b0101 | 6 channels: front left, front right, front center, LFE, back/surround left, back/surround right |
0b0110 | 7 channels: front left, front right, front center, LFE, back center, side left, side right |
0b0111 | 8 channels: front left, front right, front center, LFE, back left, back right, side left, side right |
0b1000 | left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel |
0b1001 | right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel |
0b1010 | mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel |
0b1011 - 0b1111 | reserved |
Value | Description |
---|---|
0b000 | get from STREAMINFO metadata block |
0b001 | 8 bits per sample |
0b010 | 12 bits per sample |
0b011 | reserved |
0b100 | 16 bits per sample |
0b101 | 20 bits per sample |
0b110 | 24 bits per sample |
0b111 | reserved |
Value | Description |
---|---|
0 | mandatory value |
1 | reserved for future use |
Data | Description |
---|---|
u(16) | CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with 0) of everything before the CRC, back to and including the frame header sync code |
Data | Description |
---|---|
SUBFRAME_HEADER | |
SUBFRAME_CONSTANT || SUBFRAME_FIXED || SUBFRAME_LPC || SUBFRAME_VERBATIM | The SUBFRAME_HEADER specifies which one. |
Data | Description |
---|---|
u(1) | Zero bit padding, to prevent sync-fooling string of 1s |
u(6) | SUBFRAME TYPE (see |
u(1+k) | WASTED BITS PER SAMPLE FLAG (see |
Value | Description |
---|---|
0b000000 | SUBFRAME_CONSTANT |
0b000001 | SUBFRAME_VERBATIM |
0b00001x | reserved |
0b0001xx | reserved |
0b001xxx | if(xxx <= 4) SUBFRAME_FIXED, xxx=order; else reserved |
0b01xxxx | reserved |
0b1xxxxx | SUBFRAME_LPC, xxxxx=order-1 |
Value | Description |
---|---|
0 | no wasted bits-per-sample in source subblock, k=0 |
1 | k wasted bits-per-sample in source subblock, k-1 follows, unary coded; e.g. k=3 => 0b001 follows, k=7 => 0b0000001 follows. |
Data | Description |
---|---|
u(n) | Unencoded constant value of the subblock, n = frame's bits-per-sample. |
Data | Description |
---|---|
u(n) | Unencoded warm-up samples (n = frame's bits-per-sample * predictor order). |
RESIDUAL | Encoded residual |
Data | Description |
---|---|
u(n) | Unencoded warm-up samples (n = frame's bits-per-sample * lpc order). |
u(4) | (quantized linear predictor coefficients' precision in bits)-1 (NOTE: 0b1111 is invalid). |
u(5) | Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement). |
u(n) | Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement). |
RESIDUAL | Encoded residual |
Data | Description |
---|---|
u(n\*i) | Unencoded subblock, where n is frame's bits-per-sample and i is frame's blocksize. |
Data | Description |
---|---|
u(2) | RESIDUAL_CODING_METHOD |
RESIDUAL_CODING_METHOD_PARTITIONED_EXP_GOLOMB || RESIDUAL_CODING_METHOD_PARTITIONED_EXP_GOLOMB2 |
Value | Description |
---|---|
0b00 | partitioned Exp-Golomb coding with 4-bit Exp-Golomb parameter; RESIDUALCODINGMETHODPARTITIONEDEXP_GOLOMB follows |
0b01 | partitioned Exp-Golomb coding with 5-bit Exp-Golomb parameter; RESIDUALCODINGMETHODPARTITIONEDEXP_GOLOMB2 follows |
0b10 - 0b11 | reserved |
Data | Description |
---|---|
u(4) | Partition order. |
EXP_GOLOMB_PARTITION+ | There will be 2^order partitions. |
Data | Description |
---|---|
u(4(+5)) | EXP-GOLOMB PARTITION ENCODING PARAMETER (see |
u(?) | ENCODED RESIDUAL (see |
Value | Description |
---|---|
0b0000 - 0b1110 | Exp-golomb parameter. |
0b1111 | Escape code, meaning the partition is in unencoded binary form using n bits per sample; n follows as a 5-bit number. |
Data | Description |
---|---|
u(4) | Partition order. |
EXP-GOLOMB2_PARTITION+ | There will be 2^order partitions. |
Data | Description |
---|---|
u(5(+5)) | EXP-GOLOMB2 PARTITION ENCODING PARAMETER (see |
u(?) | ENCODED RESIDUAL (see |
Value | Description |
---|---|
0b00000 - 0b11110 | Exp-golomb parameter. |
0b11111 | Escape code, meaning the partition is in unencoded binary form using n bits per sample; n follows as a 5-bit number. |