edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiBf969486Tahinli2 months ago2189 commits
| 1 | """The linear map (requantised spectrum -> PCM) for one probe frame, and its |
| 2 | pseudo-inverse: what turns an ffmpeg decode back into the integers a probe's |
| 3 | Huffman bits decoded to.""" |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | = 72 # probe frame (36 slots) + trailing silent frame |
| 10 | = * 32 |
| 11 | |
| 12 | |
| 13 | |
| 14 | = 36 |
| 15 | return |
| 16 | * |
| 17 | |
| 18 | |
| 19 | |
| 20 | = |
| 21 | |
| 22 | |
| 23 | , = * 18 - 1 - , * 18 + |
| 24 | , = , |
| 25 | = * - * |
| 26 | = * + * |
| 27 | return |
| 28 | |
| 29 | |
| 30 | |
| 31 | """(2 granules x 576) -> (72 slots x 32 subbands), flattened columns.""" |
| 32 | = |
| 33 | = |
| 34 | = |
| 35 | |
| 36 | |
| 37 | |
| 38 | = |
| 39 | |
| 40 | = 18 * + |
| 41 | = -1.0 |
| 42 | += * |
| 43 | = 18 * + |
| 44 | = -1.0 |
| 45 | += * |
| 46 | # the alias butterflies mix coefficients before the imdct |
| 47 | += |
| 48 | return |
| 49 | |
| 50 | |
| 51 | |
| 52 | = |
| 53 | |
| 54 | = |
| 55 | |
| 56 | = |
| 57 | |
| 58 | = |
| 59 | = * |
| 60 | |
| 61 | = - |
| 62 | |
| 63 | continue |
| 64 | += |
| 65 | return |
| 66 | |
| 67 | |
| 68 | |
| 69 | = @ |
| 70 | return , |
| 71 | |
| 72 | |
| 73 | |
| 74 | = |
| 75 | , = |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | # self-check: round-trip a random spectrum through the model |
| 81 | = |
| 82 | = * 1e-3 |
| 83 | = @ |
| 84 | = @ |
| 85 |