forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB63370ceTahinli2 months ago2053 commits

run.sh30 lines, 1.5 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# Regenerates ec-mp3's measured constant tables.
3#
4# Layer III's Huffman codes and its 512-tap polyphase window are normative data
5# that no formula produces. Rather than copy them out of an existing
6# implementation, these scripts measure them: they write legal Layer III frames
7# whose main-data bits they choose, decode them with ffmpeg, and read the answer
8# back through a model of the decode chain.
9#
10# learn_window.py least-squares fits the 512 window taps to the PCM ffmpeg
11# returns for spectra we chose (residual 1.6e-6, the f32
12# noise floor of the decoder being measured)
13# mp3op.py builds the spectrum -> PCM operator and its pseudo-inverse
14# learn_huffman.py walks every code tree: a bit prefix is a codeword exactly
15# when all continuations decode to the same pair. Checks a
16# Kraft sum of 1, full coverage and uniqueness per table
17# learn_sfb.py MPEG-1 long scalefactor band widths, one band attenuated
18# at a time (these agreed with the published layouts)
19# lsf_probe.py short-block reorder at the low sampling frequencies
20# emit_tables.py writes huffman_tables.rs
21#
22# Needs ffmpeg, python3 and numpy. Output lands beside the scripts; copy
23# huffman_tables.rs and window.rs into crates/ec-mp3/src/.
24set -euo pipefail
25cd "$(dirname "${BASH_SOURCE[0]}")"
26python3 learn_window.py
27python3 mp3op.py
28python3 learn_huffman.py
29python3 learn_sfb.py
30python3 emit_tables.py