3 * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef AVCODEC_QCELPDATA_H
23 #define AVCODEC_QCELPDATA_H
27 * Data tables for the QCELP decoder
28 * @author Reynaldo H. Verdejo Pinochet
29 * @remark FFmpeg merging spearheaded by Kenan Gillet
34 #include "libavutil/common.h"
37 * QCELP unpacked data frame
40 /// @defgroup qcelp_codebook_parameters QCELP excitation codebook parameters
42 uint8_t cbsign[16]; ///!< sign of the codebook gain for each codebook subframe
43 uint8_t cbgain[16]; ///!< unsigned codebook gain for each codebook subframe
44 uint8_t cindex[16]; ///!< codebook index for each codebook subframe
47 /// @defgroup qcelp_pitch_parameters QCELP pitch prediction parameters
49 uint8_t plag[4]; ///!< pitch lag for each pitch subframe
50 uint8_t pfrac[4]; ///!< fractional pitch lag for each pitch subframe
51 uint8_t pgain[4]; ///!< pitch gain for each pitch subframe
55 * line spectral pair frequencies (LSP) for RATE_OCTAVE,
56 * line spectral pair frequencies grouped into five vectors
57 * of dimension two (LSPV) for other rates
64 * pre-calculated table for hammsinc function
65 * Only half of the table is needed because of symmetry.
67 * TIA/EIA/IS-733 2.4.5.2-2/3
69 static const float qcelp_hammsinc_table[4] = { -0.006822, 0.041249, -0.143459, 0.588863};
72 uint8_t index; /*!< index into the QCELPContext structure */
73 uint8_t bitpos; /*!< position of the lowest bit in the value's byte */
74 uint8_t bitlen; /*!< number of bits to read */
77 #define QCELP_OF(variable, bit, len) {offsetof(QCELPFrame, variable), bit, len}
79 /* Disable the below code for now to allow 'make checkheaders' to pass. */
82 * bitmap unpacking tables for RATE_FULL
84 * TIA/EIA/IS-733 Table 2.4.7.1-1
86 static const QCELPBitmap qcelp_rate_full_bitmap[] = {
88 QCELP_OF(lspv [ 2], 0, 3), // 265
89 QCELP_OF(lspv [ 1], 0, 7), // 262
90 QCELP_OF(lspv [ 0], 0, 6), // 255
91 QCELP_OF(lspv [ 4], 0, 6), // 249
92 QCELP_OF(lspv [ 3], 0, 6), // 243
93 QCELP_OF(lspv [ 2], 3, 4), // 237
94 QCELP_OF(cbsign[ 0], 0, 1), // 233
95 QCELP_OF(cbgain[ 0], 0, 4), // 232
96 QCELP_OF(pfrac [ 0], 0, 1), // 228
97 QCELP_OF(plag [ 0], 0, 7), // 227
98 QCELP_OF(pgain [ 0], 0, 3), // 220
99 QCELP_OF(cindex[ 1], 0, 4), // 217
100 QCELP_OF(cbsign[ 1], 0, 1), // 213
101 QCELP_OF(cbgain[ 1], 0, 4), // 212
102 QCELP_OF(cindex[ 0], 0, 7), // 208
103 QCELP_OF(cbgain[ 3], 0, 1), // 201
104 QCELP_OF(cindex[ 2], 0, 7), // 200
105 QCELP_OF(cbsign[ 2], 0, 1), // 193
106 QCELP_OF(cbgain[ 2], 0, 4), // 192
107 QCELP_OF(cindex[ 1], 4, 3), // 188
108 QCELP_OF(plag [ 1], 0, 3), // 185
109 QCELP_OF(pgain [ 1], 0, 3), // 182
110 QCELP_OF(cindex[ 3], 0, 7), // 179
111 QCELP_OF(cbsign[ 3], 0, 1), // 172
112 QCELP_OF(cbgain[ 3], 1, 2), // 171
113 QCELP_OF(cindex[ 4], 0, 6), // 169
114 QCELP_OF(cbsign[ 4], 0, 1), // 163
115 QCELP_OF(cbgain[ 4], 0, 4), // 162
116 QCELP_OF(pfrac [ 1], 0, 1), // 158
117 QCELP_OF(plag [ 1], 3, 4), // 157
118 QCELP_OF(cbgain[ 6], 0, 3), // 153
119 QCELP_OF(cindex[ 5], 0, 7), // 150
120 QCELP_OF(cbsign[ 5], 0, 1), // 143
121 QCELP_OF(cbgain[ 5], 0, 4), // 142
122 QCELP_OF(cindex[ 4], 6, 1), // 138
123 QCELP_OF(cindex[ 7], 0, 3), // 137
124 QCELP_OF(cbsign[ 7], 0, 1), // 134
125 QCELP_OF(cbgain[ 7], 0, 3), // 133
126 QCELP_OF(cindex[ 6], 0, 7), // 130
127 QCELP_OF(cbsign[ 6], 0, 1), // 123
128 QCELP_OF(cbgain[ 6], 3, 1), // 122
129 QCELP_OF(cbgain[ 8], 0, 1), // 121
130 QCELP_OF(pfrac [ 2], 0, 1), // 120
131 QCELP_OF(plag [ 2], 0, 7), // 119
132 QCELP_OF(pgain [ 2], 0, 3), // 112
133 QCELP_OF(cindex[ 7], 3, 4), // 109
134 QCELP_OF(cbsign[ 9], 0, 1), // 105
135 QCELP_OF(cbgain[ 9], 0, 4), // 104
136 QCELP_OF(cindex[ 8], 0, 7), // 100
137 QCELP_OF(cbsign[ 8], 0, 1), // 93
138 QCELP_OF(cbgain[ 8], 1, 3), // 92
139 QCELP_OF(cindex[10], 0, 4), // 89
140 QCELP_OF(cbsign[10], 0, 1), // 85
141 QCELP_OF(cbgain[10], 0, 4), // 84
142 QCELP_OF(cindex[ 9], 0, 7), // 80
143 QCELP_OF(pgain [ 3], 0, 2), // 73
144 QCELP_OF(cindex[11], 0, 7), // 71
145 QCELP_OF(cbsign[11], 0, 1), // 64
146 QCELP_OF(cbgain[11], 0, 3), // 63
147 QCELP_OF(cindex[10], 4, 3), // 60
148 QCELP_OF(cindex[12], 0, 2), // 57
149 QCELP_OF(cbsign[12], 0, 1), // 55
150 QCELP_OF(cbgain[12], 0, 4), // 54
151 QCELP_OF(pfrac [ 3], 0, 1), // 50
152 QCELP_OF(plag [ 3], 0, 7), // 49
153 QCELP_OF(pgain [ 3], 2, 1), // 42
154 QCELP_OF(cindex[13], 0, 6), // 41
155 QCELP_OF(cbsign[13], 0, 1), // 35
156 QCELP_OF(cbgain[13], 0, 4), // 34
157 QCELP_OF(cindex[12], 2, 5), // 30
158 QCELP_OF(cbgain[15], 0, 3), // 25
159 QCELP_OF(cindex[14], 0, 7), // 22
160 QCELP_OF(cbsign[14], 0, 1), // 15
161 QCELP_OF(cbgain[14], 0, 4), // 14
162 QCELP_OF(cindex[13], 6, 1), // 10
163 QCELP_OF(reserved, 0, 2), // 9
164 QCELP_OF(cindex[15], 0, 7), // 7
165 QCELP_OF(cbsign[15], 0, 1) // 0
169 * bitmap unpacking tables for RATE_HALF
171 * TIA/EIA/IS-733 Table 2.4.7.2-1
173 static const QCELPBitmap qcelp_rate_half_bitmap[] = {
175 QCELP_OF(lspv [2], 0, 3), // 123
176 QCELP_OF(lspv [1], 0, 7), // 120
177 QCELP_OF(lspv [0], 0, 6), // 113
178 QCELP_OF(lspv [4], 0, 6), // 107
179 QCELP_OF(lspv [3], 0, 6), // 101
180 QCELP_OF(lspv [2], 3, 4), // 95
181 QCELP_OF(cbsign[0], 0, 1), // 91
182 QCELP_OF(cbgain[0], 0, 4), // 90
183 QCELP_OF(pfrac [0], 0, 1), // 86
184 QCELP_OF(plag [0], 0, 7), // 85
185 QCELP_OF(pgain [0], 0, 3), // 78
186 QCELP_OF(plag [1], 0, 6), // 75
187 QCELP_OF(pgain [1], 0, 3), // 69
188 QCELP_OF(cindex[0], 0, 7), // 66
189 QCELP_OF(pgain [2], 0, 2), // 59
190 QCELP_OF(cindex[1], 0, 7), // 57
191 QCELP_OF(cbsign[1], 0, 1), // 50
192 QCELP_OF(cbgain[1], 0, 4), // 49
193 QCELP_OF(pfrac [1], 0, 1), // 45
194 QCELP_OF(plag [1], 6, 1), // 44
195 QCELP_OF(cindex[2], 0, 2), // 43
196 QCELP_OF(cbsign[2], 0, 1), // 41
197 QCELP_OF(cbgain[2], 0, 4), // 40
198 QCELP_OF(pfrac [2], 0, 1), // 36
199 QCELP_OF(plag [2], 0, 7), // 35
200 QCELP_OF(pgain [2], 2, 1), // 28
201 QCELP_OF(pfrac [3], 0, 1), // 27
202 QCELP_OF(plag [3], 0, 7), // 26
203 QCELP_OF(pgain [3], 0, 3), // 19
204 QCELP_OF(cindex[2], 2, 5), // 16
205 QCELP_OF(cindex[3], 0, 7), // 11
206 QCELP_OF(cbsign[3], 0, 1), // 4
207 QCELP_OF(cbgain[3], 0, 4) // 3
211 * bitmap unpacking tables for RATE_QUARTER
213 * TIA/EIA/IS-733 Table 2.4.7.3-1
215 static const QCELPBitmap qcelp_rate_quarter_bitmap[] = {
217 QCELP_OF(lspv [2], 0, 3), // 53
218 QCELP_OF(lspv [1], 0, 7), // 50
219 QCELP_OF(lspv [0], 0, 6), // 43
220 QCELP_OF(lspv [4], 0, 6), // 37
221 QCELP_OF(lspv [3], 0, 6), // 31
222 QCELP_OF(lspv [2], 3, 4), // 25
223 QCELP_OF(cbgain[3], 0, 4), // 21
224 QCELP_OF(cbgain[2], 0, 4), // 17
225 QCELP_OF(cbgain[1], 0, 4), // 13
226 QCELP_OF(cbgain[0], 0, 4), // 9
227 QCELP_OF(reserved, 0, 2), // 5
228 QCELP_OF(cbgain[4], 0, 4) // 3
232 * bitmap unpacking tables for RATE_OCTAVE
234 * trick: CBSEED is written into QCELPContext.cbsign[15],
235 * which is not used for RATE_OCTAVE.
236 * CBSEED is only used to ensure the occurrence of random bit
237 * patterns in the 16 first bits that are used as the seed.
239 * TIA/EIA/IS-733 Table 2.4.7.4-1
241 static const QCELPBitmap qcelp_rate_octave_bitmap[] = {
243 QCELP_OF(cbsign[15], 3, 1), // 19
244 QCELP_OF(lspv [0], 0, 1), // 18
245 QCELP_OF(lspv [1], 0, 1), // 17
246 QCELP_OF(lspv [2], 0, 1), // 16
247 QCELP_OF(cbsign[15], 2, 1), // 15
248 QCELP_OF(lspv [3], 0, 1), // 14
249 QCELP_OF(lspv [4], 0, 1), // 13
250 QCELP_OF(lspv [5], 0, 1), // 12
251 QCELP_OF(cbsign[15], 1, 1), // 11
252 QCELP_OF(lspv [6], 0, 1), // 10
253 QCELP_OF(lspv [7], 0, 1), // 9
254 QCELP_OF(lspv [8], 0, 1), // 8
255 QCELP_OF(cbsign[15], 0, 1), // 7
256 QCELP_OF(lspv [9], 0, 1), // 6
257 QCELP_OF(cbgain [0], 0, 2), // 7
258 QCELP_OF(reserved, 0, 4) // 3
262 * position of the bitmapping data for each packet type in
265 static const QCELPBitmap * const qcelp_unpacking_bitmaps_per_rate[5] = {
266 NULL, ///!< for SILENCE rate
267 qcelp_rate_octave_bitmap,
268 qcelp_rate_quarter_bitmap,
269 qcelp_rate_half_bitmap,
270 qcelp_rate_full_bitmap,
273 static const uint16_t qcelp_unpacking_bitmaps_lengths[5] = {
274 0, ///!< for SILENCE rate
275 FF_ARRAY_ELEMS(qcelp_rate_octave_bitmap),
276 FF_ARRAY_ELEMS(qcelp_rate_quarter_bitmap),
277 FF_ARRAY_ELEMS(qcelp_rate_half_bitmap),
278 FF_ARRAY_ELEMS(qcelp_rate_full_bitmap),
282 typedef uint16_t qcelp_vector[2];
285 * LSP vector quantization tables in x*10000 form
287 * TIA/EIA/IS-733 tables 2.4.3.2.6.3-1 through 2.4.3.2.6.3-5
290 static const qcelp_vector qcelp_lspvq1[64]= {
291 { 327, 118},{ 919, 111},{ 427, 440},{1327, 185},
292 { 469, 50},{1272, 91},{ 892, 59},{1771, 193},
293 { 222, 158},{1100, 127},{ 827, 55},{ 978, 791},
294 { 665, 47},{ 700,1401},{ 670, 859},{1913,1048},
295 { 471, 215},{1046, 125},{ 645, 298},{1599, 160},
296 { 593, 39},{1187, 462},{ 749, 341},{1520, 511},
297 { 290, 792},{ 909, 362},{ 753, 81},{1111,1058},
298 { 519, 253},{ 828, 839},{ 685, 541},{1421,1258},
299 { 386, 130},{ 962, 119},{ 542, 387},{1431, 185},
300 { 526, 51},{1175, 260},{ 831, 167},{1728, 510},
301 { 273, 437},{1172, 113},{ 771, 144},{1122, 751},
302 { 619, 119},{ 492,1276},{ 658, 695},{1882, 615},
303 { 415, 200},{1018, 88},{ 681, 339},{1436, 325},
304 { 555, 122},{1042, 485},{ 826, 345},{1374, 743},
305 { 383,1018},{1005, 358},{ 704, 86},{1301, 586},
306 { 597, 241},{ 832, 621},{ 555, 573},{1504, 839}};
308 static const qcelp_vector qcelp_lspvq2[128]= {
309 { 255, 293},{ 904, 219},{ 151,1211},{1447, 498},
310 { 470, 253},{1559, 177},{1547, 994},{2394, 242},
311 { 91, 813},{ 857, 590},{ 934,1326},{1889, 282},
312 { 813, 472},{1057,1494},{ 450,3315},{2163,1895},
313 { 538, 532},{1399, 218},{ 146,1552},{1755, 626},
314 { 822, 202},{1299, 663},{ 706,1732},{2656, 401},
315 { 418, 745},{ 762,1038},{ 583,1748},{1746,1285},
316 { 527,1169},{1314, 830},{ 556,2116},{1073,2321},
317 { 297, 570},{ 981, 403},{ 468,1103},{1740, 243},
318 { 725, 179},{1255, 474},{1374,1362},{1922, 912},
319 { 285, 947},{ 930, 700},{ 593,1372},{1909, 576},
320 { 588, 916},{1110,1116},{ 224,2719},{1633,2220},
321 { 402, 520},{1061, 448},{ 402,1352},{1499, 775},
322 { 664, 589},{1081, 727},{ 801,2206},{2165,1157},
323 { 566, 802},{ 911,1116},{ 306,1703},{1792, 836},
324 { 655, 999},{1061,1038},{ 298,2089},{1110,1753},
325 { 361, 311},{ 970, 239},{ 265,1231},{1495, 573},
326 { 566, 262},{1569, 293},{1341,1144},{2271, 544},
327 { 214, 877},{ 847, 719},{ 794,1384},{2067, 274},
328 { 703, 688},{1099,1306},{ 391,2947},{2024,1670},
329 { 471, 525},{1245, 290},{ 264,1557},{1568, 807},
330 { 718, 399},{1193, 685},{ 883,1594},{2729, 764},
331 { 500, 754},{ 809,1108},{ 541,1648},{1523,1385},
332 { 614,1196},{1209, 847},{ 345,2242},{1442,1747},
333 { 199, 560},{1092, 194},{ 349,1253},{1653, 507},
334 { 625, 354},{1376, 431},{1187,1465},{2164, 872},
335 { 360, 974},{1008, 698},{ 704,1346},{2114, 452},
336 { 720, 816},{1240,1089},{ 439,2475},{1498,2040},
337 { 336, 718},{1213, 187},{ 451,1450},{1368, 885},
338 { 592, 578},{1131, 531},{ 861,1855},{1764,1500},
339 { 444, 970},{ 935, 903},{ 424,1687},{1633,1102},
340 { 793, 897},{1060, 897},{ 185,2011},{1205,1855}};
342 static const qcelp_vector qcelp_lspvq3[128]= {
343 { 225, 283},{1296, 355},{ 543, 343},{2073, 274},
344 { 204,1099},{1562, 523},{1388, 161},{2784, 274},
345 { 112, 849},{1870, 175},{1189, 160},{1490,1088},
346 { 969,1115},{ 659,3322},{1158,1073},{3183,1363},
347 { 517, 223},{1740, 223},{ 704, 387},{2637, 234},
348 { 692,1005},{1287,1610},{ 952, 532},{2393, 646},
349 { 490, 552},{1619, 657},{ 845, 670},{1784,2280},
350 { 191,1775},{ 272,2868},{ 942, 952},{2628,1479},
351 { 278, 579},{1565, 218},{ 814, 180},{2379, 187},
352 { 276,1444},{1199,1223},{1200, 349},{3009, 307},
353 { 312, 844},{1898, 306},{ 863, 470},{1685,1241},
354 { 513,1727},{ 711,2233},{1085, 864},{3398, 527},
355 { 414, 440},{1356, 612},{ 964, 147},{2173, 738},
356 { 465,1292},{ 877,1749},{1104, 689},{2105,1311},
357 { 580, 864},{1895, 752},{ 652, 609},{1485,1699},
358 { 514,1400},{ 386,2131},{ 933, 798},{2473, 986},
359 { 334, 360},{1375, 398},{ 621, 276},{2183, 280},
360 { 311,1114},{1382, 807},{1284, 175},{2605, 636},
361 { 230, 816},{1739, 408},{1074, 176},{1619,1120},
362 { 784,1371},{ 448,3050},{1189, 880},{3039,1165},
363 { 424, 241},{1672, 186},{ 815, 333},{2432, 324},
364 { 584,1029},{1137,1546},{1015, 585},{2198, 995},
365 { 574, 581},{1746, 647},{ 733, 740},{1938,1737},
366 { 347,1710},{ 373,2429},{ 787,1061},{2439,1438},
367 { 185, 536},{1489, 178},{ 703, 216},{2178, 487},
368 { 154,1421},{1414, 994},{1103, 352},{3072, 473},
369 { 408, 819},{2055, 168},{ 998, 354},{1917,1140},
370 { 665,1799},{ 993,2213},{1234, 631},{3003, 762},
371 { 373, 620},{1518, 425},{ 913, 300},{1966, 836},
372 { 402,1185},{ 948,1385},{1121, 555},{1802,1509},
373 { 474, 886},{1888, 610},{ 739, 585},{1231,2379},
374 { 661,1335},{ 205,2211},{ 823, 822},{2480,1179}};
376 static const qcelp_vector qcelp_lspvq4[64]= {
377 { 348, 311},{ 812,1145},{ 552, 461},{1826, 263},
378 { 601, 675},{1730, 172},{1523, 193},{2449, 277},
379 { 334, 668},{ 805,1441},{1319, 207},{1684, 910},
380 { 582,1318},{1403,1098},{ 979, 832},{2700,1359},
381 { 624, 228},{1292, 979},{ 800, 195},{2226, 285},
382 { 730, 862},{1537, 601},{1115, 509},{2720, 354},
383 { 218,1167},{1212,1538},{1074, 247},{1674,1710},
384 { 322,2142},{1263, 777},{ 981, 556},{2119,1710},
385 { 193, 596},{1035, 957},{ 694, 397},{1997, 253},
386 { 743, 603},{1584, 321},{1346, 346},{2221, 708},
387 { 451, 732},{1040,1415},{1184, 230},{1853, 919},
388 { 310,1661},{1625, 706},{ 856, 843},{2902, 702},
389 { 467, 348},{1108,1048},{ 859, 306},{1964, 463},
390 { 560,1013},{1425, 533},{1142, 634},{2391, 879},
391 { 397,1084},{1345,1700},{ 976, 248},{1887,1189},
392 { 644,2087},{1262, 603},{ 877, 550},{2203,1307}};
394 static const qcelp_vector qcelp_lspvq5[64]= {
395 { 360, 222},{ 820,1097},{ 601, 319},{1656, 198},
396 { 604, 513},{1552, 141},{1391, 155},{2474, 261},
397 { 269, 785},{1463, 646},{1123, 191},{2015, 223},
398 { 785, 844},{1202,1011},{ 980, 807},{3014, 793},
399 { 570, 180},{1135,1382},{ 778, 256},{1901, 179},
400 { 807, 622},{1461, 458},{1231, 178},{2028, 821},
401 { 387, 927},{1496,1004},{ 888, 392},{2246, 341},
402 { 295,1462},{1156, 694},{1022, 473},{2226,1364},
403 { 210, 478},{1029,1020},{ 722, 181},{1730, 251},
404 { 730, 488},{1465, 293},{1303, 326},{2595, 387},
405 { 458, 584},{1569, 742},{1029, 173},{1910, 495},
406 { 605,1159},{1268, 719},{ 973, 646},{2872, 428},
407 { 443, 334},{ 835,1465},{ 912, 138},{1716, 442},
408 { 620, 778},{1316, 450},{1186, 335},{1446,1665},
409 { 486,1050},{1675,1019},{ 880, 278},{2214, 202},
410 { 539,1564},{1142, 533},{ 984, 391},{2130,1089}};
412 static const qcelp_vector * const qcelp_lspvq[5] = {
421 * the final gain scalefactor before clipping into a usable output float
423 #define QCELP_SCALE 8192.
426 * the upper boundary of the clipping, depends on QCELP_SCALE
428 #define QCELP_CLIP_UPPER_BOUND (8191.75/8192.)
431 * the lower boundary of the clipping, depends on QCELP_SCALE
433 #define QCELP_CLIP_LOWER_BOUND -1.
436 * table for computing Ga (decoded linear codebook gain magnitude)
438 * @note The table could fit in int16_t in x*8 form, but it seems
439 * to be slower on x86
441 * TIA/EIA/IS-733 2.4.6.2.1-3
444 static const float qcelp_g12ga[61] = {
445 1.000/QCELP_SCALE, 1.125/QCELP_SCALE, 1.250/QCELP_SCALE, 1.375/QCELP_SCALE,
446 1.625/QCELP_SCALE, 1.750/QCELP_SCALE, 2.000/QCELP_SCALE, 2.250/QCELP_SCALE,
447 2.500/QCELP_SCALE, 2.875/QCELP_SCALE, 3.125/QCELP_SCALE, 3.500/QCELP_SCALE,
448 4.000/QCELP_SCALE, 4.500/QCELP_SCALE, 5.000/QCELP_SCALE, 5.625/QCELP_SCALE,
449 6.250/QCELP_SCALE, 7.125/QCELP_SCALE, 8.000/QCELP_SCALE, 8.875/QCELP_SCALE,
450 10.000/QCELP_SCALE, 11.250/QCELP_SCALE, 12.625/QCELP_SCALE, 14.125/QCELP_SCALE,
451 15.875/QCELP_SCALE, 17.750/QCELP_SCALE, 20.000/QCELP_SCALE, 22.375/QCELP_SCALE,
452 25.125/QCELP_SCALE, 28.125/QCELP_SCALE, 31.625/QCELP_SCALE, 35.500/QCELP_SCALE,
453 39.750/QCELP_SCALE, 44.625/QCELP_SCALE, 50.125/QCELP_SCALE, 56.250/QCELP_SCALE,
454 63.125/QCELP_SCALE, 70.750/QCELP_SCALE, 79.375/QCELP_SCALE, 89.125/QCELP_SCALE,
455 100.000/QCELP_SCALE, 112.250/QCELP_SCALE, 125.875/QCELP_SCALE, 141.250/QCELP_SCALE,
456 158.500/QCELP_SCALE, 177.875/QCELP_SCALE, 199.500/QCELP_SCALE, 223.875/QCELP_SCALE,
457 251.250/QCELP_SCALE, 281.875/QCELP_SCALE, 316.250/QCELP_SCALE, 354.875/QCELP_SCALE,
458 398.125/QCELP_SCALE, 446.625/QCELP_SCALE, 501.125/QCELP_SCALE, 562.375/QCELP_SCALE,
459 631.000/QCELP_SCALE, 708.000/QCELP_SCALE, 794.375/QCELP_SCALE, 891.250/QCELP_SCALE,
460 1000.000/QCELP_SCALE};
463 * circular codebook for rate 1 frames in x*100 form
465 * TIA/EIA/IS-733 2.4.6.1-2
467 static const int16_t qcelp_rate_full_codebook[128] = {
468 10, -65, -59, 12, 110, 34, -134, 157,
469 104, -84, -34, -115, 23, -101, 3, 45,
470 -101, -16, -59, 28, -45, 134, -67, 22,
471 61, -29, 226, -26, -55, -179, 157, -51,
472 -220, -93, -37, 60, 118, 74, -48, -95,
473 -181, 111, 36, -52, -215, 78, -112, 39,
474 -17, -47, -223, 19, 12, -98, -142, 130,
475 54, -127, 21, -12, 39, -48, 12, 128,
476 6, -167, 82, -102, -79, 55, -44, 48,
477 -20, -53, 8, -61, 11, -70, -157, -168,
478 20, -56, -74, 78, 33, -63, -173, -2,
479 -75, -53, -146, 77, 66, -29, 9, -75,
480 65, 119, -43, 76, 233, 98, 125, -156,
481 -27, 78, -9, 170, 176, 143, -148, -7,
482 27, -136, 5, 27, 18, 139, 204, 7,
483 -184, -197, 52, -3, 78, -189, 8, -65
485 #define QCELP_RATE_FULL_CODEBOOK_RATIO .01
488 * circular codebook for rate 1/2 frames in x*2 form
490 * TIA/EIA/IS-733 2.4.6.1-1
492 static const int8_t qcelp_rate_half_codebook[128] = {
493 0, -4, 0, -3, 0, 0, 0, 0,
494 0, 0, 0, 0, 0, 0, 0, 0,
495 0, -3, -2, 0, 0, 0, 0, 0,
496 0, 0, 0, 0, 0, 0, 0, 5,
497 0, 0, 0, 0, 0, 0, 4, 0,
498 0, 3, 2, 0, 3, 4, 0, 0,
499 0, 0, 0, 0, 0, 0, 0, 0,
500 0, 0, 0, 0, 0, 3, 0, 0,
501 -3, 3, 0, 0, -2, 0, 3, 0,
502 0, 0, 0, 0, 0, 0, -5, 0,
503 0, 0, 0, 3, 0, 0, 0, 3,
504 0, 0, 0, 0, 0, 0, 0, 4,
505 0, 0, 0, 0, 0, 0, 0, 0,
506 0, 3, 6, -3, -4, 0, -3, -3,
507 3, -3, 0, 0, 0, 0, 0, 0,
508 0, 0, 0, 0, 0, 0, 0, 0
510 #define QCELP_RATE_HALF_CODEBOOK_RATIO 0.5
513 * sqrt(1.887) is the maximum of the pseudorandom
514 * white sequence used to generate the scaled codebook
515 * vector for bitrate 1/4.
517 * TIA/EIA/IS-733 2.4.8.1.2
519 #define QCELP_SQRT1887 1.373681186
522 * table for impulse response of BPF used to filter
523 * the white excitation for bitrate 1/4 synthesis
525 * Only half the tables are needed because of symmetry.
527 * TIA/EIA/IS-733 2.4.8.1.2-1.1
529 static const double qcelp_rnd_fir_coefs[11] = {
530 -1.344519e-1, 1.735384e-2, -6.905826e-2, 2.434368e-2,
531 -8.210701e-2, 3.041388e-2, -9.251384e-2, 3.501983e-2,
532 -9.918777e-2, 3.749518e-2, 8.985137e-1
536 * This spread factor is used, for bitrate 1/8 and I_F_Q,
537 * to force the LSP frequencies to be at least 80 Hz apart.
539 * TIA/EIA/IS-733 2.4.3.3.2
541 #define QCELP_LSP_SPREAD_FACTOR 0.02
544 * predictor coefficient for the conversion of LSP codes
545 * to LSP frequencies for 1/8 and I_F_Q
547 * TIA/EIA/IS-733 2.4.3.2.7-2
549 #define QCELP_LSP_OCTAVE_PREDICTOR 29.0/32
551 #endif /* AVCODEC_QCELPDATA_H */