Statistics
| Branch: | Revision:

ffmpeg / libavcodec / qcelpdata.h @ 88df35d3

History | View | Annotate | Download (14.1 KB)

1
/*
2
 * part of QCELP decoder
3
 * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
4
 *
5
 * This file is part of FFmpeg.
6
 *
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.
11
 *
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.
16
 *
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
20
 */
21

    
22
#ifndef AVCODEC_QCELPDATA_H
23
#define AVCODEC_QCELPDATA_H
24

    
25
#include <stdint.h>
26

    
27
/**
28
 * pre-calculated table for hammsinc function
29
 * Only half of the table is needed because of symmetry.
30
 *
31
 * TIA/EIA/IS-733 2.4.5.2-2/3
32
 */
33
static const float qcelp_hammsinc_table[4] = { -0.006822,  0.041249, -0.143459,  0.588863};
34

    
35
typedef struct {
36
    uint8_t index;  /*!< index into the QCELPContext structure */
37
    uint8_t bitpos; /*!< position of the lowest bit in the value's byte */
38
    uint8_t bitlen; /*!< number of bits to read */
39
} QCELPBitmap;
40

    
41
#define QCELP_OF(variable, bit, len) {offsetof(QCELPContext, variable), bit, len}
42

    
43
/**
44
 * bitmap unpacking tables for RATE_FULL
45
 *
46
 * TIA/EIA/IS-733 Table 2.4.7.1-1
47
 */
