Close the eight envelope SBR Huffman codebook values
Browse files at this commit86f03f95659fe299a5ea5d59ce079d94c0019ac8Parent: c53ad6b- feat
- close the eight envelope SBR Huffman codebook values
2 changed files +617 -8
crates/ec-aac/src/sbr_tables.rsmodified+595 -1
| @@ -9,7 +9,389 @@ | |||
| 9 | //! a Kraft sum of exactly 1 (asserted below). | 9 | //! a Kraft sum of exactly 1 (asserted below). |
| 10 | #![allow(dead_code)] | 10 | #![allow(dead_code)] |
| 11 | 11 | ||
| 12 | -// Not emitted (values incomplete or book did not close): ['ENV15_F', 'ENV15_T', 'ENV30_T', 'ENV30_F', 'ENVB15_F', 'ENVB15_T', 'ENVB30_T', 'ENVB30_F'] | 12 | +/// SBR Huffman book `ENV15_F`: (length, code, delta) by codeword. |
| 13 | +pub(crate) static ENV15_F: [(u8, u32, i32); 121] = [ | ||
| 14 | + (2, 0, 0), | ||
| 15 | + (2, 1, -1), | ||
| 16 | + (3, 4, 1), | ||
| 17 | + (3, 5, -2), | ||
| 18 | + (4, 12, -3), | ||
| 19 | + (4, 13, 2), | ||
| 20 | + (5, 28, -4), | ||
| 21 | + (5, 29, 3), | ||
| 22 | + (6, 60, -5), | ||
| 23 | + (6, 61, 4), | ||
| 24 | + (7, 124, -6), | ||
| 25 | + (8, 250, 5), | ||
| 26 | + (8, 251, -7), | ||
| 27 | + (8, 252, 6), | ||
| 28 | + (9, 506, -8), | ||
| 29 | + (9, 507, 7), | ||
| 30 | + (9, 508, -9), | ||
| 31 | + (10, 1018, 8), | ||
| 32 | + (10, 1019, -10), | ||
| 33 | + (11, 2040, 9), | ||
| 34 | + (11, 2041, -11), | ||
| 35 | + (11, 2042, 10), | ||
| 36 | + (11, 2043, 11), | ||
| 37 | + (12, 4088, -12), | ||
| 38 | + (12, 4089, 12), | ||
| 39 | + (12, 4090, -13), | ||
| 40 | + (12, 4091, 13), | ||
| 41 | + (13, 8184, 14), | ||
| 42 | + (13, 8185, -14), | ||
| 43 | + (13, 8186, -15), | ||
| 44 | + (13, 8187, 15), | ||
| 45 | + (14, 16376, 16), | ||
| 46 | + (14, 16377, 17), | ||
| 47 | + (14, 16378, -16), | ||
| 48 | + (15, 32758, -17), | ||
| 49 | + (15, 32759, -18), | ||
| 50 | + (16, 65520, -19), | ||
| 51 | + (16, 65521, 18), | ||
| 52 | + (16, 65522, 19), | ||
| 53 | + (16, 65523, -20), | ||
| 54 | + (16, 65524, -21), | ||
| 55 | + (17, 131050, 20), | ||
| 56 | + (17, 131051, 21), | ||
| 57 | + (17, 131052, -24), | ||
| 58 | + (17, 131053, -23), | ||
| 59 | + (17, 131054, -22), | ||
| 60 | + (17, 131055, -26), | ||
| 61 | + (18, 262112, -28), | ||
| 62 | + (18, 262113, 22), | ||
| 63 | + (18, 262114, 23), | ||
| 64 | + (18, 262115, 25), | ||
| 65 | + (18, 262116, -41), | ||
| 66 | + (18, 262117, -25), | ||
| 67 | + (18, 262118, 26), | ||
| 68 | + (18, 262119, 27), | ||
| 69 | + (18, 262120, -30), | ||
| 70 | + (18, 262121, -27), | ||
| 71 | + (18, 262122, 24), | ||
| 72 | + (18, 262123, 28), | ||
| 73 | + (18, 262124, 44), | ||
| 74 | + (19, 524250, -51), | ||
| 75 | + (19, 524251, -46), | ||
| 76 | + (19, 524252, -44), | ||
| 77 | + (19, 524253, -43), | ||
| 78 | + (19, 524254, -37), | ||
| 79 | + (19, 524255, -33), | ||
| 80 | + (19, 524256, -31), | ||
| 81 | + (19, 524257, -29), | ||
| 82 | + (19, 524258, 30), | ||
| 83 | + (19, 524259, 37), | ||
| 84 | + (19, 524260, 42), | ||
| 85 | + (19, 524261, 47), | ||
| 86 | + (19, 524262, 48), | ||
| 87 | + (19, 524263, -60), | ||
| 88 | + (19, 524264, -59), | ||
| 89 | + (20, 1048530, -58), | ||
| 90 | + (20, 1048531, -57), | ||
| 91 | + (20, 1048532, -56), | ||
| 92 | + (20, 1048533, -55), | ||
| 93 | + (20, 1048534, -54), | ||
| 94 | + (20, 1048535, -53), | ||
| 95 | + (20, 1048536, -52), | ||
| 96 | + (20, 1048537, -50), | ||
| 97 | + (20, 1048538, -49), | ||
| 98 | + (20, 1048539, -48), | ||
| 99 | + (20, 1048540, -47), | ||
| 100 | + (20, 1048541, -45), | ||
| 101 | + (20, 1048542, -42), | ||
| 102 | + (20, 1048543, -40), | ||
| 103 | + (20, 1048544, -39), | ||
| 104 | + (20, 1048545, -38), | ||
| 105 | + (20, 1048546, -36), | ||
| 106 | + (20, 1048547, -35), | ||
| 107 | + (20, 1048548, -34), | ||
| 108 | + (20, 1048549, -32), | ||
| 109 | + (20, 1048550, 29), | ||
| 110 | + (20, 1048551, 31), | ||
| 111 | + (20, 1048552, 32), | ||
| 112 | + (20, 1048553, 33), | ||
| 113 | + (20, 1048554, 34), | ||
| 114 | + (20, 1048555, 35), | ||
| 115 | + (20, 1048556, 36), | ||
| 116 | + (20, 1048557, 38), | ||
| 117 | + (20, 1048558, 39), | ||
| 118 | + (20, 1048559, 40), | ||
| 119 | + (20, 1048560, 41), | ||
| 120 | + (20, 1048561, 43), | ||
| 121 | + (20, 1048562, 45), | ||
| 122 | + (20, 1048563, 46), | ||
| 123 | + (20, 1048564, 49), | ||
| 124 | + (20, 1048565, 50), | ||
| 125 | + (20, 1048566, 51), | ||
| 126 | + (20, 1048567, 52), | ||
| 127 | + (20, 1048568, 53), | ||
| 128 | + (20, 1048569, 54), | ||
| 129 | + (20, 1048570, 55), | ||
| 130 | + (20, 1048571, 56), | ||
| 131 | + (20, 1048572, 57), | ||
| 132 | + (20, 1048573, 58), | ||
| 133 | + (20, 1048574, 59), | ||
| 134 | + (20, 1048575, 60), | ||
| 135 | +]; | ||
| 136 | + | ||
| 137 | +/// SBR Huffman book `ENV15_T`: (length, code, delta) by codeword. | ||
| 138 | +pub(crate) static ENV15_T: [(u8, u32, i32); 121] = [ | ||
| 139 | + (2, 0, 0), | ||
| 140 | + (2, 1, -1), | ||
| 141 | + (3, 4, 1), | ||
| 142 | + (3, 5, -2), | ||
| 143 | + (4, 12, 2), | ||
| 144 | + (4, 13, -3), | ||
| 145 | + (5, 28, 3), | ||
| 146 | + (5, 29, -4), | ||
| 147 | + (6, 60, 4), | ||
| 148 | + (6, 61, -5), | ||
| 149 | + (7, 124, 5), | ||
| 150 | + (7, 125, -6), | ||
| 151 | + (8, 252, 6), | ||
| 152 | + (8, 253, -7), | ||
| 153 | + (9, 508, 7), | ||
| 154 | + (9, 509, -8), | ||
| 155 | + (10, 1020, -9), | ||
| 156 | + (10, 1021, 8), | ||
| 157 | + (11, 2044, -10), | ||
| 158 | + (12, 4090, 9), | ||
| 159 | + (12, 4091, -11), | ||
| 160 | + (13, 8184, 10), | ||
| 161 | + (13, 8185, -12), | ||
| 162 | + (13, 8186, -13), | ||
| 163 | + (14, 16374, 11), | ||
| 164 | + (14, 16375, -14), | ||
| 165 | + (14, 16376, 12), | ||
| 166 | + (14, 16377, -15), | ||
| 167 | + (15, 32756, -16), | ||
| 168 | + (15, 32757, 13), | ||
| 169 | + (16, 65516, -19), | ||
| 170 | + (16, 65517, -18), | ||
| 171 | + (16, 65518, -17), | ||
| 172 | + (16, 65519, 14), | ||
| 173 | + (16, 65520, -24), | ||
| 174 | + (16, 65521, -20), | ||
| 175 | + (16, 65522, 16), | ||
| 176 | + (17, 131046, -26), | ||
| 177 | + (17, 131047, -21), | ||
| 178 | + (17, 131048, 15), | ||
| 179 | + (17, 131049, -23), | ||
| 180 | + (18, 262100, -25), | ||
| 181 | + (18, 262101, -22), | ||
| 182 | + (18, 262102, -60), | ||
| 183 | + (18, 262103, -59), | ||
| 184 | + (18, 262104, -58), | ||
| 185 | + (18, 262105, -57), | ||
| 186 | + (18, 262106, -56), | ||
| 187 | + (18, 262107, -55), | ||
| 188 | + (19, 524216, -54), | ||
| 189 | + (19, 524217, -53), | ||
| 190 | + (19, 524218, -52), | ||
| 191 | + (19, 524219, -51), | ||
| 192 | + (19, 524220, -50), | ||
| 193 | + (19, 524221, -49), | ||
| 194 | + (19, 524222, -48), | ||
| 195 | + (19, 524223, -47), | ||
| 196 | + (19, 524224, -46), | ||
| 197 | + (19, 524225, -45), | ||
| 198 | + (19, 524226, -44), | ||
| 199 | + (19, 524227, -43), | ||
| 200 | + (19, 524228, -42), | ||
| 201 | + (19, 524229, -41), | ||
| 202 | + (19, 524230, -40), | ||
| 203 | + (19, 524231, -39), | ||
| 204 | + (19, 524232, -38), | ||
| 205 | + (19, 524233, -37), | ||
| 206 | + (19, 524234, -36), | ||
| 207 | + (19, 524235, -35), | ||
| 208 | + (19, 524236, -34), | ||
| 209 | + (19, 524237, -33), | ||
| 210 | + (19, 524238, -32), | ||
| 211 | + (19, 524239, -31), | ||
| 212 | + (19, 524240, -30), | ||
| 213 | + (19, 524241, -29), | ||
| 214 | + (19, 524242, -28), | ||
| 215 | + (19, 524243, -27), | ||
| 216 | + (19, 524244, 17), | ||
| 217 | + (19, 524245, 18), | ||
| 218 | + (19, 524246, 19), | ||
| 219 | + (19, 524247, 20), | ||
| 220 | + (19, 524248, 21), | ||
| 221 | + (19, 524249, 22), | ||
| 222 | + (19, 524250, 23), | ||
| 223 | + (19, 524251, 24), | ||
| 224 | + (19, 524252, 25), | ||
| 225 | + (19, 524253, 26), | ||
| 226 | + (19, 524254, 27), | ||
| 227 | + (19, 524255, 28), | ||
| 228 | + (19, 524256, 29), | ||
| 229 | + (19, 524257, 30), | ||
| 230 | + (19, 524258, 31), | ||
| 231 | + (19, 524259, 32), | ||
| 232 | + (19, 524260, 33), | ||
| 233 | + (19, 524261, 34), | ||
| 234 | + (19, 524262, 35), | ||
| 235 | + (19, 524263, 36), | ||
| 236 | + (19, 524264, 37), | ||
| 237 | + (19, 524265, 38), | ||
| 238 | + (19, 524266, 39), | ||
| 239 | + (19, 524267, 40), | ||
| 240 | + (19, 524268, 41), | ||
| 241 | + (19, 524269, 42), | ||
| 242 | + (19, 524270, 43), | ||
| 243 | + (19, 524271, 44), | ||
| 244 | + (19, 524272, 45), | ||
| 245 | + (19, 524273, 46), | ||
| 246 | + (19, 524274, 47), | ||
| 247 | + (19, 524275, 48), | ||
| 248 | + (19, 524276, 49), | ||
| 249 | + (19, 524277, 50), | ||
| 250 | + (19, 524278, 51), | ||
| 251 | + (19, 524279, 52), | ||
| 252 | + (19, 524280, 53), | ||
| 253 | + (19, 524281, 54), | ||
| 254 | + (19, 524282, 55), | ||
| 255 | + (19, 524283, 56), | ||
| 256 | + (19, 524284, 57), | ||
| 257 | + (19, 524285, 58), | ||
| 258 | + (19, 524286, 59), | ||
| 259 | + (19, 524287, 60), | ||
| 260 | +]; | ||
| 261 | + | ||
| 262 | +/// SBR Huffman book `ENV30_T`: (length, code, delta) by codeword. | ||
| 263 | +pub(crate) static ENV30_T: [(u8, u32, i32); 63] = [ | ||
| 264 | + (1, 0, 0), | ||
| 265 | + (2, 2, -1), | ||
| 266 | + (3, 6, 0), | ||
| 267 | + (4, 14, -2), | ||
| 268 | + (5, 30, 0), | ||
| 269 | + (6, 62, -3), | ||
| 270 | + (7, 126, 0), | ||
| 271 | + (8, 254, -4), | ||
| 272 | + (9, 510, 0), | ||
| 273 | + (11, 2044, -5), | ||
| 274 | + (11, 2045, 0), | ||
| 275 | + (12, 4092, -6), | ||
| 276 | + (13, 8186, -7), | ||
| 277 | + (13, 8187, 0), | ||
| 278 | + (14, 16376, -8), | ||
| 279 | + (14, 16377, 0), | ||
| 280 | + (14, 16378, -9), | ||
| 281 | + (14, 16379, -10), | ||
| 282 | + (14, 16380, 0), | ||
| 283 | + (15, 32762, 0), | ||
| 284 | + (16, 65526, 0), | ||
| 285 | + (16, 65527, -13), | ||
| 286 | + (16, 65528, -11), | ||
| 287 | + (16, 65529, -12), | ||
| 288 | + (17, 131060, -14), | ||
| 289 | + (17, 131061, 0), | ||
| 290 | + (18, 262124, 0), | ||
| 291 | + (18, 262125, -31), | ||
| 292 | + (18, 262126, -30), | ||
| 293 | + (19, 524254, -29), | ||
| 294 | + (19, 524255, -28), | ||
| 295 | + (19, 524256, -27), | ||
| 296 | + (19, 524257, -26), | ||
| 297 | + (19, 524258, -25), | ||
| 298 | + (19, 524259, -24), | ||
| 299 | + (19, 524260, -23), | ||
| 300 | + (19, 524261, -22), | ||
| 301 | + (19, 524262, -21), | ||
| 302 | + (19, 524263, -20), | ||
| 303 | + (19, 524264, -19), | ||
| 304 | + (19, 524265, -18), | ||
| 305 | + (19, 524266, -17), | ||
| 306 | + (19, 524267, -16), | ||
| 307 | + (19, 524268, -15), | ||
| 308 | + (19, 524269, 0), | ||
| 309 | + (19, 524270, 0), | ||
| 310 | + (19, 524271, 0), | ||
| 311 | + (19, 524272, 0), | ||
| 312 | + (19, 524273, 0), | ||
| 313 | + (19, 524274, 0), | ||
| 314 | + (19, 524275, 0), | ||
| 315 | + (19, 524276, 0), | ||
| 316 | + (19, 524277, 0), | ||
| 317 | + (19, 524278, 0), | ||
| 318 | + (19, 524279, 0), | ||
| 319 | + (19, 524280, 0), | ||
| 320 | + (19, 524281, 0), | ||
| 321 | + (19, 524282, 0), | ||
| 322 | + (19, 524283, 0), | ||
| 323 | + (19, 524284, 0), | ||
| 324 | + (19, 524285, 0), | ||
| 325 | + (19, 524286, 0), | ||
| 326 | + (19, 524287, 0), | ||
| 327 | +]; | ||
| 328 | + | ||
| 329 | +/// SBR Huffman book `ENV30_F`: (length, code, delta) by codeword. | ||
| 330 | +pub(crate) static ENV30_F: [(u8, u32, i32); 63] = [ | ||
| 331 | + (1, 0, 0), | ||
| 332 | + (2, 2, -1), | ||
| 333 | + (3, 6, 0), | ||
| 334 | + (4, 14, -2), | ||
| 335 | + (5, 30, 0), | ||
| 336 | + (6, 62, -3), | ||
| 337 | + (8, 252, 0), | ||
| 338 | + (8, 253, -4), | ||
| 339 | + (9, 508, 0), | ||
| 340 | + (9, 509, -5), | ||
| 341 | + (10, 1020, 0), | ||
| 342 | + (10, 1021, -6), | ||
| 343 | + (11, 2044, 0), | ||
| 344 | + (11, 2045, -7), | ||
| 345 | + (12, 4092, 0), | ||
| 346 | + (12, 4093, -8), | ||
| 347 | + (13, 8188, 0), | ||
| 348 | + (14, 16378, 0), | ||
| 349 | + (14, 16379, -9), | ||
| 350 | + (15, 32760, -10), | ||
| 351 | + (15, 32761, 0), | ||
| 352 | + (15, 32762, 0), | ||
| 353 | + (16, 65526, -11), | ||
| 354 | + (16, 65527, -12), | ||
| 355 | + (16, 65528, 0), | ||
| 356 | + (16, 65529, 0), | ||
| 357 | + (17, 131060, -13), | ||
| 358 | + (17, 131061, -15), | ||
| 359 | + (17, 131062, 0), | ||
| 360 | + (17, 131063, 0), | ||
| 361 | + (18, 262128, -14), | ||
| 362 | + (18, 262129, 0), | ||
| 363 | + (18, 262130, -18), | ||
| 364 | + (18, 262131, -24), | ||
| 365 | + (18, 262132, -19), | ||
| 366 | + (18, 262133, 0), | ||
| 367 | + (18, 262134, 0), | ||
| 368 | + (19, 524270, -22), | ||
| 369 | + (19, 524271, -21), | ||
| 370 | + (19, 524272, -16), | ||
| 371 | + (19, 524273, 0), | ||
| 372 | + (19, 524274, 0), | ||
| 373 | + (19, 524275, 0), | ||
| 374 | + (19, 524276, 0), | ||
| 375 | + (19, 524277, -23), | ||
| 376 | + (19, 524278, -20), | ||
| 377 | + (19, 524279, 0), | ||
| 378 | + (20, 1048560, -31), | ||
| 379 | + (20, 1048561, -30), | ||
| 380 | + (20, 1048562, -29), | ||
| 381 | + (20, 1048563, -28), | ||
| 382 | + (20, 1048564, -27), | ||
| 383 | + (20, 1048565, -26), | ||
| 384 | + (20, 1048566, -25), | ||
| 385 | + (20, 1048567, -17), | ||
| 386 | + (20, 1048568, 0), | ||
| 387 | + (20, 1048569, 0), | ||
| 388 | + (20, 1048570, 0), | ||
| 389 | + (20, 1048571, 0), | ||
| 390 | + (20, 1048572, 0), | ||
| 391 | + (20, 1048573, 0), | ||
| 392 | + (20, 1048574, 0), | ||
| 393 | + (20, 1048575, 0), | ||
| 394 | +]; | ||
| 13 | 395 | ||
| 14 | /// SBR Huffman book `NOISE_T`: (length, code, delta) by codeword. | 396 | /// SBR Huffman book `NOISE_T`: (length, code, delta) by codeword. |
| 15 | pub(crate) static NOISE_T: [(u8, u32, i32); 63] = [ | 397 | pub(crate) static NOISE_T: [(u8, u32, i32); 63] = [ |
| @@ -145,6 +527,170 @@ pub(crate) static NOISE_F: [(u8, u32, i32); 63] = [ | |||
| 145 | (20, 1048575, 31), | 527 | (20, 1048575, 31), |
| 146 | ]; | 528 | ]; |
| 147 | 529 | ||
| 530 | +/// SBR Huffman book `ENVB15_F`: (length, code, delta) by codeword. | ||
| 531 | +pub(crate) static ENVB15_F: [(u8, u32, i32); 49] = [ | ||
| 532 | + (1, 0, 0), | ||
| 533 | + (2, 2, -1), | ||
| 534 | + (3, 6, 1), | ||
| 535 | + (4, 14, -2), | ||
| 536 | + (5, 30, 2), | ||
| 537 | + (6, 62, 3), | ||
| 538 | + (7, 126, -3), | ||
| 539 | + (8, 254, -4), | ||
| 540 | + (9, 510, 4), | ||
| 541 | + (11, 2044, -5), | ||
| 542 | + (11, 2045, 5), | ||
| 543 | + (11, 2046, -6), | ||
| 544 | + (12, 4094, 6), | ||
| 545 | + (14, 16380, -7), | ||
| 546 | + (15, 32762, 7), | ||
| 547 | + (16, 65526, 8), | ||
| 548 | + (16, 65527, -9), | ||
| 549 | + (17, 131056, -8), | ||
| 550 | + (18, 262114, -24), | ||
| 551 | + (18, 262115, -23), | ||
| 552 | + (18, 262116, -22), | ||
| 553 | + (18, 262117, -21), | ||
| 554 | + (18, 262118, -20), | ||
| 555 | + (18, 262119, -19), | ||
| 556 | + (18, 262120, -18), | ||
| 557 | + (18, 262121, -17), | ||
| 558 | + (18, 262122, -16), | ||
| 559 | + (18, 262123, -15), | ||
| 560 | + (18, 262124, -14), | ||
| 561 | + (18, 262125, -13), | ||
| 562 | + (18, 262126, -12), | ||
| 563 | + (18, 262127, -11), | ||
| 564 | + (18, 262128, -10), | ||
| 565 | + (18, 262129, 9), | ||
| 566 | + (18, 262130, 10), | ||
| 567 | + (18, 262131, 11), | ||
| 568 | + (18, 262132, 12), | ||
| 569 | + (18, 262133, 13), | ||
| 570 | + (18, 262134, 14), | ||
| 571 | + (18, 262135, 15), | ||
| 572 | + (18, 262136, 16), | ||
| 573 | + (18, 262137, 17), | ||
| 574 | + (18, 262138, 18), | ||
| 575 | + (18, 262139, 19), | ||
| 576 | + (18, 262140, 20), | ||
| 577 | + (18, 262141, 21), | ||
| 578 | + (18, 262142, 22), | ||
| 579 | + (19, 524286, 23), | ||
| 580 | + (19, 524287, 24), | ||
| 581 | +]; | ||
| 582 | + | ||
| 583 | +/// SBR Huffman book `ENVB15_T`: (length, code, delta) by codeword. | ||
| 584 | +pub(crate) static ENVB15_T: [(u8, u32, i32); 49] = [ | ||
| 585 | + (1, 0, 0), | ||
| 586 | + (2, 2, 1), | ||
| 587 | + (3, 6, -1), | ||
| 588 | + (4, 14, 2), | ||
| 589 | + (5, 30, -2), | ||
| 590 | + (6, 62, 3), | ||
| 591 | + (7, 126, -3), | ||
| 592 | + (8, 254, 4), | ||
| 593 | + (9, 510, -4), | ||
| 594 | + (11, 2044, -5), | ||
| 595 | + (11, 2045, 5), | ||
| 596 | + (12, 4092, -6), | ||
| 597 | + (12, 4093, 6), | ||
| 598 | + (15, 32752, 7), | ||
| 599 | + (16, 65506, -7), | ||
| 600 | + (16, 65507, 8), | ||
| 601 | + (16, 65508, -24), | ||
| 602 | + (16, 65509, -23), | ||
| 603 | + (16, 65510, -22), | ||
| 604 | + (16, 65511, -21), | ||
| 605 | + (16, 65512, -20), | ||
| 606 | + (16, 65513, -19), | ||
| 607 | + (16, 65514, -18), | ||
| 608 | + (16, 65515, -17), | ||
| 609 | + (16, 65516, -16), | ||
| 610 | + (16, 65517, -15), | ||
| 611 | + (16, 65518, -14), | ||
| 612 | + (16, 65519, -13), | ||
| 613 | + (16, 65520, -12), | ||
| 614 | + (16, 65521, -11), | ||
| 615 | + (16, 65522, -10), | ||
| 616 | + (16, 65523, -9), | ||
| 617 | + (16, 65524, -8), | ||
| 618 | + (16, 65525, 9), | ||
| 619 | + (16, 65526, 10), | ||
| 620 | + (16, 65527, 11), | ||
| 621 | + (16, 65528, 12), | ||
| 622 | + (16, 65529, 13), | ||
| 623 | + (16, 65530, 14), | ||
| 624 | + (17, 131062, 15), | ||
| 625 | + (17, 131063, 16), | ||
| 626 | + (17, 131064, 17), | ||
| 627 | + (17, 131065, 18), | ||
| 628 | + (17, 131066, 19), | ||
| 629 | + (17, 131067, 20), | ||
| 630 | + (17, 131068, 21), | ||
| 631 | + (17, 131069, 22), | ||
| 632 | + (17, 131070, 23), | ||
| 633 | + (17, 131071, 24), | ||
| 634 | +]; | ||
| 635 | + | ||
| 636 | +/// SBR Huffman book `ENVB30_T`: (length, code, delta) by codeword. | ||
| 637 | +pub(crate) static ENVB30_T: [(u8, u32, i32); 25] = [ | ||
| 638 | + (1, 0, 0), | ||
| 639 | + (2, 2, 0), | ||
| 640 | + (3, 6, -1), | ||
| 641 | + (4, 14, -2), | ||
| 642 | + (5, 30, 0), | ||
| 643 | + (6, 62, 0), | ||
| 644 | + (7, 126, -3), | ||
| 645 | + (8, 254, -4), | ||
| 646 | + (9, 510, 0), | ||
| 647 | + (12, 4088, -5), | ||
| 648 | + (13, 8178, -12), | ||
| 649 | + (13, 8179, -11), | ||
| 650 | + (13, 8180, -10), | ||
| 651 | + (13, 8181, -9), | ||
| 652 | + (13, 8182, -8), | ||
| 653 | + (13, 8183, -7), | ||
| 654 | + (13, 8184, -6), | ||
| 655 | + (13, 8185, 0), | ||
| 656 | + (13, 8186, 0), | ||
| 657 | + (13, 8187, 0), | ||
| 658 | + (13, 8188, 0), | ||
| 659 | + (13, 8189, 0), | ||
| 660 | + (13, 8190, 0), | ||
| 661 | + (14, 16382, 0), | ||
| 662 | + (14, 16383, 0), | ||
| 663 | +]; | ||
| 664 | + | ||
| 665 | +/// SBR Huffman book `ENVB30_F`: (length, code, delta) by codeword. | ||
| 666 | +pub(crate) static ENVB30_F: [(u8, u32, i32); 25] = [ | ||
| 667 | + (1, 0, 0), | ||
| 668 | + (2, 2, -1), | ||
| 669 | + (3, 6, 0), | ||
| 670 | + (4, 14, -2), | ||
| 671 | + (5, 30, 0), | ||
| 672 | + (6, 62, 0), | ||
| 673 | + (7, 126, -3), | ||
| 674 | + (8, 254, -4), | ||
| 675 | + (9, 510, 0), | ||
| 676 | + (11, 2044, -5), | ||
| 677 | + (12, 4090, 0), | ||
| 678 | + (13, 8182, 0), | ||
| 679 | + (13, 8183, -12), | ||
| 680 | + (13, 8184, -11), | ||
| 681 | + (13, 8185, -10), | ||
| 682 | + (13, 8186, -9), | ||
| 683 | + (13, 8187, -8), | ||
| 684 | + (14, 16376, -7), | ||
| 685 | + (14, 16377, -6), | ||
| 686 | + (14, 16378, 0), | ||
| 687 | + (14, 16379, 0), | ||
| 688 | + (14, 16380, 0), | ||
| 689 | + (14, 16381, 0), | ||
| 690 | + (14, 16382, 0), | ||
| 691 | + (14, 16383, 0), | ||
| 692 | +]; | ||
| 693 | + | ||
| 148 | /// SBR Huffman book `NOISEB_T`: (length, code, delta) by codeword. | 694 | /// SBR Huffman book `NOISEB_T`: (length, code, delta) by codeword. |
| 149 | pub(crate) static NOISEB_T: [(u8, u32, i32); 25] = [ | 695 | pub(crate) static NOISEB_T: [(u8, u32, i32); 25] = [ |
| 150 | (1, 0, 0), | 696 | (1, 0, 0), |
| @@ -222,6 +768,30 @@ mod tests { | |||
| 222 | } | 768 | } |
| 223 | } | 769 | } |
| 224 | 770 | ||
| 771 | + #[test] | ||
| 772 | + fn env15_f_is_a_complete_prefix_code() { | ||
| 773 | + kraft_is_one(&ENV15_F); | ||
| 774 | + is_prefix_free(&ENV15_F); | ||
| 775 | + } | ||
| 776 | + | ||
| 777 | + #[test] | ||
| 778 | + fn env15_t_is_a_complete_prefix_code() { | ||
| 779 | + kraft_is_one(&ENV15_T); | ||
| 780 | + is_prefix_free(&ENV15_T); | ||
| 781 | + } | ||
| 782 | + | ||
| 783 | + #[test] | ||
| 784 | + fn env30_t_is_a_complete_prefix_code() { | ||
| 785 | + kraft_is_one(&ENV30_T); | ||
| 786 | + is_prefix_free(&ENV30_T); | ||
| 787 | + } | ||
| 788 | + | ||
| 789 | + #[test] | ||
| 790 | + fn env30_f_is_a_complete_prefix_code() { | ||
| 791 | + kraft_is_one(&ENV30_F); | ||
| 792 | + is_prefix_free(&ENV30_F); | ||
| 793 | + } | ||
| 794 | + | ||
| 225 | #[test] | 795 | #[test] |
| 226 | fn noise_t_is_a_complete_prefix_code() { | 796 | fn noise_t_is_a_complete_prefix_code() { |
| 227 | kraft_is_one(&NOISE_T); | 797 | kraft_is_one(&NOISE_T); |
| @@ -234,6 +804,30 @@ mod tests { | |||
| 234 | is_prefix_free(&NOISE_F); | 804 | is_prefix_free(&NOISE_F); |
| 235 | } | 805 | } |
| 236 | 806 | ||
| 807 | + #[test] | ||
| 808 | + fn envb15_f_is_a_complete_prefix_code() { | ||
| 809 | + kraft_is_one(&ENVB15_F); | ||
| 810 | + is_prefix_free(&ENVB15_F); | ||
| 811 | + } | ||
| 812 | + | ||
| 813 | + #[test] | ||
| 814 | + fn envb15_t_is_a_complete_prefix_code() { | ||
| 815 | + kraft_is_one(&ENVB15_T); | ||
| 816 | + is_prefix_free(&ENVB15_T); | ||
| 817 | + } | ||
| 818 | + | ||
| 819 | + #[test] | ||
| 820 | + fn envb30_t_is_a_complete_prefix_code() { | ||
| 821 | + kraft_is_one(&ENVB30_T); | ||
| 822 | + is_prefix_free(&ENVB30_T); | ||
| 823 | + } | ||
| 824 | + | ||
| 825 | + #[test] | ||
| 826 | + fn envb30_f_is_a_complete_prefix_code() { | ||
| 827 | + kraft_is_one(&ENVB30_F); | ||
| 828 | + is_prefix_free(&ENVB30_F); | ||
| 829 | + } | ||
| 830 | + | ||
| 237 | #[test] | 831 | #[test] |
| 238 | fn noiseb_t_is_a_complete_prefix_code() { | 832 | fn noiseb_t_is_a_complete_prefix_code() { |
| 239 | kraft_is_one(&NOISEB_T); | 833 | kraft_is_one(&NOISEB_T); |
scripts/aac-tables/sbrtables.pymodified+22 -7
| @@ -891,8 +891,16 @@ def values_config(kind, sf_index=7): | |||
| 891 | element = "cpe" if balance else "sce" | 891 | element = "cpe" if balance else "sce" |
| 892 | if kind.endswith("_F"): | 892 | if kind.endswith("_F"): |
| 893 | if is_env: | 893 | if is_env: |
| 894 | - over = dict(element=element, coupling=1, num_env=1, amp_res=amp_res, | 894 | + if amp_res: |
| 895 | - df_env=[0] * 8, df_noise=[0, 0], freq_res=1) | 895 | + # `amp_res_of` forces the 1.5 dB resolution whenever there is |
| 896 | + # only one envelope, so a lone envelope can never carry the | ||
| 897 | + # 3 dB book: a second envelope (T-coded, already closed) has | ||
| 898 | + # to ride along to keep the resolution at 3 dB. | ||
| 899 | + over = dict(element=element, coupling=1, num_env=2, amp_res=1, | ||
| 900 | + df_env=[0, 1] + [0] * 6, df_noise=[0, 0], freq_res=1) | ||
| 901 | + else: | ||
| 902 | + over = dict(element=element, coupling=1, num_env=1, amp_res=amp_res, | ||
| 903 | + df_env=[0] * 8, df_noise=[0, 0], freq_res=1) | ||
| 896 | found = find_config(sf_index, over, n_high=2, n_q=1) | 904 | found = find_config(sf_index, over, n_high=2, n_q=1) |
| 897 | key, width = ("env0b" if balance else "env0"), RAW_ENV[(1 if balance else 0, amp_res)] | 905 | key, width = ("env0b" if balance else "env0"), RAW_ENV[(1 if balance else 0, amp_res)] |
| 898 | else: | 906 | else: |
| @@ -945,17 +953,24 @@ def book_values(oracle, kind, cfg, tables, key, width, scale, books): | |||
| 945 | seen = {} | 953 | seen = {} |
| 946 | crashed = set() | 954 | crashed = set() |
| 947 | clean = set() | 955 | clean = set() |
| 948 | - for (length, code, raw), (_n, err) in zip(meta, got): | 956 | + for (length, code, raw), (v, t, w), (n, err) in zip(meta, cases, got): |
| 949 | m = pat.search(err) | 957 | m = pat.search(err) |
| 950 | if not m: | 958 | if not m: |
| 951 | # Not a range-check complaint: either a clean decode (only the | 959 | # Not a range-check complaint: either a clean decode (only the |
| 952 | # routine byte-count line) or the parser aborting the element for | 960 | # routine byte-count line) or the parser aborting the element for |
| 953 | # an unrelated reason -- only the former licenses the "both ends | 961 | # an unrelated reason -- only the former licenses the "both ends |
| 954 | - # valid" inference below, so the two are told apart here. | 962 | + # valid" inference below, so the two are told apart here. The |
| 955 | - if "is not allocated" in err or "Invalid data found" in err: | 963 | + # "channel element 0.1 is not allocated" complaint fires on every |
| 956 | - crashed.add((length, code)) | 964 | + # mono probe regardless of whether the codeword itself was in |
| 957 | - else: | 965 | + # range (the reference decoder treats HE-AAC mono as implicit |
| 966 | + # stereo and always misses the second channel element), so it | ||
| 967 | + # carries no information; the byte count the parser actually | ||
| 968 | + # consumed against the full predicted frame length is the real | ||
| 969 | + # discriminator -- an undershoot is a genuine early abort. | ||
| 970 | + if n == predicted(v, t, w): | ||
| 958 | clean.add((length, code)) | 971 | clean.add((length, code)) |
| 972 | + else: | ||
| 973 | + crashed.add((length, code)) | ||
| 959 | continue | 974 | continue |
| 960 | val = int(m.group(1)) | 975 | val = int(m.group(1)) |
| 961 | if raw == 0: | 976 | if raw == 0: |