Every frame of MPEG audio starts with this header. It is four bytes, read as a 32-bit big-endian number, and it tells a decoder the coding, the bit rate, the sample rate and the channel layout of the frame, and from those the frame’s length. Bit 31 is the first bit of the first byte.
Fields
| Bits | Width | Field | Meaning |
|---|---|---|---|
| 31–21 | 11 | sync | eleven ones; the sync word that starts a frame |
| 20–19 | 2 | version | 00 MPEG-2.5, 01 reserved, 10 MPEG-2, 11 MPEG-1 |
| 18–17 | 2 | layer | 00 reserved, 01 Layer III, 10 Layer II, 11 Layer I |
| 16 | 1 | protection | 0 means a 16-bit CRC follows the header; 1 means none |
| 15–12 | 4 | bitrate | an index into the bit rate table; 0 is free format, 15 is not allowed |
| 11–10 | 2 | sample rate | an index into the sample rate table; 3 is reserved |
| 9 | 1 | padding | 1 means one extra slot, so the average bit rate comes out right |
| 8 | 1 | private | free for applications; decoders ignore it |
| 7–6 | 2 | mode | 00 stereo, 01 joint stereo, 10 dual channel, 11 single channel |
| 5–4 | 2 | mode extension | used only in joint stereo: see below |
| 3 | 1 | copyright | 1 means the audio is copyrighted |
| 2 | 1 | original | 1 means original media, 0 a copy |
| 1–0 | 2 | emphasis | 00 none, 01 50/15 µs, 10 reserved, 11 CCITT J.17 |
The sync is eleven bits rather than twelve because MPEG-2.5 uses the twelfth bit of the old sync word as part of its version field. MPEG-1 and MPEG-2 files always have the twelfth bit set.
Bit rates
In kilobits a second. Index 0 is free format (the frame length must be found from the next frame); index 15 is not allowed. MPEG-2 LSF means MPEG-2 and MPEG-2.5.
| Index | MPEG-1 Layer I | MPEG-1 Layer II | MPEG-1 Layer III | LSF Layer I | LSF Layers II and III |
|---|---|---|---|---|---|
| 0 | free | free | free | free | free |
| 1 | 32 | 32 | 32 | 32 | 8 |
| 2 | 64 | 48 | 40 | 48 | 16 |
| 3 | 96 | 56 | 48 | 56 | 24 |
| 4 | 128 | 64 | 56 | 64 | 32 |
| 5 | 160 | 80 | 64 | 80 | 40 |
| 6 | 192 | 96 | 80 | 96 | 48 |
| 7 | 224 | 112 | 96 | 112 | 56 |
| 8 | 256 | 128 | 112 | 128 | 64 |
| 9 | 288 | 160 | 128 | 144 | 80 |
| 10 | 320 | 192 | 160 | 160 | 96 |
| 11 | 352 | 224 | 192 | 176 | 112 |
| 12 | 384 | 256 | 224 | 192 | 128 |
| 13 | 416 | 320 | 256 | 224 | 144 |
| 14 | 448 | 384 | 320 | 256 | 160 |
| 15 | not allowed | not allowed | not allowed | not allowed | not allowed |
In MPEG-1 Layer II not every rate may be used with every channel mode. Rates 32, 48, 56 and 80 are for single channel only. Rates 64, 96, 112, 128, 160 and 192 may be used with every mode. Rates 224, 256, 320 and 384 are for stereo, intensity stereo and dual channel, not single channel. Free format may use any mode. The explorer reports a combination outside this list on the frame’s bit rate field, and still reads the frame.
Sample rates
| Index | MPEG-1 | MPEG-2 | MPEG-2.5 |
|---|---|---|---|
| 0 | 44,100 Hz | 22,050 Hz | 11,025 Hz |
| 1 | 48,000 Hz | 24,000 Hz | 12,000 Hz |
| 2 | 32,000 Hz | 16,000 Hz | 8,000 Hz |
| 3 | reserved | ||
Mode extension
Only used when the mode is joint stereo. In Layers I and II it gives the bound: the subband from which channels share samples through intensity stereo.
| Value | Layers I and II | Layer III |
|---|---|---|
00 | intensity from subband 4 | no intensity stereo, MS stereo off |
01 | intensity from subband 8 | intensity stereo on, MS stereo off |
10 | intensity from subband 12 | intensity stereo off, MS stereo on |
11 | intensity from subband 16 | intensity and MS stereo on |
Samples per frame
Each frame holds a fixed number of samples per channel, which gives its duration.
| Layer I | Layer II | Layer III | |
|---|---|---|---|
| MPEG-1 | 384 | 1,152 | 1,152 (two granules of 576) |
| MPEG-2 and 2.5 | 384 | 1,152 | 576 (one granule) |
Frame length
In bytes, rounding down. Bit rate is in bits a second. A slot is one byte for Layers II and III, and four bytes for Layer I. The padding bit adds one slot.
| Layer | Length |
|---|---|
| Layer I | (12 × bit rate / sample rate + padding) × 4 |
| Layer II | 144 × bit rate / sample rate + padding |
| Layer III, MPEG-1 | 144 × bit rate / sample rate + padding |
| Layer III, MPEG-2 and 2.5 | 72 × bit rate / sample rate + padding |
The header counts as part of the frame. A 128 kbps stereo MPEG-1 Layer III frame at 44,100 Hz is 417 bytes, or 418 when padded. A free-format frame (bit rate index 0) has no length in its header: its bit rate is constant and is not one of the listed ones, and a reader measures it by finding the next frame.
CRC
When the protection bit is 0, a 16-bit CRC follows the header. It uses the polynomial
x16 + x15 + x2 + 1 (0x8005), starts at
0xFFFF, and covers bytes 2 and 3 of the header, then:
| Layer | Protected |
|---|---|
| Layer I | the bit allocation |
| Layer II | the bit allocation and the scalefactor selection information (scfsi) |
| Layer III | the side information |
The explorer computes the CRC for each protected frame and reports any that do not match.
An example
The header FF FB 90 64, the commonest there is:
| Field | Bits | Value |
|---|---|---|
| sync | 11111111 111 | eleven ones |
| version | 11 | MPEG-1 |
| layer | 01 | Layer III |
| protection | 1 | no CRC |
| bitrate | 1001 | 128 kbps |
| sample rate | 00 | 44,100 Hz |
| padding | 0 | not padded |
| private | 0 | |
| mode | 01 | joint stereo |
| mode extension | 10 | MS stereo on |
| copyright, original | 0, 1 | not copyrighted, original |
| emphasis | 00 | none |