48
static const QCELPBitmap qcelp_rate_full_bitmap[] = {
49
                                // start on bit
50
    QCELP_OF(lspv  [ 2], 0, 3), // 265
51
    QCELP_OF(lspv  [ 1], 0, 7), // 262
52
    QCELP_OF(lspv  [ 0], 0, 6), // 255
53
    QCELP_OF(lspv  [ 4], 0, 6), // 249
54
    QCELP_OF(lspv  [ 3], 0, 6), // 243
55
    QCELP_OF(lspv  [ 2], 3, 4), // 237
56
    QCELP_OF(cbsign[ 0], 0, 1), // 233
57
    QCELP_OF(cbgain[ 0], 0, 4), // 232
58
    QCELP_OF(pfrac [ 0], 0, 1), // 228
59
    QCELP_OF(plag  [ 0], 0, 7), // 227
60
    QCELP_OF(pgain [ 0], 0, 3), // 220
61
    QCELP_OF(cindex[ 1], 0, 4), // 217
62
    QCELP_OF(cbsign[ 1], 0, 1), // 213
63
    QCELP_OF(cbgain[ 1], 0, 4), // 212
64
    QCELP_OF(cindex[ 0], 0, 7), // 208
65
    QCELP_OF(cbgain[ 3], 0, 1), // 201
66
    QCELP_OF(cindex[ 2], 0, 7), // 200
67
    QCELP_OF(cbsign[ 2], 0, 1), // 193
68
    QCELP_OF(cbgain[ 2], 0, 4), // 192
69
    QCELP_OF(cindex[ 1], 4, 3), // 188
70
    QCELP_OF(plag  [ 1], 0, 3), // 185
71
    QCELP_OF(pgain [ 1], 0, 3), // 182
72
    QCELP_OF(cindex[ 3], 0, 7), // 179
73
    QCELP_OF(cbsign[ 3], 0, 1), // 172
74
    QCELP_OF(cbgain[ 3], 1, 2), // 171
75
    QCELP_OF(cindex[ 4], 0, 6), // 169
76
    QCELP_OF(cbsign[ 4], 0, 1), // 163
77
    QCELP_OF(cbgain[ 4], 0, 4), // 162
78
    QCELP_OF(pfrac [ 1], 0, 1), // 158
79
    QCELP_OF(plag  [ 1], 3, 4), // 157
80
    QCELP_OF(cbgain[ 6], 0, 3), // 153
81
    QCELP_OF(cindex[ 5], 0, 7), // 150
82
    QCELP_OF(cbsign[ 5], 0, 1), // 143
83
    QCELP_OF(cbgain[ 5], 0, 4), // 142
84
    QCELP_OF(cindex[ 4], 6, 1), // 138
85
    QCELP_OF(cindex[ 7], 0, 3), // 137
86
    QCELP_OF(cbsign[ 7], 0, 1), // 134
87
    QCELP_OF(cbgain[ 7], 0, 3), // 133
88
    QCELP_OF(cindex[ 6], 0, 7), // 130
89
    QCELP_OF(cbsign[ 6], 0, 1), // 123
90
    QCELP_OF(cbgain[ 6], 3, 1), // 122
91
    QCELP_OF(cbgain[ 8], 0, 1), // 121
92
    QCELP_OF(pfrac [ 2], 0, 1), // 120
93
    QCELP_OF(plag  [ 2], 0, 7), // 119
94
    QCELP_OF(pgain [ 2], 0, 3), // 112
95
    QCELP_OF(cindex[ 7], 3, 4), // 109
96
    QCELP_OF(cbsign[ 9], 0, 1), // 105
97
    QCELP_OF(cbgain[ 9], 0, 4), // 104
98
    QCELP_OF(cindex[ 8], 0, 7), // 100
99
    QCELP_OF(cbsign[ 8], 0, 1), //  93
100
    QCELP_OF(cbgain[ 8], 1, 3), //  92
101
    QCELP_OF(cindex[10], 0, 4), //  89
102
    QCELP_OF(cbsign[10], 0, 1), //  85
103
    QCELP_OF(cbgain[10], 0, 4), //  84
104
    QCELP_OF(cindex[ 9], 0, 7), //  80
105
    QCELP_OF(pgain [ 3], 0, 2), //  73
106
    QCELP_OF(cindex[11], 0, 7), //  71
107
    QCELP_OF(cbsign[11], 0, 1), //  64
108
    QCELP_OF(cbgain[11], 0, 3), //  63
109
    QCELP_OF(cindex[10], 4, 3), //  60
110
    QCELP_OF(cindex[12], 0, 2), //  57
111
    QCELP_OF(cbsign[12], 0, 1), //  55
112
    QCELP_OF(cbgain[12], 0, 4), //  54
113
    QCELP_OF(pfrac [ 3], 0, 1), //  50
114
    QCELP_OF(plag  [ 3], 0, 7), //  49
115
    QCELP_OF(pgain [ 3], 2, 1), //  42
116
    QCELP_OF(cindex[13], 0, 6), //  41
117
    QCELP_OF(cbsign[13], 0, 1), //  35
118
    QCELP_OF(cbgain[13], 0, 4), //  34
119
    QCELP_OF(cindex[12], 2, 5), //  30
120
    QCELP_OF(cbgain[15], 0, 3), //  25
121
    QCELP_OF(cindex[14], 0, 7), //  22
122
    QCELP_OF(cbsign[14], 0, 1), //  15
123
    QCELP_OF(cbgain[14], 0, 4), //  14
124
    QCELP_OF(cindex[13], 6, 1), //  10
125
    QCELP_OF(reserved,   0, 2), //   9
126
    QCELP_OF(cindex[15], 0, 7), //   7
127
    QCELP_OF(cbsign[15], 0, 1)  //   0
128
};
129

    
130
/**
131
 * bitmap unpacking tables for RATE_HALF
132
 *
133
 * TIA/EIA/IS-733 Table 2.4.7.2-1
134
 */
