Bitrate reduction from lossless encoding in MP3 encoded audio files


Csaba Horváth,
tonestack.net


June 20, 2025

Lossy audio compression is a result of lossy compression (quantization) and lossless compression (transform gain, Huffman coding, differential encoding, etc.). The efficiency of a lossy audio format depends largely on the efficiency of the lossless encoding stages. Furthermore, the efficiency of lossless encoding can be measured by disabling all quantization except rounding.

The ratio of lossy and lossless compression varies from signal to signal. For signals with low harmonic content (four tone multitone, triangle) bitrate reduction is mainly the result of lossless encoding. On the contrary, for signals with high harmonic content bitrate reduction is largely derived from quantization. Although the efficiency of lossless compression is low for signals with many harmonics, the greatly increased masking threshold can hide a large amount of quantization noise.

The ratio of lossy and lossless compression also varies with signal level: the contribution of lossless compression to the entire compression is greater at low signal levels. In fact, perceptual coding is secondary at very low signal levels. (Lossless encoding of low-level signals requires very few bits, mainly because low-level signals don't use all the bits in a 16-bit WAV file, so unused bits can be simply discarded.)

PCM⟶
MDCT transform
Quantizer
Huffman-coding
⟶bitstream

There are two lossless stages in MP3 encoding: MDCT transformation (with subbands) and Huffman-coding. Although MDCT transformation is lossless, the implementation in MP3 (and other lossy encoders) is not completely lossless, since MDCT uses non-integer arithmetic, whereas the input for Huffman-coding are integers. At least a rounding has to be performed before Huffman-coding of frequency values. Fortunately, quantization can be configured to produce a fixed 16-bit noise floor. The nonlinear quantizer (x0.75) can be either included or excluded from the encoding process.


1. The modified encoder

Description of the encoder used for generating the tables:

Encoder noise floor, linear vs. nonlinear quantizer

Since lossless encoding of low-level signals requires very few bits and perceptual coding is secondary at low signal levels (ATH is important, masking is not) we can ignore the analysis of low-level signals and focus on high-level signals. By ignoring low-level signals, we can weaken the requirements of the analysis.

Two types of quantizer setting were tested, which has a minor effect on the noise floor.

When power law quantization is enabled and global gain is 210 (slightly nonlinear quantizer), the encoder noise floor for high level signals is equivalent with a noise floor of a 14 bit system. The dynamic range is equivalent with the dynamic range of a 16-bit system. Not lossless compression but way beyond transparency.

Quantization for this setting:

ix(i) = int ( |xr(i)|0.75 - 0.0946 ),

where ix(i) is integer, xr(i) is float or double.

When power law quantization is disabled and global gain is 210 (linear quantizer), the encoder noise floor is equivalent to a noise floor of a 16-bit system. The actual signal-to-noise ratio and dynamic range depend on how dither is applied at the output and input. In our case dynamic range and SNR are not so important, as we are mainly interested in signal compression above -48 dBFS. (Note: the dynamic range of an MP3 file can be much larger, as the global gain varies from block to block in a real encoder.)

Quantization for this setting:

ix(i) = int ( |xr(i)| )

In this case, quantization is rounding a floating point frequency value to the nearest integer.


2. Periodic signals

Power law quantization is enabled (nonlinear quantizer)

Details:

SignalBitrate (kbps)
0 dBFS-6 dBFS-12 dBFS-30 dBFS-48 dBFS
sine, f=100Hz222018116
sine, f=1kHz3632281911
sine, f=10kHz4236342113
Triangle, f=100Hz14511077258
Triangle, f=400Hz22018015070-
Sawtooth, f=100Hz39335230019083
Sawtooth, f=200Hz41037032020095
Sawtooth, f=400Hz440400350210110
100Hz+1k+5k+15k1751601408540
Multitone315-240160-

Notes:

Power law quantization is disabled (rounding only)

Details:

SignalBitrate (kbps)
0 dBFS-6 dBFS-12 dBFS-30 dBFS-48 dBFS
sine, f=1kHzno table40---
sine, f=10kHzno table40---
Triangle, f=100Hzno tableno table80--
Triangle, f=400Hzno tableno table160--
Sawtooth, f=200Hzno tableno table410--
Sawtooth, f=400Hzno tableno table430-100
Multitone41035032018075


3. Bitrates for pulse signals

Two extremes should be analyzed:

In the following simulations bitrates are average of two granulas. Global gain is set to 210, quantizer is 1.

For the empty granula (best case) 50 kbps for background noise is allocated. (Granula: one long block or three short blocks.)

Short windows

QuantizerSignalBitrate (kbps)
0 dBFS-6 dBFS-12 dBFS-30 dBFS
Non-linearPulse best case170150120-
Pulse worst case250235200-
RoundingPulse best case215190160-
Pulse worst case290270240-

Long windows

QuantizerSignalBitrate (kbps)
0 dBFS-6 dBFS-12 dBFS-30 dBFS
Non-linearPulse best case18015012052
Pulse worst case310270230120
RoundingPulse best case22518013060
Pulse worst case390310260130

4. Start of periodic signals

Signal level is 0 dBFS, power law quantization is enabled. Start is at the meeting point of two granulas (worst case). Short blocks.

SignalGranules (bitrates, kbps)
#0#1#2#3
Sine, f = 10 kHz2802803030
Triangle, f = 400 Hz262322250254
Multitone254354291294

5. Contribution of lossless coding and perceptual coding to bitrate reduction

The chart shows the bitrates after lossless compression (rounding is the only quantization) and lossy compression with a non-modified MP3 encoder (standard perceptual coding). The bitrate for the lossy compression is set for "transparent" quality (errors are not audible).


705.6
 
352.8
 
0

Triangle (400 Hz)Sawtooth (400 Hz)

Blue: lossless compression, red: lossy compression,
signal level is -12 dBFS; results are in kbps

The difference between lossless and lossy compression is the bitrate reduction from perceptual coding.

Unfortunately, this method has a minor flaw: Huffman-code tables are optimized for encoding quantized values less than or equal to 4 bits, or for bitstreams where values greater than 4 bits are rare (4 bit is meant without sign). When quantization is disabled, Huffman-coding becomes inefficient at high signal levels. It's likely that the compression resulting from lossless stages in standard MP3 files is somewhat greater than the previous graph suggests.