After the three headers, each packet is a block of audio. Decoding a packet reads its mode, recovers a floor curve and a residue spectrum for every channel, multiplies them, and transforms the result into samples. All fields are bit-packed, lowest bits first.
Packet start
| Size | Field | Description |
|---|---|---|
| 1 bit | packet type | 0 for audio; a set bit would be a header |
| ilog(modes − 1) | mode number | the mode used for this block |
| 1 bit each | window flags | on a long block only: the previous and next window flags (0 means that neighbour is short) |
Floor curves
Each channel uses the floor of its submap. Floor 1 starts with a flag:
0 means the channel is unused in this block. Otherwise it reads two amplitudes (each
ilog(range − 1) bits), then partition by partition uses the class books to read
one value per post. The values are predictions from neighbouring posts. Reconstruction
joins the kept posts with straight lines in dB.
Floor 0 reads an amplitude, chooses a book by number, and reads enough vectors to make up the LSP coefficients. The curve is the LSP filter’s response on the Bark scale.
A channel with an unused floor has no residue. A coupled pair is treated as used if either channel in the pair is used.
Residue spectra
Residues are read in eight passes over partitions, using cascaded codebooks by class. A classification word, read through the classbook, gives the class of each partition.
| Type | How the values fall into each partition |
|---|---|
| 0 | one vector spread across the partition, position by position |
| 1 | vectors placed one after another in the partition |
| 2 | like 1, but over one vector interleaving all channels, split back out afterwards |
Reading continues only up to residue_end, and running out of packet ends
the block with zeros for the rest.
Channel coupling
For every coupling step, last to first, the magnitude and angle spectra become two channels again:
| M | A | New M | New A |
|---|---|---|---|
| M > 0 | A > 0 | M | M − A |
| M > 0 | A ≤ 0 | M + A | M |
| M ≤ 0 | A > 0 | M | M + A |
| M ≤ 0 | A ≤ 0 | M − A | M |
Transform and overlap
- Multiply each channel’s residue by its floor curve to give the spectrum.
- Apply the inverse MDCT of the block size, which gives twice as many samples as spectral values.
- Apply the window: a slope of the Vorbis power-complementary sine over the overlap, with a shorter slope next to a short neighbour.
- Overlap-add with the previous block, and output the samples between the centres of the two blocks.
The first block gives no output. Each later block yields a quarter of the previous block plus a quarter of the current block. The last page’s granule position says how many of the final samples to keep.
Links
- Vorbis I specification – the Xiph.Org Foundation’s description of the codec