135
static const QCELPBitmap qcelp_rate_half_bitmap[] = {
136
                               // start on bit
137
    QCELP_OF(lspv  [2], 0, 3), // 123
138
    QCELP_OF(lspv  [1], 0, 7), // 120
139
    QCELP_OF(lspv  [0], 0, 6), // 113
140
    QCELP_OF(lspv  [4], 0, 6), // 107
141
    QCELP_OF(lspv  [3], 0, 6), // 101
142
    QCELP_OF(lspv  [2], 3, 4), //  95
143
    QCELP_OF(cbsign[0], 0, 1), //  91
144
    QCELP_OF(cbgain[0], 0, 4), //  90
145
    QCELP_OF(pfrac [0], 0, 1), //  86
146
    QCELP_OF(plag  [0], 0, 7), //  85
147
    QCELP_OF(pgain [0], 0, 3), //  78
148
    QCELP_OF(plag  [1], 0, 6), //  75
149
    QCELP_OF(pgain [1], 0, 3), //  69
150
    QCELP_OF(cindex[0], 0, 7), //  66
151
    QCELP_OF(pgain [2], 0, 2), //  59
152
    QCELP_OF(cindex[1], 0, 7), //  57
153
    QCELP_OF(cbsign[1], 0, 1), //  50
154
    QCELP_OF(cbgain[1], 0, 4), //  49
155
    QCELP_OF(pfrac [1], 0, 1), //  45
156
    QCELP_OF(plag  [1], 6, 1), //  44
157
    QCELP_OF(cindex[2], 0, 2), //  43
158
    QCELP_OF(cbsign[2], 0, 1), //  41
159
    QCELP_OF(cbgain[2], 0, 4), //  40
160
    QCELP_OF(pfrac [2], 0, 1), //  36
161
    QCELP_OF(plag  [2], 0, 7), //  35
162
    QCELP_OF(pgain [2], 2, 1), //  28
163
    QCELP_OF(pfrac [3], 0, 1), //  27
164
    QCELP_OF(plag  [3], 0, 7), //  26
165
    QCELP_OF(pgain [3], 0, 3), //  19
166
    QCELP_OF(cindex[2], 2, 5), //  16
167
    QCELP_OF(cindex[3], 0, 7), //  11
168
    QCELP_OF(cbsign[3], 0, 1), //   4
169
    QCELP_OF(cbgain[3], 0, 4)  //   3
170
};
171

    
172
/**
173
 * bitmap unpacking tables for RATE_QUARTER
174
 *
175
 * TIA/EIA/IS-733 Table 2.4.7.3-1
176
 */
177
static const QCELPBitmap qcelp_rate_quarter_bitmap[] = {
178
                               // start on bit
179
    QCELP_OF(lspv  [2], 0, 3), // 53
180
    QCELP_OF(lspv  [1], 0, 7), // 50
181
    QCELP_OF(lspv  [0], 0, 6), // 43
182
    QCELP_OF(lspv  [4], 0, 6), // 37
183
    QCELP_OF(lspv  [3], 0, 6), // 31
184
    QCELP_OF(lspv  [2], 3, 4), // 25
185
    QCELP_OF(cbgain[3], 0, 4), // 21
186
    QCELP_OF(cbgain[2], 0, 4), // 17
187
    QCELP_OF(cbgain[1], 0, 4), // 13
188
    QCELP_OF(cbgain[0], 0, 4), //  9
189
    QCELP_OF(reserved,  0, 2), //  5
190
    QCELP_OF(cbgain[4], 0, 4)  //  3
191
};
192

    
193
/**
194
 * bitmap unpacking tables for RATE_OCTAVE
195
 *
196
 * trick: CBSEED is written into QCELPContext.cbsign[15],
197
 * which is not used for RATE_OCTAVE.
198
 * CBSEED is only used to ensure the occurrence of random bit
199
 * patterns in the 16 first bits that are used as the seed.
200
 *
201
 * TIA/EIA/IS-733 Table 2.4.7.4-1
202
 */
