History

avcodec/adpcm_data: Move tables only used by adpcm.c to it

Andreas Rheinhardt committed 5 years ago

Commit 73b847e1 parent ac5bd4e3 files · +134 −140Browse files

Unified · Split

3 files
  1. libavcodec/adpcm.c +134 −7
  2. libavcodec/adpcm_data.c +0 −127
  3. libavcodec/adpcm_data.h +0 −6
libavcodec/adpcm.c+134−7
@@ -82,6 +82,11 @@ static const int8_t xa_adpcm_table[5][2] = { · 81 unmodified lines
8282 { 122, -60 }
8383 };
8484
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+
8590 static const int16_t ea_adpcm_table[] = {
8691 0, 240, 460, 392,
8792 0, 0, -208, -220,
@@ -90,6 +95,128 @@ static const int16_t ea_adpcm_table[] = { · 2 unmodified lines
9095 0, -1, -3, -4
9196 };
9297
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+
93220 // padded to zero where table size is less then 16
94221 static const int8_t swf_index_tables[4][16] = {
95222 /*2*/ { -1, 2 },
@@ -335,8 +462,8 @@ static inline int16_t adpcm_ima_cunning_expand_nibble(ADPCMChannelStatus *c, int · 239 unmodified lines
335462
336463 nibble = sign_extend(nibble & 0xF, 4);
337464
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)];
340467 step_index = av_clip(step_index, 0, 60);
341468
342469 predictor = c->predictor + step * nibble;
@@ -354,7 +481,7 @@ static inline int16_t adpcm_ima_wav_expand_nibble(ADPCMChannelStatus *c, GetBitC · 11 unmodified lines
354481 shift = bps - 1;
355482 nibble = get_bits_le(gb, bps),
356483 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];
358485 step_index = av_clip(step_index, 0, 88);
359486
360487 sign = nibble & (1 << shift);
@@ -419,7 +546,7 @@ static inline int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nib · 58 unmodified lines
419546 {
420547 int step_index, predictor, sign, delta, diff, step;
421548
422− step = ff_adpcm_oki_step_table[c->step_index];
549+ step = oki_step_table[c->step_index];
423550 step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
424551 step_index = av_clip(step_index, 0, 48);
425552
@@ -493,7 +620,7 @@ static inline int16_t adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, uint8_t · 67 unmodified lines
493620
494621 static inline int16_t adpcm_mtaf_expand_nibble(ADPCMChannelStatus *c, uint8_t nibble)
495622 {
496− c->predictor += ff_adpcm_mtaf_stepsize[c->step][nibble];
623+ c->predictor += mtaf_stepsize[c->step][nibble];
497624 c->predictor = av_clip_int16(c->predictor);
498625 c->step += ff_adpcm_index_table[nibble];
499626 c->step = av_clip_uintp2(c->step, 5);
@@ -1836,8 +1963,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, · 1336 unmodified lines
18361963 int byte = bytestream2_get_byteu(&gb);
18371964 int scale = 1 << (byte >> 4);
18381965 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];
18411968
18421969 /* Decode 16 samples. */
18431970 for (int n = 0; n < 16; n++) {
libavcodec/adpcm_data.c+0−127
@@ -27,33 +27,11 @@ · 26 unmodified lines
2727
2828 /* ff_adpcm_step_table[] and ff_adpcm_index_table[] are from the ADPCM
2929 reference source */
30−static const int8_t adpcm_index_table2[4] = {
31− -1, 2,
32− -1, 2,
33−};
34−
35−static const int8_t adpcm_index_table3[8] = {
36− -1, -1, 1, 2,
37− -1, -1, 1, 2,
38−};
39−
4030 const int8_t ff_adpcm_index_table[16] = {
4131 -1, -1, -1, -1, 2, 4, 6, 8,
4232 -1, -1, -1, -1, 2, 4, 6, 8,
4333 };
4434
45−static const int8_t adpcm_index_table5[32] = {
46− -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16,
47− -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16,
48−};
49−
50−const int8_t * const ff_adpcm_index_tables[4] = {
51− &adpcm_index_table2[0],
52− &adpcm_index_table3[0],
53− &ff_adpcm_index_table[0],
54− &adpcm_index_table5[0],
55−};
56−
5735 /**
5836 * This is the step table. Note that many programs use slight deviations from
5937 * this table, but such deviations are negligible:
@@ -70,14 +48,6 @@ const int16_t ff_adpcm_step_table[89] = { · 10 unmodified lines
7048 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
7149 };
7250
73−const int16_t ff_adpcm_oki_step_table[49] = {
74− 16, 17, 19, 21, 23, 25, 28, 31, 34, 37,
75− 41, 45, 50, 55, 60, 66, 73, 80, 88, 97,
76− 107, 118, 130, 143, 157, 173, 190, 209, 230, 253,
77− 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
78− 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
79−};
80−
8151 /* These are for MS-ADPCM */
8252 /* ff_adpcm_AdaptationTable[], ff_adpcm_AdaptCoeff1[], and
8353 ff_adpcm_AdaptCoeff2[] are from libsndfile */
@@ -105,100 +75,3 @@ const int8_t ff_adpcm_yamaha_difflookup[] = { · 21 unmodified lines
10575 1, 3, 5, 7, 9, 11, 13, 15,
10676 -1, -3, -5, -7, -9, -11, -13, -15
10777 };
108−
109−const int16_t ff_adpcm_afc_coeffs[2][16] = {
110− { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, -1024, -1024, -2048 },
111− { 0, 0, 2048, 1024, -2048, -1536, -1024, -2560, -2248, -2300, -3072, -2048, -1024, 1024, 0, 0 }
112−};
113−
114−const int16_t ff_adpcm_mtaf_stepsize[32][16] = {
115− { 1, 5, 9, 13, 16, 20, 24, 28,
116− -1, -5, -9, -13, -16, -20, -24, -28, },
117− { 2, 6, 11, 15, 20, 24, 29, 33,
118− -2, -6, -11, -15, -20, -24, -29, -33, },
119− { 2, 7, 13, 18, 23, 28, 34, 39,
120− -2, -7, -13, -18, -23, -28, -34, -39, },
121− { 3, 9, 15, 21, 28, 34, 40, 46,
122− -3, -9, -15, -21, -28, -34, -40, -46, },
123− { 3, 11, 18, 26, 33, 41, 48, 56,
124− -3, -11, -18, -26, -33, -41, -48, -56, },
125− { 4, 13, 22, 31, 40, 49, 58, 67,
126− -4, -13, -22, -31, -40, -49, -58, -67, },
127− { 5, 16, 26, 37, 48, 59, 69, 80,
128− -5, -16, -26, -37, -48, -59, -69, -80, },
129− { 6, 19, 31, 44, 57, 70, 82, 95,
130− -6, -19, -31, -44, -57, -70, -82, -95, },
131− { 7, 22, 38, 53, 68, 83, 99, 114,
132− -7, -22, -38, -53, -68, -83, -99, -114, },
133− { 9, 27, 45, 63, 81, 99, 117, 135,
134− -9, -27, -45, -63, -81, -99, -117, -135, },
135− { 10, 32, 53, 75, 96, 118, 139, 161,
136− -10, -32, -53, -75, -96, -118, -139, -161, },
137− { 12, 38, 64, 90, 115, 141, 167, 193,
138− -12, -38, -64, -90, -115, -141, -167, -193, },
139− { 15, 45, 76, 106, 137, 167, 198, 228,
140− -15, -45, -76, -106, -137, -167, -198, -228, },
141− { 18, 54, 91, 127, 164, 200, 237, 273,
142− -18, -54, -91, -127, -164, -200, -237, -273, },
143− { 21, 65, 108, 152, 195, 239, 282, 326,
144− -21, -65, -108, -152, -195, -239, -282, -326, },
145− { 25, 77, 129, 181, 232, 284, 336, 388,
146− -25, -77, -129, -181, -232, -284, -336, -388, },
147− { 30, 92, 153, 215, 276, 338, 399, 461,
148− -30, -92, -153, -215, -276, -338, -399, -461, },
149− { 36, 109, 183, 256, 329, 402, 476, 549,
150− -36, -109, -183, -256, -329, -402, -476, -549, },
151− { 43, 130, 218, 305, 392, 479, 567, 654,
152− -43, -130, -218, -305, -392, -479, -567, -654, },
153− { 52, 156, 260, 364, 468, 572, 676, 780,
154− -52, -156, -260, -364, -468, -572, -676, -780, },
155− { 62, 186, 310, 434, 558, 682, 806, 930,
156− -62, -186, -310, -434, -558, -682, -806, -930, },
157− { 73, 221, 368, 516, 663, 811, 958, 1106,
158− -73, -221, -368, -516, -663, -811, -958, -1106, },
159− { 87, 263, 439, 615, 790, 966, 1142, 1318,
160− -87, -263, -439, -615, -790, -966, -1142, -1318, },
161− { 104, 314, 523, 733, 942, 1152, 1361, 1571,
162− -104, -314, -523, -733, -942, -1152, -1361, -1571, },
163− { 124, 374, 623, 873, 1122, 1372, 1621, 1871,
164− -124, -374, -623, -873, -1122, -1372, -1621, -1871, },
165− { 148, 445, 743, 1040, 1337, 1634, 1932, 2229,
166− -148, -445, -743, -1040, -1337, -1634, -1932, -2229, },
167− { 177, 531, 885, 1239, 1593, 1947, 2301, 2655,
168− -177, -531, -885, -1239, -1593, -1947, -2301, -2655, },
169− { 210, 632, 1053, 1475, 1896, 2318, 2739, 3161,
170− -210, -632, -1053, -1475, -1896, -2318, -2739, -3161, },
171− { 251, 753, 1255, 1757, 2260, 2762, 3264, 3766,
172− -251, -753, -1255, -1757, -2260, -2762, -3264, -3766, },
173− { 299, 897, 1495, 2093, 2692, 3290, 3888, 4486,
174− -299, -897, -1495, -2093, -2692, -3290, -3888, -4486, },
175− { 356, 1068, 1781, 2493, 3206, 3918, 4631, 5343,
176− -356, -1068, -1781, -2493, -3206, -3918, -4631, -5343, },
177− { 424, 1273, 2121, 2970, 3819, 4668, 5516, 6365,
178− -424, -1273, -2121, -2970, -3819, -4668, -5516, -6365, },
179−};
180−
181−/*
182− * Dumped from the binaries:
183− * - FantasticJourney.exe - 0x794D2, DGROUP:0x47A4D2
184− * - BigRaceUSA.exe - 0x9B8AA, DGROUP:0x49C4AA
185− * - Timeshock!.exe - 0x8506A, DGROUP:0x485C6A
186− */
187−const int8_t ff_adpcm_ima_cunning_index_table[9] = {
188− -1, -1, -1, -1, 1, 2, 3, 4, -1
189−};
190−
191−/*
192− * Dumped from the binaries:
193− * - FantasticJourney.exe - 0x79458, DGROUP:0x47A458
194− * - BigRaceUSA.exe - 0x9B830, DGROUP:0x49C430
195− * - Timeshock!.exe - 0x84FF0, DGROUP:0x485BF0
196− */
197−const int16_t ff_adpcm_ima_cunning_step_table[61] = {
198− 1, 1, 1, 1, 2, 2, 3, 3, 4, 5,
199− 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
200− 32, 40, 48, 56, 64, 80, 96, 112, 128, 160,
201− 192, 224, 256, 320, 384, 448, 512, 640, 768, 896,
202− 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584, 4096, 5120,
203− 6144, 7168, 8192, 10240, 12288, 14336, 16384, 20480, 24576, 28672, 0
204−};
libavcodec/adpcm_data.h+0−6
@@ -31,18 +31,12 @@ · 30 unmodified lines
3131 static const uint8_t ff_adpcm_ima_block_sizes[4] = { 4, 12, 4, 20 };
3232 static const uint8_t ff_adpcm_ima_block_samples[4] = { 16, 32, 8, 32 };
3333
34−extern const int8_t * const ff_adpcm_index_tables[4];
3534 extern const int8_t ff_adpcm_index_table[16];
3635 extern const int16_t ff_adpcm_step_table[89];
37−extern const int16_t ff_adpcm_oki_step_table[49];
3836 extern const int16_t ff_adpcm_AdaptationTable[];
3937 extern const uint8_t ff_adpcm_AdaptCoeff1[];
4038 extern const int8_t ff_adpcm_AdaptCoeff2[];
4139 extern const int16_t ff_adpcm_yamaha_indexscale[];
4240 extern const int8_t ff_adpcm_yamaha_difflookup[];
43−extern const int16_t ff_adpcm_afc_coeffs[2][16];
44−extern const int16_t ff_adpcm_mtaf_stepsize[32][16];
45−extern const int8_t ff_adpcm_ima_cunning_index_table[9];
46−extern const int16_t ff_adpcm_ima_cunning_step_table[61];
4741
4842 #endif /* AVCODEC_ADPCM_DATA_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t