Lossless Re-Encoding of Vorbis and Opus Audio Files
Organizations: The author is with the Algorithmic Bioinformatics group, Department of Computer Science, and with the Department of Mathematics, Saarland University, Saarbrücken, Germany
Abstract
We present Balrogg, a lossless recompressor that replaces the entropy coding of Ogg Vorbis and Ogg Opus files with adaptive context mixing models. For Vorbis, we write each represent each codebook entry as a tuple of small signed integers (digits), binarized in five stages, and mixed with a direct context model, a bit-history model, and a match model, with weights selected by the neighboring digits and the previous residue pass. For Opus, each symbol is coded by an adaptive context model initialized with the codec's probability tables as priors, and the pyramid vector quantizer (PVQ) indices of the CELT layer are split recursively into pulse counts. At the default level, Balrogg reduces Vorbis music by 16.2%, Vorbis speech by 10.6%, and Opus speech by 5.4%; xz, zstd, ZPAQ, and bzip3 save at most 4.1% on the same files. Over 48 encoder configurations, files shrink to 66.5--96.1% of their size. Encoding and decoding are symmetric, run at 1.8--3.2MB/s per core, and use less than 12MiB of memory.
Figures & tables
| Stage | Context |
|---|---|
| 0, | , , , , [slot unchanged] |
| 1, sign | , , , , sign of , two last signs in |
| 2, | , , , , sign of |
| 3, | , , node of the three-bit tree |
| 4, mantissa | , , , two last mantissa bits |
| Kind (prior) | Context | |||
|---|---|---|---|---|
| Tabulated (table) | 384 | 28 | table, site, previous value at site (clipped to 7) | |
| Coarse energy (Laplace) | 512 | 48 | band, channel, intra flag, frame size; residual of previous frame, previous band, other channel (5 classes each) | |
| Fine energy (uniform) | 1024 | 16 | band, channel, width; previous value; other channel (5 classes) | |
| Band angle (step, triang.) | 192 | 32 | band, pdf, band-size class, resolution; previous-frame angle (8 classes) | |
| Small integer (uniform) | 1024 | 24 | site, alphabet size | |
| Pulse split, Eq. ( 8 ) | 1024 | 16 | band, depth, |
| Balrogg (%) | Baselines (%) | Level 4 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Set | Codec | Files | MB | L1 | L4 | L9 | xz -9e | zstd -19 | Enc. (s) | Dec. (s) | Mem. |
| OpenMIC-2018 | Vorbis | 20 000 | 2595.8 | 86.2 | 83.8 | 83.5 | 97.5 | 97.5 | 68.4 | 71.5 | 6.6 |
| VoxPopuli | Vorbis | 41 | 5178.9 | 89.8 | 89.4 | 89.3 | 98.6 | 98.3 | 120.6 | 129.7 | 11.7 |
| Minecraft (V) | Vorbis | 741 | 29.5 | 83.9 | 80.8 | 80.4 | 96.9 | 96.9 | 2.4 | 2.5 | 8.6 |
| Piano piece (P) | Vorbis | 1 | 2.7 | 83.3 | 79.0 | 78.4 | 97.4 | 97.6 | 1.1 | 1.2 | 5.5 |
| MLS | Opus | 2729 | 182.1 | 94.9 | 94.6 | 94.3 | 99.5 | 98.6 | 3.4 | 3.5 | 4.7 |
| Compressed size (%) | Throughput, enc./dec. (MB/s) | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Set | L1 | L4 | xz -9e | zstd -19 | ZPAQ | bzip3 | L1 | L4 | xz -9e | zstd -19 | ZPAQ | bzip3 |
| OpenMIC-2018 | 86.7 | 84.5 | 97.8 | 97.7 | 97.4 | 97.4 | 4.9/5.0 | 2.3/2.2 | 1.4/15.5 | 6.5/22.9 | 0.22/0.22 | 5.5/5.2 |
| VoxPopuli | 91.2 | 90.8 | 99.9 | 99.7 | 98.6 | 98.6 | 7.1/7.1 | 3.2/2.9 | 2.4/331 | 11.7/3320 | 0.33/0.33 | 5.9/4.9 |
| Set V | 83.9 | 80.8 | 96.9 | 96.9 | 97.8 | 96.6 | 3.3/3.4 | 1.9/1.8 | 1.0/6.4 | 4.1/7.5 | 0.16/0.16 | 3.6/3.5 |
| Set P | 83.3 | 79.0 | 97.4 | 97.6 | 95.9 | 96.2 | 6.0/6.3 | 2.5/2.4 | 4.6/35.8 | 10.7/189 | 0.23/0.24 | 6.6/6.0 |
| MLS | 94.9 | 94.6 | 99.5 | 98.6 | 99.6 | 98.8 | 3.7/3.9 | 2.7/3.0 | 0.9/9.8 | 5.5/12.4 | 0.19/0.19 | 4.5/4.4 |
| Set | L1 | L4 | xz -9e | zstd -19 | ZPAQ | bzip3 |
|---|---|---|---|---|---|---|
| OpenMIC | 2.0/1.9 | 3.5/3.4 | 66/0.2 | 5.6/1.1 | 85/84 | 5.9/5.9 |
| VoxPopuli | 6.5/3.6 | 8.0/5.1 | 673/64 | 713/11 | 976/849 | 1278/1277 |
| Set V | 2.9/2.8 | 4.4/4.3 | 86/2.4 | 56/4.9 | 127/126 | 18/18 |
| Set P | 2.4/2.4 | 4.0/3.9 | 87/2.7 | 56/4.7 | 128/126 | 19/18 |
| MLS | 4.3/4.3 | 4.7/4.7 | 65/0.2 | 2.6/0.5 | 84/84 | 5.6/5.5 |
| Set | Median | IQR | 5–95% | Range |
|---|---|---|---|---|
| OpenMIC-2018 | 84.8 | 81.6–86.8 | 74.7–88.5 | 35.5–92.5 |
| VoxPopuli | 89.9 | 88.7–90.7 | 86.9–90.9 | 86.0–91.0 |
| Minecraft (V) | 78.9 | 74.0–83.3 | 65.8–88.1 | 52.4–92.0 |
| MLS | 94.6 | 94.2–94.8 | 93.8–95.1 | 92.5–95.3 |
| Jobs | Enc. (s) | Dec. (s) | Speedup | Mem. (MiB) | |
|---|---|---|---|---|---|
| Enc. | Dec. | ||||
| 1 | 109.7 | 110.0 | 1.0 | 1.0 | 3.5 |
| 2 | 55.2 | 55.8 | 2.0 | 2.0 | 6.8 |
| 4 | 27.6 | 27.9 | 4.0 | 3.9 | 13.4 |
| 8 | 13.9 | 14.0 | 7.9 | 7.9 | 26.5 |
| 16 | 7.7 | 7.4 | 14.3 | 15.0 | 50.9 |
| Configuration | L1 | L4 | L9 | Med. | xz |
|---|---|---|---|---|---|
| LV | 82.1 | 77.5 | 76.3 | 77.8 | 94.4 |
| LV | 85.5 | 82.2 | 81.4 | 84.1 | 96.1 |
| LV | 84.7 | 82.4 | 81.8 | 83.6 | 96.0 |
| LV | 87.8 | 86.2 | 85.9 | 87.4 | 98.0 |
| LV | 89.1 | 87.7 | 87.4 | 88.8 | 98.4 |
| LV | 91.5 | 90.5 | 90.3 | 91.8 | 99.1 |
| Method | V | OpenMIC | MLS |
| xz -9e , per file | 97.2 | 97.5 | 99.5 |
| zstd -19 , per file | 97.2 | 97.5 | 98.6 |
| xz -9e , solid archive | 92.5 | 95.5 | 99.0 |
| zstd -19 --long=31 , solid archive | 92.5 | 95.6 | 98.1 |
| zstd -19 , trained dictionary | 92.7 | 95.5 | 98.3 |
| Balrogg level 4, per file | 80.7 | 83.8 | 94.6 |
| Set | OptiVorbis | Balrogg | Both |
|---|---|---|---|
| OpenMIC-2018 | 94.5 | 83.8 | 83.5 |
| VoxPopuli | 97.1 | 89.4 | 89.4 |
| Minecraft (V) | 92.7 | 80.8 | 78.7 |
| Piano piece (P) | 96.4 | 79.0 | 79.0 |
| Collection | Files | Acc. | Size | 95% interval | Med. |
| Opus, random sample | |||||
| All files | 1002 | 1000 | 94.1 | 94.0–94.2 | 94.3 |
| FFmpeg | 837 | 837 | 94.1 | 93.9–94.2 | 94.3 |
| libopus | 107 | 107 | 94.6 | 94.0–95.1 | 95.2 |
| 35 | 34 | 91.9 | 91.5–92.4 | 92.5 | |
| Other encoders | 23 | 22 | 91.3 | 88.4–93.8 | 88.5 |