203
static const QCELPBitmap qcelp_rate_octave_bitmap[] = {
204
                                // start on bit
205
    QCELP_OF(cbsign[15], 3, 1), // 19
206
    QCELP_OF(lspv   [0], 0, 1), // 18
207
    QCELP_OF(lspv   [1], 0, 1), // 17
208
    QCELP_OF(lspv   [2], 0, 1), // 16
209
    QCELP_OF(cbsign[15], 2, 1), // 15
210
    QCELP_OF(lspv   [3], 0, 1), // 14
211
    QCELP_OF(lspv   [4], 0, 1), // 13
212
    QCELP_OF(lspv   [5], 0, 1), // 12
213
    QCELP_OF(cbsign[15], 1, 1), // 11
214
    QCELP_OF(lspv   [6], 0, 1), // 10
215
    QCELP_OF(lspv   [7], 0, 1), //  9
216
    QCELP_OF(lspv   [8], 0, 1), //  8
217
    QCELP_OF(cbsign[15], 0, 1), //  7
218
    QCELP_OF(lspv   [9], 0, 1), //  6
219
    QCELP_OF(cbgain [0], 0, 2), //  7
220
    QCELP_OF(reserved,   0, 4)  //  3
221
};
222

    
223
/**
224
 * position of the bitmapping data for each packet type in
225
 * the QCELPContext
226
 */
227
static const QCELPBitmap * const qcelp_unpacking_bitmaps_per_rate[5] = {
228
    NULL,                     ///!< for SILENCE rate
229
    qcelp_rate_octave_bitmap,
230
    qcelp_rate_quarter_bitmap,
231
    qcelp_rate_half_bitmap,
232
    qcelp_rate_full_bitmap,
233
};
234

    
235
static const uint16_t qcelp_bits_per_rate[5] = {
236
    0, ///!< for SILENCE rate
237
    FF_ARRAY_ELEMS(qcelp_rate_octave_bitmap),
238
    FF_ARRAY_ELEMS(qcelp_rate_quarter_bitmap),
239
    FF_ARRAY_ELEMS(qcelp_rate_half_bitmap),
240
    FF_ARRAY_ELEMS(qcelp_rate_full_bitmap),
241
};
242

    
243
typedef uint16_t qcelp_vector[2];
244

    
245
/**
246
 * LSP vector quantization tables in x*10000 form
247
 *
248
 * TIA/EIA/IS-733 tables 2.4.3.2.6.3-1 through 2.4.3.2.6.3-5
249
 */
