| @@ -82,6 +82,11 @@ static const int8_t xa_adpcm_table[5][2] = { · 81 unmodified lines |
| 82 | 82 | { 122, -60 } |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | +static const int16_t afc_coeffs[2][16] = { |
| 86 | + { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, -1024, -1024, -2048 }, |
| 87 | + { 0, 0, 2048, 1024, -2048, -1536, -1024, -2560, -2248, -2300, -3072, -2048, -1024, 1024, 0, 0 } |
| 88 | +}; |
| 89 | + |
| 85 | 90 | static const int16_t ea_adpcm_table[] = { |
| 86 | 91 | 0, 240, 460, 392, |
| 87 | 92 | 0, 0, -208, -220, |
| @@ -90,6 +95,128 @@ static const int16_t ea_adpcm_table[] = { · 2 unmodified lines |
| 90 | 95 | 0, -1, -3, -4 |
| 91 | 96 | }; |
| 92 | 97 | |
| 98 | +/* |
| 99 | + * Dumped from the binaries: |
| 100 | + * - FantasticJourney.exe - 0x794D2, DGROUP:0x47A4D2 |
| 101 | + * - BigRaceUSA.exe - 0x9B8AA, DGROUP:0x49C4AA |
| 102 | + * - Timeshock!.exe - 0x8506A, DGROUP:0x485C6A |
| 103 | + */ |
| 104 | +static const int8_t ima_cunning_index_table[9] = { |
| 105 | + -1, -1, -1, -1, 1, 2, 3, 4, -1 |
| 106 | +}; |
| 107 | + |
| 108 | +/* |
| 109 | + * Dumped from the binaries: |
| 110 | + * - FantasticJourney.exe - 0x79458, DGROUP:0x47A458 |
| 111 | + * - BigRaceUSA.exe - 0x9B830, DGROUP:0x49C430 |
| 112 | + * - Timeshock!.exe - 0x84FF0, DGROUP:0x485BF0 |
| 113 | + */ |
| 114 | +static const int16_t ima_cunning_step_table[61] = { |
| 115 | + 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, |
| 116 | + 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, |
| 117 | + 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, |
| 118 | + 192, 224, 256, 320, 384, 448, 512, 640, 768, 896, |
| 119 | + 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584, 4096, 5120, |
| 120 | + 6144, 7168, 8192, 10240, 12288, 14336, 16384, 20480, 24576, 28672, 0 |
| 121 | +}; |
| 122 | + |
| 123 | +static const int8_t adpcm_index_table2[4] = { |
| 124 | + -1, 2, |
| 125 | + -1, 2, |
| 126 | +}; |
| 127 | + |
| 128 | +static const int8_t adpcm_index_table3[8] = { |
| 129 | + -1, -1, 1, 2, |
| 130 | + -1, -1, 1, 2, |
| 131 | +}; |
| 132 | + |
| 133 | +static const int8_t adpcm_index_table5[32] = { |
| 134 | + -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16, |
| 135 | + -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16, |
| 136 | +}; |
| 137 | + |
| 138 | +static const int8_t * const adpcm_index_tables[4] = { |
| 139 | + &adpcm_index_table2[0], |
| 140 | + &adpcm_index_table3[0], |
| 141 | + &ff_adpcm_index_table[0], |
| 142 | + &adpcm_index_table5[0], |
| 143 | +}; |
| 144 | + |
| 145 | +static const int16_t mtaf_stepsize[32][16] = { |
| 146 | + { 1, 5, 9, 13, 16, 20, 24, 28, |
| 147 | + -1, -5, -9, -13, -16, -20, -24, -28, }, |
| 148 | + { 2, 6, 11, 15, 20, 24, 29, 33, |
| 149 | + -2, -6, -11, -15, -20, -24, -29, -33, }, |
| 150 | + { 2, 7, 13, 18, 23, 28, 34, 39, |
| 151 | + -2, -7, -13, -18, -23, -28, -34, -39, }, |
| 152 | + { 3, 9, 15, 21, 28, 34, 40, 46, |
| 153 | + -3, -9, -15, -21, -28, -34, -40, -46, }, |
| 154 | + { 3, 11, 18, 26, 33, 41, 48, 56, |
| 155 | + -3, -11, -18, -26, -33, -41, -48, -56, }, |
| 156 | + { 4, 13, 22, 31, 40, 49, 58, 67, |
| 157 | + -4, -13, -22, -31, -40, -49, -58, -67, }, |
| 158 | + { 5, 16, 26, 37, 48, 59, 69, 80, |
| 159 | + -5, -16, -26, -37, -48, -59, -69, -80, }, |
| 160 | + { 6, 19, 31, 44, 57, 70, 82, 95, |
| 161 | + -6, -19, -31, -44, -57, -70, -82, -95, }, |
| 162 | + { 7, 22, 38, 53, 68, 83, 99, 114, |
| 163 | + -7, -22, -38, -53, -68, -83, -99, -114, }, |
| 164 | + { 9, 27, 45, 63, 81, 99, 117, 135, |
| 165 | + -9, -27, -45, -63, -81, -99, -117, -135, }, |
| 166 | + { 10, 32, 53, 75, 96, 118, 139, 161, |
| 167 | + -10, -32, -53, -75, -96, -118, -139, -161, }, |
| 168 | + { 12, 38, 64, 90, 115, 141, 167, 193, |
| 169 | + -12, -38, -64, -90, -115, -141, -167, -193, }, |
| 170 | + { 15, 45, 76, 106, 137, 167, 198, 228, |
| 171 | + -15, -45, -76, -106, -137, -167, -198, -228, }, |
| 172 | + { 18, 54, 91, 127, 164, 200, 237, 273, |
| 173 | + -18, -54, -91, -127, -164, -200, -237, -273, }, |
| 174 | + { 21, 65, 108, 152, 195, 239, 282, 326, |
| 175 | + -21, -65, -108, -152, -195, -239, -282, -326, }, |
| 176 | + { 25, 77, 129, 181, 232, 284, 336, 388, |
| 177 | + -25, -77, -129, -181, -232, -284, -336, -388, }, |
| 178 | + { 30, 92, 153, 215, 276, 338, 399, 461, |
| 179 | + -30, -92, -153, -215, -276, -338, -399, -461, }, |
| 180 | + { 36, 109, 183, 256, 329, 402, 476, 549, |
| 181 | + -36, -109, -183, -256, -329, -402, -476, -549, }, |
| 182 | + { 43, 130, 218, 305, 392, 479, 567, 654, |
| 183 | + -43, -130, -218, -305, -392, -479, -567, -654, }, |
| 184 | + { 52, 156, 260, 364, 468, 572, 676, 780, |
| 185 | + -52, -156, -260, -364, -468, -572, -676, -780, }, |
| 186 | + { 62, 186, 310, 434, 558, 682, 806, 930, |
| 187 | + -62, -186, -310, -434, -558, -682, -806, -930, }, |
| 188 | + { 73, 221, 368, 516, 663, 811, 958, 1106, |
| 189 | + -73, -221, -368, -516, -663, -811, -958, -1106, }, |
| 190 | + { 87, 263, 439, 615, 790, 966, 1142, 1318, |
| 191 | + -87, -263, -439, -615, -790, -966, -1142, -1318, }, |
| 192 | + { 104, 314, 523, 733, 942, 1152, 1361, 1571, |
| 193 | + -104, -314, -523, -733, -942, -1152, -1361, -1571, }, |
| 194 | + { 124, 374, 623, 873, 1122, 1372, 1621, 1871, |
| 195 | + -124, -374, -623, -873, -1122, -1372, -1621, -1871, }, |
| 196 | + { 148, 445, 743, 1040, 1337, 1634, 1932, 2229, |
| 197 | + -148, -445, -743, -1040, -1337, -1634, -1932, -2229, }, |
| 198 | + { 177, 531, 885, 1239, 1593, 1947, 2301, 2655, |
| 199 | + -177, -531, -885, -1239, -1593, -1947, -2301, -2655, }, |
| 200 | + { 210, 632, 1053, 1475, 1896, 2318, 2739, 3161, |
| 201 | + -210, -632, -1053, -1475, -1896, -2318, -2739, -3161, }, |
| 202 | + { 251, 753, 1255, 1757, 2260, 2762, 3264, 3766, |
| 203 | + -251, -753, -1255, -1757, -2260, -2762, -3264, -3766, }, |
| 204 | + { 299, 897, 1495, 2093, 2692, 3290, 3888, 4486, |
| 205 | + -299, -897, -1495, -2093, -2692, -3290, -3888, -4486, }, |
| 206 | + { 356, 1068, 1781, 2493, 3206, 3918, 4631, 5343, |
| 207 | + -356, -1068, -1781, -2493, -3206, -3918, -4631, -5343, }, |
| 208 | + { 424, 1273, 2121, 2970, 3819, 4668, 5516, 6365, |
| 209 | + -424, -1273, -2121, -2970, -3819, -4668, -5516, -6365, }, |
| 210 | +}; |
| 211 | + |
| 212 | +static const int16_t oki_step_table[49] = { |
| 213 | + 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, |
| 214 | + 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, |
| 215 | + 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, |
| 216 | + 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, |
| 217 | + 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552 |
| 218 | +}; |
| 219 | + |
| 93 | 220 | // padded to zero where table size is less then 16 |
| 94 | 221 | static const int8_t swf_index_tables[4][16] = { |
| 95 | 222 | /*2*/ { -1, 2 }, |
| @@ -335,8 +462,8 @@ static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int · 239 unmodified lines |
| 335 | 462 | |
| 336 | 463 | nibble = sign_extend(nibble & 0xF, 4); |
| 337 | 464 | |
| 338 | | − step = ff_adpcm_ima_cunning_step_table[c->step_index]; |
| 339 | | − step_index = c->step_index + ff_adpcm_ima_cunning_index_table[abs(nibble)]; |
| 465 | + step = ima_cunning_step_table[c->step_index]; |
| 466 | + step_index = c->step_index + ima_cunning_index_table[abs(nibble)]; |
| 340 | 467 | step_index = av_clip(step_index, 0, 60); |
| 341 | 468 | |
| 342 | 469 | predictor = c->predictor + step * nibble; |
| @@ -354,7 +481,7 @@ static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitC · 11 unmodified lines |
| 354 | 481 | shift = bps - 1; |
| 355 | 482 | nibble = get_bits_le(gb, bps), |
| 356 | 483 | step = ff_adpcm_step_table[c->step_index]; |
| 357 | | − step_index = c->step_index + ff_adpcm_index_tables[bps - 2][nibble]; |
| 484 | + step_index = c->step_index + adpcm_index_tables[bps - 2][nibble]; |
| 358 | 485 | step_index = av_clip(step_index, 0, 88); |
| 359 | 486 | |
| 360 | 487 | sign = nibble & (1 << shift); |
| @@ -419,7 +546,7 @@ static inline int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nib · 58 unmodified lines |
| 419 | 546 | { |
| 420 | 547 | int step_index, predictor, sign, delta, diff, step; |
| 421 | 548 | |
| 422 | | − step = ff_adpcm_oki_step_table[c->step_index]; |
| 549 | + step = oki_step_table[c->step_index]; |
| 423 | 550 | step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble]; |
| 424 | 551 | step_index = av_clip(step_index, 0, 48); |
| 425 | 552 | |
| @@ -493,7 +620,7 @@ static inline int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t · 67 unmodified lines |
| 493 | 620 | |
| 494 | 621 | static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble) |
| 495 | 622 | { |
| 496 | | − c->predictor += ff_adpcm_mtaf_stepsize[c->step][nibble]; |
| 623 | + c->predictor += mtaf_stepsize[c->step][nibble]; |
| 497 | 624 | c->predictor = av_clip_int16(c->predictor); |
| 498 | 625 | c->step += ff_adpcm_index_table[nibble]; |
| 499 | 626 | c->step = av_clip_uintp2(c->step, 5); |
| @@ -1836,8 +1963,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1336 unmodified lines |
| 1836 | 1963 | int byte = bytestream2_get_byteu(&gb); |
| 1837 | 1964 | int scale = 1 << (byte >> 4); |
| 1838 | 1965 | int index = byte & 0xf; |
| 1839 | | − int factor1 = ff_adpcm_afc_coeffs[0][index]; |
| 1840 | | − int factor2 = ff_adpcm_afc_coeffs[1][index]; |
| 1966 | + int factor1 = afc_coeffs[0][index]; |
| 1967 | + int factor2 = afc_coeffs[1][index]; |
| 1841 | 1968 | |
| 1842 | 1969 | /* Decode 16 samples. */ |
| 1843 | 1970 | for (int n = 0; n < 16; n++) { |