A Layer II frame is self-contained. After the header and any CRC come a bit allocation, scale factor selection, scale factors and 1,152 samples per channel. The samples are 36 consecutive values of each of up to 32 subbands, stored as 12 groups of three. In what follows, the bound is 32 outside joint stereo; in joint stereo it is the subband given by the mode extension, as explained under the bound. The number of subbands in use comes from the allocation table.
Bit allocation
One field per subband and channel, as wide as the allocation table says for that subband, 2 to 4 bits. A value of 0 means the subband is silent in that channel. Up to the bound, each channel has its own field. From the bound upwards, one field serves both channels.
Scale factor selection
For each subband and channel with a nonzero allocation, 2 bits of scfsi say
how many scale factors are stored for the 36 samples, which are divided into three
parts of 12.
| scfsi | Scale factors 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 |
Scale factors
Each stored scale factor is a 6-bit index for that subband and channel. An index i of 0 to 62 means a scale of 2 × 2−i/3, from 2.0 down to about 0.0000012; 63 is not used. Above the bound, the two channels still have separate scale factors even though they share samples.
| Index | Scale | Index | Scale |
|---|---|---|---|
| 0 | 2.00000000 | 3 | 1.00000000 |
| 1 | 1.58740105 | 4 | 0.79370053 |
| 2 | 1.25992105 | 5 | 0.62996052 |
Each three indices halve the scale, so the rest of the table follows. Index 62 is 2 × 2−62/3.
Samples
There are 12 groups. In each group, for each subband (up to the limit), for each channel (only one above the bound): three consecutive samples, as one grouped code or three separate codes.
| Levels | Bits per sample | Coding |
|---|---|---|
| 3 | 5 for three | grouped: v₀ + 3 v₁ + 9 v₂ in 5 bits |
| 5 | 7 for three | grouped: v₀ + 5 v₁ + 25 v₂ in 7 bits |
| 7 | 3 each | one code a sample |
| 9 | 10 for three | grouped: v₀ + 9 v₁ + 81 v₂ in 10 bits |
| 15 | 4 each | one code a sample |
| 31 | 5 each | one code a sample |
| 63 | 6 each | one code a sample |
| 127 | 7 each | one code a sample |
| 255 | 8 each | one code a sample |
| 511 | 9 each | one code a sample |
| 1,023 | 10 each | one code a sample |
| 2,047 | 11 each | one code a sample |
| 4,095 | 12 each | one code a sample |
| 8,191 | 13 each | one code a sample |
| 16,383 | 14 each | one code a sample |
| 32,767 | 15 each | one code a sample |
| 65,535 | 16 each | one code a sample |
A code value v gives a sample (2v + 1 − levels) / levels, between −1 and 1, then multiplied by the scale factor. Each group’s three samples form part of the 36 samples of the subband, and the samples of the 32 subbands are recombined by the synthesis filter bank to give the 1,152 output samples.
Ancillary data
Any bits left in the frame after the samples are ancillary data, with no structure defined here. The multichannel extension uses this space, as do some broadcast formats, for example programme-associated data in DAB, whose layout is not covered here.