250

    
251
static const qcelp_vector qcelp_lspvq1[64]= {
252
{ 327, 118},{ 919, 111},{ 427, 440},{1327, 185},
253
{ 469,  50},{1272,  91},{ 892,  59},{1771, 193},
254
{ 222, 158},{1100, 127},{ 827,  55},{ 978, 791},
255
{ 665,  47},{ 700,1401},{ 670, 859},{1913,1048},
256
{ 471, 215},{1046, 125},{ 645, 298},{1599, 160},
257
{ 593,  39},{1187, 462},{ 749, 341},{1520, 511},
258
{ 290, 792},{ 909, 362},{ 753,  81},{1111,1058},
259
{ 519, 253},{ 828, 839},{ 685, 541},{1421,1258},
260
{ 386, 130},{ 962, 119},{ 542, 387},{1431, 185},
261
{ 526,  51},{1175, 260},{ 831, 167},{1728, 510},
262
{ 273, 437},{1172, 113},{ 771, 144},{1122, 751},
263
{ 619, 119},{ 492,1276},{ 658, 695},{1882, 615},
264
{ 415, 200},{1018,  88},{ 681, 339},{1436, 325},
265
{ 555, 122},{1042, 485},{ 826, 345},{1374, 743},
266
{ 383,1018},{1005, 358},{ 704,  86},{1301, 586},
267
{ 597, 241},{ 832, 621},{ 555, 573},{1504, 839}};
268

    
269
static const qcelp_vector qcelp_lspvq2[128]= {
270
{ 255, 293},{ 904, 219},{ 151,1211},{1447, 498},
271
{ 470, 253},{1559, 177},{1547, 994},{2394, 242},
272
{  91, 813},{ 857, 590},{ 934,1326},{1889, 282},
273
{ 813, 472},{1057,1494},{ 450,3315},{2163,1895},
274
{ 538, 532},{1399, 218},{ 146,1552},{1755, 626},
275
{ 822, 202},{1299, 663},{ 706,1732},{2656, 401},
276
{ 418, 745},{ 762,1038},{ 583,1748},{1746,1285},
277
{ 527,1169},{1314, 830},{ 556,2116},{1073,2321},
278
{ 297, 570},{ 981, 403},{ 468,1103},{1740, 243},
279
{ 725, 179},{1255, 474},{1374,1362},{1922, 912},
280
{ 285, 947},{ 930, 700},{ 593,1372},{1909, 576},
281
{ 588, 916},{1110,1116},{ 224,2719},{1633,2220},
282
{ 402, 520},{1061, 448},{ 402,1352},{1499, 775},
283
{ 664, 589},{1081, 727},{ 801,2206},{2165,1157},
284
{ 566, 802},{ 911,1116},{ 306,1703},{1792, 836},
285
{ 655, 999},{1061,1038},{ 298,2089},{1110,1753},
286
{ 361, 311},{ 970, 239},{ 265,1231},{1495, 573},
287
{ 566, 262},{1569, 293},{1341,1144},{2271, 544},
288
{ 214, 877},{ 847, 719},{ 794,1384},{2067, 274},
289
{ 703, 688},{1099,1306},{ 391,2947},{2024,1670},
290
{ 471, 525},{1245, 290},{ 264,1557},{1568, 807},
291
{ 718, 399},{1193, 685},{ 883,1594},{2729, 764},
292
{ 500, 754},{ 809,1108},{ 541,1648},{1523,1385},
293
{ 614,1196},{1209, 847},{ 345,2242},{1442,1747},
294
{ 199, 560},{1092, 194},{ 349,1253},{1653, 507},
295
{ 625, 354},{1376, 431},{1187,1465},{2164, 872},
296
{ 360, 974},{1008, 698},{ 704,1346},{2114, 452},
297
{ 720, 816},{1240,1089},{ 439,2475},{1498,2040},
298
{ 336, 718},{1213, 187},{ 451,1450},{1368, 885},
299
{ 592, 578},{1131, 531},{ 861,1855},{1764,1500},
300
{ 444, 970},{ 935, 903},{ 424,1687},{1633,1102},
301
{ 793, 897},{1060, 897},{ 185,2011},{1205,1855}};
302

    
303
static const qcelp_vector qcelp_lspvq3[128]= {
304
{ 225, 283},{1296, 355},{ 543, 343},{2073, 274},
305
{ 204,1099},{1562, 523},{1388, 161},{2784, 274},
306
{ 112, 849},{1870, 175},{1189, 160},{1490,1088},
307
{ 969,1115},{ 659,3322},{1158,1073},{3183,1363},
308
{ 517, 223},{1740, 223},{ 704, 387},{2637, 234},
309
{ 692,1005},{1287,1610},{ 952, 532},{2393, 646},
310
{ 490, 552},{1619, 657},{ 845, 670},{1784,2280},
311
{ 191,1775},{ 272,2868},{ 942, 952},{2628,1479},
312
{ 278, 579},{1565, 218},{ 814, 180},{2379, 187},
313
{ 276,1444},{1199,1223},{1200, 349},{3009, 307},
314
{ 312, 844},{1898, 306},{ 863, 470},{1685,1241},
315
{ 513,1727},{ 711,2233},{1085, 864},{3398, 527},
316
{ 414, 440},{1356, 612},{ 964, 147},{2173, 738},
317
{ 465,1292},{ 877,1749},{1104, 689},{2105,1311},
318
{ 580, 864},{1895, 752},{ 652, 609},{1485,1699},
319
{ 514,1400},{ 386,2131},{ 933, 798},{2473, 986},
320
{ 334, 360},{1375, 398},{ 621, 276},{2183, 280},
321
{ 311,1114},{1382, 807},{1284, 175},{2605, 636},
322
{ 230, 816},{1739, 408},{1074, 176},{1619,1120},
323
{ 784,1371},{ 448,3050},{1189, 880},{3039,1165},
324
{ 424, 241},{1672, 186},{ 815, 333},{2432, 324},
325
{ 584,1029},{1137,1546},{1015, 585},{2198, 995},
326
{ 574, 581},{1746, 647},{ 733, 740},{1938,1737},
327
{ 347,1710},{ 373,2429},{ 787,1061},{2439,1438},
328
{ 185, 536},{1489, 178},{ 703, 216},{2178, 487},
329
{ 154,1421},{1414, 994},{1103, 352},{3072, 473},
330
{ 408, 819},{2055, 168},{ 998, 354},{1917,1140},
331
{ 665,1799},{ 993,2213},{1234, 631},{3003, 762},
332
{ 373, 620},{1518, 425},{ 913, 300},{1966, 836},
333
{ 402,1185},{ 948,1385},{1121, 555},{1802,1509},
334
{ 474, 886},{1888, 610},{ 739, 585},{1231,2379},
335
{ 661,1335},{ 205,2211},{ 823, 822},{2480,1179}};
336

    
337
static const qcelp_vector qcelp_lspvq4[64]= {
338
{ 348, 311},{ 812,1145},{ 552, 461},{1826, 263},
339
{ 601, 675},{1730, 172},{1523, 193},{2449, 277},
340
{ 334, 668},{ 805,1441},{1319, 207},{1684, 910},
341
{ 582,1318},{1403,1098},{ 979, 832},{2700,1359},
342
{ 624, 228},{1292, 979},{ 800, 195},{2226, 285},
343
{ 730, 862},{1537, 601},{1115, 509},{2720, 354},
344
{ 218,1167},{1212,1538},{1074, 247},{1674,1710},
345
{ 322,2142},{1263, 777},{ 981, 556},{2119,1710},
346
{ 193, 596},{1035, 957},{ 694, 397},{1997, 253},
347
{ 743, 603},{1584, 321},{1346, 346},{2221, 708},
348
{ 451, 732},{1040,1415},{1184, 230},{1853, 919},
349
{ 310,1661},{1625, 706},{ 856, 843},{2902, 702},
350
{ 467, 348},{1108,1048},{ 859, 306},{1964, 463},
351
{ 560,1013},{1425, 533},{1142, 634},{2391, 879},
352
{ 397,1084},{1345,1700},{ 976, 248},{1887,1189},
353
{ 644,2087},{1262, 603},{ 877, 550},{2203,1307}};
354

    
355
static const qcelp_vector qcelp_lspvq5[64]= {
356
{ 360, 222},{ 820,1097},{ 601, 319},{1656, 198},
357
{ 604, 513},{1552, 141},{1391, 155},{2474, 261},
358
{ 269, 785},{1463, 646},{1123, 191},{2015, 223},
359
{ 785, 844},{1202,1011},{ 980, 807},{3014, 793},
360
{ 570, 180},{1135,1382},{ 778, 256},{1901, 179},
361
{ 807, 622},{1461, 458},{1231, 178},{2028, 821},
362
{ 387, 927},{1496,1004},{ 888, 392},{2246, 341},
363
{ 295,1462},{1156, 694},{1022, 473},{2226,1364},
364
{ 210, 478},{1029,1020},{ 722, 181},{1730, 251},
365
{ 730, 488},{1465, 293},{1303, 326},{2595, 387},
366
{ 458, 584},{1569, 742},{1029, 173},{1910, 495},
367
{ 605,1159},{1268, 719},{ 973, 646},{2872, 428},
368
{ 443, 334},{ 835,1465},{ 912, 138},{1716, 442},
369
{ 620, 778},{1316, 450},{1186, 335},{1446,1665},
370
{ 486,1050},{1675,1019},{ 880, 278},{2214, 202},
371
{ 539,1564},{1142, 533},{ 984, 391},{2130,1089}};
372

    
373
static const qcelp_vector * const qcelp_lspvq[5] = {
374
    qcelp_lspvq1,
375
    qcelp_lspvq2,
376
    qcelp_lspvq3,
377
    qcelp_lspvq4,
378
    qcelp_lspvq5
379
};
380

    
381
#endif /* AVCODEC_QCELPDATA_H */