edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiBe08e2e6Tahinli2 months ago2649 commits
| 1 | #!/usr/bin/env python3 |
| 2 | """Derive the normative AAC-LC tables by black-box probing of a reference decoder. |
| 3 | |
| 4 | Clean room: no AAC implementation source is read. The only oracle is ffmpeg's |
| 5 | `aac` decoder, driven as a black box. Synthetic access units carry a spectral |
| 6 | payload we choose; decoding them and inverting the MDCT recovers the quantised |
| 7 | values, and a binary-tree walk over bit prefixes enumerates each codebook. |
| 8 | |
| 9 | A bit string `b` is a complete codeword exactly when the first decoded tuple does |
| 10 | not change if a `0` is appended -- prefix codes are injective, and the filler |
| 11 | after the codeword is identical in both probes. That makes the walk about `2M` |
| 12 | probes for `M` codewords, and every codebook it produces is checked against a |
| 13 | Kraft sum of exactly 1 and the entry count ISO/IEC 14496-3 prescribes, which is |
| 14 | what makes the derivation self-checking. |
| 15 | |
| 16 | The band tables come out the same way: with `max_sfb = k` the highest non-zero |
| 17 | coefficient is `swb_offset[k] - 1`, and the TNS band limits show up as the |
| 18 | `max_sfb` at which a filter stops being applied. |
| 19 | |
| 20 | Usage: python3 scripts/derive-aac-tables.py [work-dir] |
| 21 | Writes cb1..cb11.json, sfb.json, swb.json and swb_short.json into the work |
| 22 | directory, then regenerates crates/ec-aac/src/tables.rs. Needs numpy and ffmpeg. |
| 23 | """ |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | = |
| 31 | = |
| 32 | = |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | = |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | = |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 |