2 * Copyright (c) 2001-2003 The FFmpeg project
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 /* ff_adpcm_step_table[] and ff_adpcm_index_table[] are from the ADPCM
30 static const int8_t adpcm_index_table2[4] = {
35 static const int8_t adpcm_index_table3[8] = {
40 const int8_t ff_adpcm_index_table[16] = {
41 -1, -1, -1, -1, 2, 4, 6, 8,
42 -1, -1, -1, -1, 2, 4, 6, 8,
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,
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],
58 * This is the step table. Note that many programs use slight deviations from
59 * this table, but such deviations are negligible:
61 const int16_t ff_adpcm_step_table[89] = {
62 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
63 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
64 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
65 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
66 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
67 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
68 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
69 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
70 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
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
81 /* These are for MS-ADPCM */
82 /* ff_adpcm_AdaptationTable[], ff_adpcm_AdaptCoeff1[], and
83 ff_adpcm_AdaptCoeff2[] are from libsndfile */
84 const int16_t ff_adpcm_AdaptationTable[] = {
85 230, 230, 230, 230, 307, 409, 512, 614,
86 768, 614, 512, 409, 307, 230, 230, 230
89 /** Divided by 4 to fit in 8-bit integers */
90 const uint8_t ff_adpcm_AdaptCoeff1[] = {
91 64, 128, 0, 48, 60, 115, 98
94 /** Divided by 4 to fit in 8-bit integers */
95 const int8_t ff_adpcm_AdaptCoeff2[] = {
96 0, -64, 0, 16, 0, -52, -58
99 const int16_t ff_adpcm_yamaha_indexscale[] = {
100 230, 230, 230, 230, 307, 409, 512, 614,
101 230, 230, 230, 230, 307, 409, 512, 614
104 const int8_t ff_adpcm_yamaha_difflookup[] = {
105 1, 3, 5, 7, 9, 11, 13, 15,
106 -1, -3, -5, -7, -9, -11, -13, -15
109 const uint16_t ff_adpcm_afc_coeffs[2][16] = {
110 { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, 64512, 64512, 63488 },
111 { 0, 0, 2048, 1024, 63488, 64000, 64512, 62976, 63288, 63236, 62464, 63488, 64512, 1024, 0, 0 }
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, },
181 const int8_t ff_adpcm_ima_cunning_index_table[8] = {
182 -1, -1, -1, -1, 1, 2, 3, 4,
185 const int16_t ff_adpcm_ima_cunning_step_table[61] = {
186 1, 1, 1, 1, 2, 2, 3, 3, 4, 5,
187 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
188 32, 40, 48, 56, 64, 80, 96, 112, 128, 160,
189 192, 224, 256, 320, 384, 448, 512, 640, 768, 896,
190 1024, 1280, 1536, 1792, 2048, 2560, 3072, 3584, 4096, 5120,
191 6144, 7168, 8192, 10240, 12288, 14336, 16384, 20480, 24576, 28672, 0