Lossless Re-Encoding of Vorbis and Opus Audio Files
Authors: Kamila Szewczyk
Organizations: The author is with the Algorithmic Bioinformatics group, Department of Computer Science, and with the Department of Mathematics, Saarland University, Saarbrücken, Germany
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, v=0
⌊c/4⌋ , h , f , [m=0] , [slot unchanged]
1, sign
λ(c) , h , f , [m=0] , sign of m , two last signs in h
2, ∣v∣=1
λ(c) , h , g , [m=0] , sign of v
3, ℓ
h , g , node of the three-bit tree
4, mantissa
h , g , ℓ , two last mantissa bits
TABLE I: Contexts of the direct models of a residue digit. c : position, λ(c) : bit length of c , h : channel (clipped to 3), m : memory, g : magnitude class of the latest digit of the first channel, f=[g=0] , [slot unchanged]: the previously coded digit used the same slot.
Kind (prior)
S
δ
H
Context
Tabulated (table)
384
28
214
table, site, previous value at site (clipped to 7)
Coarse energy (Laplace)
512
48
214
band, channel, intra flag, frame size; residual of previous frame, previous band, other channel (5 classes each)
Fine energy (uniform)
1024
16
214
band, channel, width; previous value; other channel (5 classes)
TABLE II: Opus multisymbol models: prior, scale S , increment δ , rescaling threshold H , and context.
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
TABLE III: Compressed size (%) of complete sets at levels 1, 4, and 9, and of xz and zstd applied to each file. Times are wall-clock seconds for the whole set at level 4 with 32 processes. Memory is the largest per-process peak in MiB at any level.
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
TABLE IV: Single-process comparison on identical files (OpenMIC-2018: first 1000 files; VoxPopuli: first two recordings): compressed size (%) and throughput (MB/s), encoding/decoding.
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
TABLE V: Per-process memory in MiB, encoding/decoding, on the files of Table IV : largest peak over the files of a set.
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
TABLE VI: Per-file compressed size at level 4 (%): median, interquartile range, 5th to 95th percentile, and range.
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
TABLE VII: 2000 files of OpenMIC-2018 (254.5 MB) at level 4: wall-clock time, speedup, and largest sum of the private memory of all running processes. Means of three runs (coefficient of variation at most 0.25%).
Configuration
L1
L4
L9
Med.
xz
LV q=0
82.1
77.5
76.3
77.8
94.4
LV q=2
85.5
82.2
81.4
84.1
96.1
LV q=4
84.7
82.4
81.8
83.6
96.0
LV q=6
87.8
86.2
85.9
87.4
98.0
LV q=8
89.1
87.7
87.4
88.8
98.4
LV q=10
91.5
90.5
90.3
91.8
99.1
TABLE VIII: EBU SQAM, 70 tracks per configuration: compressed size (%) at levels 1, 4, and 9, per-file median at level 4, and xz -9e per file; for Opus, reduction (%) of the entropy-coded payload at level 4. LV: libvorbis 1.3.7 (quality q ); FF: FFmpeg 7.1 (quality q for Vorbis, kb/s for Opus); LO: libopus 1.5.2 and LO ′ : libopus 1.3.1 (kb/s; stereo, 20 ms frames, and automatic mode unless stated).
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
TABLE IX: Baselines that use redundancy between files: compressed size (%) of whole sets. Set V is restricted to its 449 distinct files.
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
TABLE X: Compressed size (%): OptiVorbis, Balrogg at level 4, and Balrogg at level 4 applied to the output of OptiVorbis.
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
WhatsApp
35
34
91.9
91.5–92.4
92.5
Other encoders
23
22
91.3
88.4–93.8
88.5
TABLE XI: Internet Archive files at level 4: files examined and accepted, compressed size of the accepted files (%) with a 95% bootstrap interval over files, and per-file median.