edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
| 1 | //! The constant tables Layer III needs besides the Huffman codes: scalefactor |
| 2 | //! band layouts, the pre-emphasis table, and the two lazily built power tables |
| 3 | //! requantisation runs on. |
| 4 | //! |
| 5 | //! The three MPEG-1 long-block layouts here were measured against a reference |
| 6 | //! decoder the same way the Huffman tables were (`scripts/mp3-tables/`, one |
| 7 | //! band attenuated at a time), which is also why they are stated as widths: a |
| 8 | //! width table cannot silently disagree with itself about where 576 ends. |
| 9 | |
| 10 | use ; |
| 11 | |
| 12 | /// Widths of the 22 long scalefactor bands, by sample rate. |
| 13 | pub |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | /// Widths of the 13 short scalefactor bands (per window), by sample rate. |
| 39 | pub |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | /// Start offset of each long band, plus 576 as the last entry. |
| 54 | pub |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | /// Start offset of each short band within one window, plus 192. |
| 66 | pub |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | /// Additional high-frequency scalefactor applied when `preflag` is set. |
| 78 | pub const PRETAB: = |
| 79 | |
| 80 | ; |
| 81 | |
| 82 | /// `slen1`/`slen2` for the MPEG-1 `scalefac_compress` index. |
| 83 | pub const SLEN: = |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | ; |
| 101 | |
| 102 | /// Scalefactor band counts per partition for the MPEG-2 LSF scalefactor |
| 103 | /// scheme, indexed `[block number][0 = long, 1 = short, 2 = mixed]`. |
| 104 | pub const LSF_PARTITIONS: = |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | ; |
| 112 | |
| 113 | /// The largest quantised magnitude Layer III can code (15 plus 13 linbits). |
| 114 | pub const MAX_QUANT: usize = 8206; |
| 115 | |
| 116 | /// `|is|^(4/3)`, the requantisation curve, tabulated once. |
| 117 | pub |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | /// The four Layer III block windows: normal, start, short, stop. |
| 129 | pub |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | /// Alias-reduction butterfly coefficients, `(cs, ca)` for the eight lines each |
| 162 | /// side of a subband boundary. |
| 163 | pub |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | /// The forward MDCT's cosine kernel, `cos(pi/72 · (2n+19)(2k+1))`, laid out |
| 179 | /// `[k][n]` so each of the 18 output coefficients of a long block is one dot |
| 180 | /// product. The encoder recomputed these with libm for every subband of |
| 181 | /// every granule — 23% of its runtime — where the decoder has had its |
| 182 | /// inverse table since it was written. |
| 183 | static FORWARD_MDCT_LONG: = new |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | ; |
| 193 | |
| 194 | /// The forward MDCT kernel for a long block. |
| 195 | pub |
| 196 | |
| 197 | |
| 198 | |
| 199 | /// The short-block kernel, `cos(pi/24 · (2n+7)(2k+1))`, laid out `[k][n]` |
| 200 | /// for one 12-sample window; the three windows share it at 6-sample offsets. |
| 201 | static FORWARD_MDCT_SHORT: = new |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | ; |
| 211 | |
| 212 | /// The forward MDCT kernel for one short window. |
| 213 | pub |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 |