Skip to main content

Module quantization

Module quantization 

Source
Expand description

Quantization and rate control for MP3 encoding

This module implements the quantization loop that controls the trade-off between audio quality and bitrate by adjusting quantization step sizes and managing the bit reservoir.

The implementation strictly follows the shine reference implementation in ref/shine/src/lib/l3loop.c

Functions§

bigv_tab_select
Select Huffman code tables for bigvalues regions Corresponds to bigv_tab_select() in l3loop.c
calc_runlen
Calculate run length encoding information Corresponds to calc_runlen() in l3loop.c
count1_bitcount
Count bits for count1 region Corresponds to count1_bitcount() in l3loop.c
count_bit
Count the number of bits necessary to code the subregion Corresponds to count_bit() in l3loop.c
ix_max
Calculate maximum value in range
labs
Absolute value function (matches shine labs)
mulr
Multiply with rounding and 32-bit right shift (matches shine mulr)
mulsr
Multiplication macros matching shine’s mult_noarch_gcc.h These implement fixed-point arithmetic operations
part2_length
Calculate part2 length (scalefactors) Corresponds to part2_length() in l3loop.c
quantize
Quantize MDCT coefficients Corresponds to quantize() in l3loop.c
quantize_with_l3loop
Helper function to avoid borrowing conflicts
shine_inner_loop
Inner loop: find optimal quantization step size for given scalefactors Corresponds to shine_inner_loop() in l3loop.c
shine_iteration_loop
Main iteration loop for encoding Corresponds to shine_iteration_loop() in l3loop.c
shine_loop_initialise
Initialize quantization loop tables Corresponds to shine_loop_initialise() in l3loop.c
shine_outer_loop
Outer loop: controls masking conditions and computes best scalefac and global gain Corresponds to shine_outer_loop() in l3loop.c
subdivide
Subdivide big values region into regions for different Huffman tables Corresponds to subdivide() in l3loop.c
subdivide_with_samplerate
Helper function to subdivide without borrowing conflicts