Layers I and II are the simpler MPEG audio layers. They have no Huffman coding and no bit reservoir: each frame is self-contained, holding 32 subbands of samples, an allocation that says how many bits each subband uses, and scalefactors that restore its level. The frame header and everything before the audio data are the same as for Layer III; see the frame header.
Layer I
A frame holds 384 samples per channel: 12 consecutive samples of each of 32 subbands. After the header and any CRC come, in order:
- Allocation: 4 bits for each subband and channel, giving the bits per sample as the value plus one. 0 means the subband is silent; 15 is not allowed. From the bound up, in joint stereo, one allocation serves both channels.
- Scalefactors: 6 bits for each subband and channel that has anything allocated.
- Samples: for each of 12 time slots, for each subband, for each channel, one code of the allocated width. Above the bound, one code serves both channels, each scaled by its own scalefactor.
Layer II
A frame holds 1152 samples per channel: 36 consecutive samples of each subband, arranged as 12 groups of three, and shares its scalefactors across three parts of 12 samples each. After the header and any CRC:
- Bit allocation: one field per subband and channel, of a width set by the allocation table; above the bound, one field for both channels.
- Scalefactor selection (scfsi): 2 bits per subband and channel with an allocation.
- Scalefactors: for each subband with an allocation, one to three 6-bit values, as the scfsi says.
- Samples: 12 groups; in each, for each subband, for each channel, three samples, as a single grouped code or three separate codes.
| scfsi | Scalefactors stored | Applied to parts 1, 2, 3 |
|---|---|---|
| 0 | three | first, second, third |
| 1 | two | first, first, second |
| 2 | one | first, first, first |
| 3 | two | first, second, second |
Layer II allocation tables
Which subbands exist and how they may be coded depends on the sample rate and the bit rate per channel. Four tables serve MPEG-1 (ISO/IEC 11172-3, tables B.2a to B.2d); MPEG-2’s lower rates use their own (13818-3). For each subband, the table gives the allocation field’s width, then the quantisation classes the values 1, 2, … select.
| Table | Used when | Subbands |
|---|---|---|
| a (B.2a) | sample rate is 48 kHz and bit rate per channel at least 56, or per channel 56 to 80 | 0–26 |
| b (B.2b) | sample rate is not 48 kHz and bit rate per channel at least 96 | 0–29 |
| c (B.2c) | sample rate is not 32 kHz and bit rate per channel at most 48 | 0–7 |
| d (B.2d) | otherwise | 0–11 |
| LSF (13818-3) | MPEG-2 and 2.5 | 0–29 |
Rows of allocation-field width and classes (allocation value 0 is silent):
| Tables | Subbands | Width | Classes (levels) for allocation 1, 2, 3 … |
|---|---|---|---|
| a, b | 0–2 | 4 | 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535 |
| a, b | 3–10 | 4 | 3, 5, 7, 9, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 65535 |
| a, b | 11–22 | 3 | 3, 5, 7, 9, 15, 31, 65535 |
| a, b | 23–29 | 2 | 3, 5, 65535 |
| c, d | 0–1 | 4 | 3, 5, 9, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767 |
| c, d | 2–11 | 3 | 3, 5, 9, 15, 31, 63, 127 |
| LSF | 0–3 | 4 | 3, 5, 7, 9, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383 |
| LSF | 4–10 | 3 | 3, 5, 9, 15, 31, 63, 127 |
| LSF | 11–29 | 2 | 3, 5, 9 |
Samples
Every level count is 3, 5, 9, or 2n − 1. A value v from 0 to levels − 1 is a sample s = (2v + 1 − levels) / levels, in the range −1 to 1, then multiplied by the scalefactor.
| Levels | Bits a sample | Coding |
|---|---|---|
| 3 | 5, for three samples together | grouped: v₀ + 3 v₁ + 9 v₂ in 5 bits |
| 5 | 7, for three together | grouped: v₀ + 5 v₁ + 25 v₂ in 7 bits |
| 7 | 3 each | one code a sample |
| 9 | 10, for three together | grouped: v₀ + 9 v₁ + 81 v₂ in 10 bits |
| 15, 31, … 65535 | log₂(levels + 1) each | one code a sample |
In Layer I every subband uses a level count of 2n − 1 with n from the allocation; there is no grouping.
Scalefactors
A 6-bit index selects a multiplier: 2 × 2−index / 3, so 0 is 2.0, 1 is about 1.587, 2 about 1.26, and each three steps halves the value. Index 63 is not used.
Intensity stereo
In joint stereo, subbands from the bound up ( the mode extension sets it to 4, 8, 12 or 16) share one allocation and one set of samples between the two channels; each channel has its own scalefactors, which set its share of the signal.
Synthesis
The decoded subband samples go through the polyphase synthesis filterbank, 32 samples at a time: a 32-point DCT feeding a 1024-sample buffer, windowed by the standard’s 512 coefficients D[0..511], which produces the time samples. Layer III ends with the same filterbank.
Ancillary data
Any bits after the samples are ancillary data, ignored by a decoder. MPEG-2’s backwards-compatible multichannel audio (13818-3 part 4) hides its extra channels there, so that an MPEG-1 decoder plays the stereo; the explorer does not decode them.