blob: 22f2acb33062bf21f48196db5aca6da67dd2d17b [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11/******************************************************************
12
13 iLBC Speech Coder ANSI-C Source Code
14
15 constants.c
16
17******************************************************************/
18
Mirko Bonadei06c2aa92018-02-01 15:11:41 +010019#include "modules/audio_coding/codecs/ilbc/constants.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
Timothy Gu31117832020-12-18 22:25:57 -080021#include "modules/audio_coding/codecs/ilbc/defines.h"
22
niklase@google.com470e71d2011-07-07 08:21:25 +000023/* HP Filters {b[0] b[1] b[2] -a[1] -a[2]} */
24
pbos@webrtc.org0946a562013-04-09 00:28:06 +000025const int16_t WebRtcIlbcfix_kHpInCoefs[5] = {3798, -7596, 3798, 7807, -3733};
26const int16_t WebRtcIlbcfix_kHpOutCoefs[5] = {3849, -7699, 3849, 7918, -3833};
niklase@google.com470e71d2011-07-07 08:21:25 +000027
28/* Window in Q11 to window the energies of the 5 choises (3 for 20ms) in the choise for
29 the 80 sample start state
30*/
pbos@webrtc.org0946a562013-04-09 00:28:06 +000031const int16_t WebRtcIlbcfix_kStartSequenceEnrgWin[NSUB_MAX-1]= {
niklase@google.com470e71d2011-07-07 08:21:25 +000032 1638, 1843, 2048, 1843, 1638
33};
34
35/* LP Filter coeffs used for downsampling */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000036const int16_t WebRtcIlbcfix_kLpFiltCoefs[FILTERORDER_DS_PLUS1]= {
niklase@google.com470e71d2011-07-07 08:21:25 +000037 -273, 512, 1297, 1696, 1297, 512, -273
38};
39
40/* Constants used in the LPC calculations */
41
42/* Hanning LPC window (in Q15) */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000043const int16_t WebRtcIlbcfix_kLpcWin[BLOCKL_MAX] = {
niklase@google.com470e71d2011-07-07 08:21:25 +000044 6, 22, 50, 89, 139, 200, 272, 355, 449, 554, 669, 795,
45 932, 1079, 1237, 1405, 1583, 1771, 1969, 2177, 2395, 2622, 2858, 3104,
46 3359, 3622, 3894, 4175, 4464, 4761, 5066, 5379, 5699, 6026, 6361, 6702,
47 7050, 7404, 7764, 8130, 8502, 8879, 9262, 9649, 10040, 10436, 10836, 11240,
48 11647, 12058, 12471, 12887, 13306, 13726, 14148, 14572, 14997, 15423, 15850, 16277,
49 16704, 17131, 17558, 17983, 18408, 18831, 19252, 19672, 20089, 20504, 20916, 21325,
50 21730, 22132, 22530, 22924, 23314, 23698, 24078, 24452, 24821, 25185, 25542, 25893,
51 26238, 26575, 26906, 27230, 27547, 27855, 28156, 28450, 28734, 29011, 29279, 29538,
52 29788, 30029, 30261, 30483, 30696, 30899, 31092, 31275, 31448, 31611, 31764, 31906,
53 32037, 32158, 32268, 32367, 32456, 32533, 32600, 32655, 32700, 32733, 32755, 32767,
54 32767, 32755, 32733, 32700, 32655, 32600, 32533, 32456, 32367, 32268, 32158, 32037,
55 31906, 31764, 31611, 31448, 31275, 31092, 30899, 30696, 30483, 30261, 30029, 29788,
56 29538, 29279, 29011, 28734, 28450, 28156, 27855, 27547, 27230, 26906, 26575, 26238,
57 25893, 25542, 25185, 24821, 24452, 24078, 23698, 23314, 22924, 22530, 22132, 21730,
58 21325, 20916, 20504, 20089, 19672, 19252, 18831, 18408, 17983, 17558, 17131, 16704,
59 16277, 15850, 15423, 14997, 14572, 14148, 13726, 13306, 12887, 12471, 12058, 11647,
60 11240, 10836, 10436, 10040, 9649, 9262, 8879, 8502, 8130, 7764, 7404, 7050,
61 6702, 6361, 6026, 5699, 5379, 5066, 4761, 4464, 4175, 3894, 3622, 3359,
62 3104, 2858, 2622, 2395, 2177, 1969, 1771, 1583, 1405, 1237, 1079, 932,
63 795, 669, 554, 449, 355, 272, 200, 139, 89, 50, 22, 6
64};
65
66/* Asymmetric LPC window (in Q15)*/
pbos@webrtc.org0946a562013-04-09 00:28:06 +000067const int16_t WebRtcIlbcfix_kLpcAsymWin[BLOCKL_MAX] = {
niklase@google.com470e71d2011-07-07 08:21:25 +000068 2, 7, 15, 27, 42, 60, 81, 106, 135, 166, 201, 239,
69 280, 325, 373, 424, 478, 536, 597, 661, 728, 798, 872, 949,
70 1028, 1111, 1197, 1287, 1379, 1474, 1572, 1674, 1778, 1885, 1995, 2108,
71 2224, 2343, 2465, 2589, 2717, 2847, 2980, 3115, 3254, 3395, 3538, 3684,
72 3833, 3984, 4138, 4295, 4453, 4615, 4778, 4944, 5112, 5283, 5456, 5631,
73 5808, 5987, 6169, 6352, 6538, 6725, 6915, 7106, 7300, 7495, 7692, 7891,
74 8091, 8293, 8497, 8702, 8909, 9118, 9328, 9539, 9752, 9966, 10182, 10398,
75 10616, 10835, 11055, 11277, 11499, 11722, 11947, 12172, 12398, 12625, 12852, 13080,
76 13309, 13539, 13769, 14000, 14231, 14463, 14695, 14927, 15160, 15393, 15626, 15859,
77 16092, 16326, 16559, 16792, 17026, 17259, 17492, 17725, 17957, 18189, 18421, 18653,
78 18884, 19114, 19344, 19573, 19802, 20030, 20257, 20483, 20709, 20934, 21157, 21380,
79 21602, 21823, 22042, 22261, 22478, 22694, 22909, 23123, 23335, 23545, 23755, 23962,
80 24168, 24373, 24576, 24777, 24977, 25175, 25371, 25565, 25758, 25948, 26137, 26323,
81 26508, 26690, 26871, 27049, 27225, 27399, 27571, 27740, 27907, 28072, 28234, 28394,
82 28552, 28707, 28860, 29010, 29157, 29302, 29444, 29584, 29721, 29855, 29987, 30115,
83 30241, 30364, 30485, 30602, 30717, 30828, 30937, 31043, 31145, 31245, 31342, 31436,
84 31526, 31614, 31699, 31780, 31858, 31933, 32005, 32074, 32140, 32202, 32261, 32317,
85 32370, 32420, 32466, 32509, 32549, 32585, 32618, 32648, 32675, 32698, 32718, 32734,
86 32748, 32758, 32764, 32767, 32767, 32667, 32365, 31863, 31164, 30274, 29197, 27939,
87 26510, 24917, 23170, 21281, 19261, 17121, 14876, 12540, 10126, 7650, 5126, 2571
88};
89
90/* Lag window for LPC (Q31) */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000091const int32_t WebRtcIlbcfix_kLpcLagWin[LPC_FILTERORDER + 1]={
niklase@google.com470e71d2011-07-07 08:21:25 +000092 2147483647, 2144885453, 2137754373, 2125918626, 2109459810,
93 2088483140, 2063130336, 2033564590, 1999977009, 1962580174,
94 1921610283};
95
96/* WebRtcIlbcfix_kLpcChirpSyntDenum vector in Q15 corresponding
97 * floating point vector {1 0.9025 0.9025^2 0.9025^3 ...}
98 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000099const int16_t WebRtcIlbcfix_kLpcChirpSyntDenum[LPC_FILTERORDER + 1] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000100 32767, 29573, 26690, 24087,
101 21739, 19619, 17707, 15980,
102 14422, 13016, 11747};
103
104/* WebRtcIlbcfix_kLpcChirpWeightDenum in Q15 corresponding to
105 * floating point vector {1 0.4222 0.4222^2... }
106 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000107const int16_t WebRtcIlbcfix_kLpcChirpWeightDenum[LPC_FILTERORDER + 1] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000108 32767, 13835, 5841, 2466, 1041, 440,
109 186, 78, 33, 14, 6};
110
111/* LSF quantization Q13 domain */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000112const int16_t WebRtcIlbcfix_kLsfCb[64 * 3 + 128 * 3 + 128 * 4] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000113 1273, 2238, 3696,
114 3199, 5309, 8209,
115 3606, 5671, 7829,
116 2815, 5262, 8778,
117 2608, 4027, 5493,
118 1582, 3076, 5945,
119 2983, 4181, 5396,
120 2437, 4322, 6902,
121 1861, 2998, 4613,
122 2007, 3250, 5214,
123 1388, 2459, 4262,
124 2563, 3805, 5269,
125 2036, 3522, 5129,
126 1935, 4025, 6694,
127 2744, 5121, 7338,
128 2810, 4248, 5723,
129 3054, 5405, 7745,
130 1449, 2593, 4763,
131 3411, 5128, 6596,
132 2484, 4659, 7496,
133 1668, 2879, 4818,
134 1812, 3072, 5036,
135 1638, 2649, 3900,
136 2464, 3550, 4644,
137 1853, 2900, 4158,
138 2458, 4163, 5830,
139 2556, 4036, 6254,
140 2703, 4432, 6519,
141 3062, 4953, 7609,
142 1725, 3703, 6187,
143 2221, 3877, 5427,
144 2339, 3579, 5197,
145 2021, 4633, 7037,
146 2216, 3328, 4535,
147 2961, 4739, 6667,
148 2807, 3955, 5099,
149 2788, 4501, 6088,
150 1642, 2755, 4431,
151 3341, 5282, 7333,
152 2414, 3726, 5727,
153 1582, 2822, 5269,
154 2259, 3447, 4905,
155 3117, 4986, 7054,
156 1825, 3491, 5542,
157 3338, 5736, 8627,
158 1789, 3090, 5488,
159 2566, 3720, 4923,
160 2846, 4682, 7161,
161 1950, 3321, 5976,
162 1834, 3383, 6734,
163 3238, 4769, 6094,
164 2031, 3978, 5903,
165 1877, 4068, 7436,
166 2131, 4644, 8296,
167 2764, 5010, 8013,
168 2194, 3667, 6302,
169 2053, 3127, 4342,
170 3523, 6595, 10010,
171 3134, 4457, 5748,
172 3142, 5819, 9414,
173 2223, 4334, 6353,
174 2022, 3224, 4822,
175 2186, 3458, 5544,
176 2552, 4757, 6870,
177 10905, 12917, 14578,
178 9503, 11485, 14485,
179 9518, 12494, 14052,
180 6222, 7487, 9174,
181 7759, 9186, 10506,
182 8315, 12755, 14786,
183 9609, 11486, 13866,
184 8909, 12077, 13643,
185 7369, 9054, 11520,
186 9408, 12163, 14715,
187 6436, 9911, 12843,
188 7109, 9556, 11884,
189 7557, 10075, 11640,
190 6482, 9202, 11547,
191 6463, 7914, 10980,
192 8611, 10427, 12752,
193 7101, 9676, 12606,
194 7428, 11252, 13172,
195 10197, 12955, 15842,
196 7487, 10955, 12613,
197 5575, 7858, 13621,
198 7268, 11719, 14752,
199 7476, 11744, 13795,
200 7049, 8686, 11922,
201 8234, 11314, 13983,
202 6560, 11173, 14984,
203 6405, 9211, 12337,
204 8222, 12054, 13801,
205 8039, 10728, 13255,
206 10066, 12733, 14389,
207 6016, 7338, 10040,
208 6896, 8648, 10234,
209 7538, 9170, 12175,
210 7327, 12608, 14983,
211 10516, 12643, 15223,
212 5538, 7644, 12213,
213 6728, 12221, 14253,
214 7563, 9377, 12948,
215 8661, 11023, 13401,
216 7280, 8806, 11085,
217 7723, 9793, 12333,
218 12225, 14648, 16709,
219 8768, 13389, 15245,
220 10267, 12197, 13812,
221 5301, 7078, 11484,
222 7100, 10280, 11906,
223 8716, 12555, 14183,
224 9567, 12464, 15434,
225 7832, 12305, 14300,
226 7608, 10556, 12121,
227 8913, 11311, 12868,
228 7414, 9722, 11239,
229 8666, 11641, 13250,
230 9079, 10752, 12300,
231 8024, 11608, 13306,
232 10453, 13607, 16449,
233 8135, 9573, 10909,
234 6375, 7741, 10125,
235 10025, 12217, 14874,
236 6985, 11063, 14109,
237 9296, 13051, 14642,
238 8613, 10975, 12542,
239 6583, 10414, 13534,
240 6191, 9368, 13430,
241 5742, 6859, 9260,
242 7723, 9813, 13679,
243 8137, 11291, 12833,
244 6562, 8973, 10641,
245 6062, 8462, 11335,
246 6928, 8784, 12647,
247 7501, 8784, 10031,
248 8372, 10045, 12135,
249 8191, 9864, 12746,
250 5917, 7487, 10979,
251 5516, 6848, 10318,
252 6819, 9899, 11421,
253 7882, 12912, 15670,
254 9558, 11230, 12753,
255 7752, 9327, 11472,
256 8479, 9980, 11358,
257 11418, 14072, 16386,
258 7968, 10330, 14423,
259 8423, 10555, 12162,
260 6337, 10306, 14391,
261 8850, 10879, 14276,
262 6750, 11885, 15710,
263 7037, 8328, 9764,
264 6914, 9266, 13476,
265 9746, 13949, 15519,
266 11032, 14444, 16925,
267 8032, 10271, 11810,
268 10962, 13451, 15833,
269 10021, 11667, 13324,
270 6273, 8226, 12936,
271 8543, 10397, 13496,
272 7936, 10302, 12745,
273 6769, 8138, 10446,
274 6081, 7786, 11719,
275 8637, 11795, 14975,
276 8790, 10336, 11812,
277 7040, 8490, 10771,
278 7338, 10381, 13153,
279 6598, 7888, 9358,
280 6518, 8237, 12030,
281 9055, 10763, 12983,
282 6490, 10009, 12007,
283 9589, 12023, 13632,
284 6867, 9447, 10995,
285 7930, 9816, 11397,
286 10241, 13300, 14939,
287 5830, 8670, 12387,
288 9870, 11915, 14247,
289 9318, 11647, 13272,
290 6721, 10836, 12929,
291 6543, 8233, 9944,
292 8034, 10854, 12394,
293 9112, 11787, 14218,
294 9302, 11114, 13400,
295 9022, 11366, 13816,
296 6962, 10461, 12480,
297 11288, 13333, 15222,
298 7249, 8974, 10547,
299 10566, 12336, 14390,
300 6697, 11339, 13521,
301 11851, 13944, 15826,
302 6847, 8381, 11349,
303 7509, 9331, 10939,
304 8029, 9618, 11909,
305 13973, 17644, 19647, 22474,
306 14722, 16522, 20035, 22134,
307 16305, 18179, 21106, 23048,
308 15150, 17948, 21394, 23225,
309 13582, 15191, 17687, 22333,
310 11778, 15546, 18458, 21753,
311 16619, 18410, 20827, 23559,
312 14229, 15746, 17907, 22474,
313 12465, 15327, 20700, 22831,
314 15085, 16799, 20182, 23410,
315 13026, 16935, 19890, 22892,
316 14310, 16854, 19007, 22944,
317 14210, 15897, 18891, 23154,
318 14633, 18059, 20132, 22899,
319 15246, 17781, 19780, 22640,
320 16396, 18904, 20912, 23035,
321 14618, 17401, 19510, 21672,
322 15473, 17497, 19813, 23439,
323 18851, 20736, 22323, 23864,
324 15055, 16804, 18530, 20916,
325 16490, 18196, 19990, 21939,
326 11711, 15223, 21154, 23312,
327 13294, 15546, 19393, 21472,
328 12956, 16060, 20610, 22417,
329 11628, 15843, 19617, 22501,
330 14106, 16872, 19839, 22689,
331 15655, 18192, 20161, 22452,
332 12953, 15244, 20619, 23549,
333 15322, 17193, 19926, 21762,
334 16873, 18676, 20444, 22359,
335 14874, 17871, 20083, 21959,
336 11534, 14486, 19194, 21857,
337 17766, 19617, 21338, 23178,
338 13404, 15284, 19080, 23136,
339 15392, 17527, 19470, 21953,
340 14462, 16153, 17985, 21192,
341 17734, 19750, 21903, 23783,
342 16973, 19096, 21675, 23815,
343 16597, 18936, 21257, 23461,
344 15966, 17865, 20602, 22920,
345 15416, 17456, 20301, 22972,
346 18335, 20093, 21732, 23497,
347 15548, 17217, 20679, 23594,
348 15208, 16995, 20816, 22870,
349 13890, 18015, 20531, 22468,
350 13211, 15377, 19951, 22388,
351 12852, 14635, 17978, 22680,
352 16002, 17732, 20373, 23544,
353 11373, 14134, 19534, 22707,
354 17329, 19151, 21241, 23462,
355 15612, 17296, 19362, 22850,
356 15422, 19104, 21285, 23164,
357 13792, 17111, 19349, 21370,
358 15352, 17876, 20776, 22667,
359 15253, 16961, 18921, 22123,
360 14108, 17264, 20294, 23246,
361 15785, 17897, 20010, 21822,
362 17399, 19147, 20915, 22753,
363 13010, 15659, 18127, 20840,
364 16826, 19422, 22218, 24084,
365 18108, 20641, 22695, 24237,
366 18018, 20273, 22268, 23920,
367 16057, 17821, 21365, 23665,
368 16005, 17901, 19892, 23016,
369 13232, 16683, 21107, 23221,
370 13280, 16615, 19915, 21829,
371 14950, 18575, 20599, 22511,
372 16337, 18261, 20277, 23216,
373 14306, 16477, 21203, 23158,
374 12803, 17498, 20248, 22014,
375 14327, 17068, 20160, 22006,
376 14402, 17461, 21599, 23688,
377 16968, 18834, 20896, 23055,
378 15070, 17157, 20451, 22315,
379 15419, 17107, 21601, 23946,
380 16039, 17639, 19533, 21424,
381 16326, 19261, 21745, 23673,
382 16489, 18534, 21658, 23782,
383 16594, 18471, 20549, 22807,
384 18973, 21212, 22890, 24278,
385 14264, 18674, 21123, 23071,
386 15117, 16841, 19239, 23118,
387 13762, 15782, 20478, 23230,
388 14111, 15949, 20058, 22354,
389 14990, 16738, 21139, 23492,
390 13735, 16971, 19026, 22158,
391 14676, 17314, 20232, 22807,
392 16196, 18146, 20459, 22339,
393 14747, 17258, 19315, 22437,
394 14973, 17778, 20692, 23367,
395 15715, 17472, 20385, 22349,
396 15702, 18228, 20829, 23410,
397 14428, 16188, 20541, 23630,
398 16824, 19394, 21365, 23246,
399 13069, 16392, 18900, 21121,
400 12047, 16640, 19463, 21689,
401 14757, 17433, 19659, 23125,
402 15185, 16930, 19900, 22540,
403 16026, 17725, 19618, 22399,
404 16086, 18643, 21179, 23472,
405 15462, 17248, 19102, 21196,
406 17368, 20016, 22396, 24096,
407 12340, 14475, 19665, 23362,
408 13636, 16229, 19462, 22728,
409 14096, 16211, 19591, 21635,
410 12152, 14867, 19943, 22301,
411 14492, 17503, 21002, 22728,
412 14834, 16788, 19447, 21411,
413 14650, 16433, 19326, 22308,
414 14624, 16328, 19659, 23204,
415 13888, 16572, 20665, 22488,
416 12977, 16102, 18841, 22246,
417 15523, 18431, 21757, 23738,
418 14095, 16349, 18837, 20947,
419 13266, 17809, 21088, 22839,
420 15427, 18190, 20270, 23143,
421 11859, 16753, 20935, 22486,
422 12310, 17667, 21736, 23319,
423 14021, 15926, 18702, 22002,
424 12286, 15299, 19178, 21126,
425 15703, 17491, 21039, 23151,
426 12272, 14018, 18213, 22570,
427 14817, 16364, 18485, 22598,
428 17109, 19683, 21851, 23677,
429 12657, 14903, 19039, 22061,
430 14713, 16487, 20527, 22814,
431 14635, 16726, 18763, 21715,
432 15878, 18550, 20718, 22906
433};
434
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000435const int16_t WebRtcIlbcfix_kLsfDimCb[LSF_NSPLIT] = {3, 3, 4};
436const int16_t WebRtcIlbcfix_kLsfSizeCb[LSF_NSPLIT] = {64,128,128};
niklase@google.com470e71d2011-07-07 08:21:25 +0000437
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000438const int16_t WebRtcIlbcfix_kLsfMean[LPC_FILTERORDER] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000439 2308, 3652, 5434, 7885,
440 10255, 12559, 15160, 17513,
441 20328, 22752};
442
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000443const int16_t WebRtcIlbcfix_kLspMean[LPC_FILTERORDER] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000444 31476, 29565, 25819, 18725, 10276,
445 1236, -9049, -17600, -25884, -30618
446};
447
448/* Q14 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000449const int16_t WebRtcIlbcfix_kLsfWeight20ms[4] = {12288, 8192, 4096, 0};
450const int16_t WebRtcIlbcfix_kLsfWeight30ms[6] = {8192, 16384, 10923, 5461, 0, 0};
niklase@google.com470e71d2011-07-07 08:21:25 +0000451
452/*
453 cos(x) in Q15
454 WebRtcIlbcfix_kCos[i] = cos(pi*i/64.0)
455 used in WebRtcIlbcfix_Lsp2Lsf()
456*/
457
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000458const int16_t WebRtcIlbcfix_kCos[64] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000459 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853,
460 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279,
461 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010,
462 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608,
463 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039,
464 -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006,
465 -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622,
466 -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729
467};
468
469/*
470 Derivative in Q19, used to interpolate between the
471 WebRtcIlbcfix_kCos[] values to get a more exact y = cos(x)
472*/
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000473const int16_t WebRtcIlbcfix_kCosDerivative[64] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000474 -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261,
475 -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744,
476 -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526,
477 -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726,
478 -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009,
479 -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637,
480 -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428,
481 -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632};
482
483/*
484 Table in Q15, used for a2lsf conversion
485 WebRtcIlbcfix_kCosGrid[i] = cos((2*pi*i)/(float)(2*COS_GRID_POINTS));
486*/
487
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000488const int16_t WebRtcIlbcfix_kCosGrid[COS_GRID_POINTS + 1] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000489 32760, 32723, 32588, 32364, 32051, 31651, 31164, 30591,
490 29935, 29196, 28377, 27481, 26509, 25465, 24351, 23170,
491 21926, 20621, 19260, 17846, 16384, 14876, 13327, 11743,
492 10125, 8480, 6812, 5126, 3425, 1714, 0, -1714, -3425,
493 -5126, -6812, -8480, -10125, -11743, -13327, -14876,
494 -16384, -17846, -19260, -20621, -21926, -23170, -24351,
495 -25465, -26509, -27481, -28377, -29196, -29935, -30591,
496 -31164, -31651, -32051, -32364, -32588, -32723, -32760
497};
498
499/*
500 Derivative of y = acos(x) in Q12
501 used in WebRtcIlbcfix_Lsp2Lsf()
502*/
503
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000504const int16_t WebRtcIlbcfix_kAcosDerivative[64] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000505 -26887, -8812, -5323, -3813, -2979, -2444, -2081, -1811,
506 -1608, -1450, -1322, -1219, -1132, -1059, -998, -946,
507 -901, -861, -827, -797, -772, -750, -730, -713,
508 -699, -687, -677, -668, -662, -657, -654, -652,
509 -652, -654, -657, -662, -668, -677, -687, -699,
510 -713, -730, -750, -772, -797, -827, -861, -901,
511 -946, -998, -1059, -1132, -1219, -1322, -1450, -1608,
512 -1811, -2081, -2444, -2979, -3813, -5323, -8812, -26887
513};
514
515
516/* Tables for quantization of start state */
517
518/* State quantization tables */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000519const int16_t WebRtcIlbcfix_kStateSq3[8] = { /* Values in Q13 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000520 -30473, -17838, -9257, -2537,
521 3639, 10893, 19958, 32636
522};
523
524/* This table defines the limits for the selection of the freqg
525 less or equal than value 0 => index = 0
526 less or equal than value k => index = k
527*/
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000528const int32_t WebRtcIlbcfix_kChooseFrgQuant[64] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000529 118, 163, 222, 305, 425, 604,
530 851, 1174, 1617, 2222, 3080, 4191,
531 5525, 7215, 9193, 11540, 14397, 17604,
532 21204, 25209, 29863, 35720, 42531, 50375,
533 59162, 68845, 80108, 93754, 110326, 129488,
534 150654, 174328, 201962, 233195, 267843, 308239,
535 354503, 405988, 464251, 531550, 608652, 697516,
536 802526, 928793, 1080145, 1258120, 1481106, 1760881,
537 2111111, 2546619, 3078825, 3748642, 4563142, 5573115,
538 6887601, 8582108, 10797296, 14014513, 18625760, 25529599,
539 37302935, 58819185, 109782723, WEBRTC_SPL_WORD32_MAX
540};
541
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000542const int16_t WebRtcIlbcfix_kScale[64] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000543 /* Values in Q16 */
544 29485, 25003, 21345, 18316, 15578, 13128, 10973, 9310, 7955,
545 6762, 5789, 4877, 4255, 3699, 3258, 2904, 2595, 2328,
546 2123, 1932, 1785, 1631, 1493, 1370, 1260, 1167, 1083,
547 /* Values in Q21 */
548 32081, 29611, 27262, 25229, 23432, 21803, 20226, 18883, 17609,
549 16408, 15311, 14327, 13390, 12513, 11693, 10919, 10163, 9435,
550 8739, 8100, 7424, 6813, 6192, 5648, 5122, 4639, 4207, 3798,
551 3404, 3048, 2706, 2348, 2036, 1713, 1393, 1087, 747
552};
553
554/*frgq in fixpoint, but already computed like this:
555 for(i=0; i<64; i++){
556 a = (pow(10,frgq[i])/4.5);
557 WebRtcIlbcfix_kFrgQuantMod[i] = round(a);
558 }
559
560 Value 0 :36 in Q8
561 37:58 in Q5
562 59:63 in Q3
563*/
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000564const int16_t WebRtcIlbcfix_kFrgQuantMod[64] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000565 /* First 37 values in Q8 */
566 569, 671, 786, 916, 1077, 1278,
567 1529, 1802, 2109, 2481, 2898, 3440,
568 3943, 4535, 5149, 5778, 6464, 7208,
569 7904, 8682, 9397, 10285, 11240, 12246,
570 13313, 14382, 15492, 16735, 18131, 19693,
571 21280, 22912, 24624, 26544, 28432, 30488,
572 32720,
573 /* 22 values in Q5 */
574 4383, 4684, 5012, 5363, 5739, 6146,
575 6603, 7113, 7679, 8285, 9040, 9850,
576 10838, 11882, 13103, 14467, 15950, 17669,
577 19712, 22016, 24800, 28576,
578 /* 5 values in Q3 */
579 8240, 9792, 12040, 15440, 22472
580};
581
582/* Constants for codebook search and creation */
583
584/* Expansion filter to get additional cb section.
585 * Q12 and reversed compared to flp
586 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000587const int16_t WebRtcIlbcfix_kCbFiltersRev[CB_FILTERLEN]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000588 -140, 446, -755, 3302, 2922, -590, 343, -138};
589
590/* Weighting coefficients for short lags.
591 * [0.2 0.4 0.6 0.8] in Q15 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000592const int16_t WebRtcIlbcfix_kAlpha[4]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000593 6554, 13107, 19661, 26214};
594
595/* Ranges for search and filters at different subframes */
596
Peter Kastingdce40cf2015-08-24 14:52:23 -0700597const size_t WebRtcIlbcfix_kSearchRange[5][CB_NSTAGES]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000598 {58,58,58}, {108,44,44}, {108,108,108}, {108,108,108}, {108,108,108}};
599
Peter Kastingdce40cf2015-08-24 14:52:23 -0700600const size_t WebRtcIlbcfix_kFilterRange[5]={63, 85, 125, 147, 147};
niklase@google.com470e71d2011-07-07 08:21:25 +0000601
602/* Gain Quantization for the codebook gains of the 3 stages */
603
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000604/* Q14 (one extra value (max int16_t) to simplify for the search) */
605const int16_t WebRtcIlbcfix_kGainSq3[9]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000606 -16384, -10813, -5407, 0, 4096, 8192,
607 12288, 16384, 32767};
608
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000609/* Q14 (one extra value (max int16_t) to simplify for the search) */
610const int16_t WebRtcIlbcfix_kGainSq4[17]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000611 -17203, -14746, -12288, -9830, -7373, -4915,
612 -2458, 0, 2458, 4915, 7373, 9830,
613 12288, 14746, 17203, 19661, 32767};
614
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000615/* Q14 (one extra value (max int16_t) to simplify for the search) */
616const int16_t WebRtcIlbcfix_kGainSq5[33]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000617 614, 1229, 1843, 2458, 3072, 3686,
618 4301, 4915, 5530, 6144, 6758, 7373,
619 7987, 8602, 9216, 9830, 10445, 11059,
620 11674, 12288, 12902, 13517, 14131, 14746,
621 15360, 15974, 16589, 17203, 17818, 18432,
622 19046, 19661, 32767};
623
624/* Q14 gain_sq5Tbl squared in Q14 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000625const int16_t WebRtcIlbcfix_kGainSq5Sq[32] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000626 23, 92, 207, 368, 576, 829,
627 1129, 1474, 1866, 2304, 2787, 3317,
628 3893, 4516, 5184, 5897, 6658, 7464,
629 8318, 9216, 10160, 11151, 12187, 13271,
630 14400, 15574, 16796, 18062, 19377, 20736,
631 22140, 23593
632};
633
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000634const int16_t* const WebRtcIlbcfix_kGain[3] =
niklase@google.com470e71d2011-07-07 08:21:25 +0000635{WebRtcIlbcfix_kGainSq5, WebRtcIlbcfix_kGainSq4, WebRtcIlbcfix_kGainSq3};
636
637
638/* Tables for the Enhancer, using upsamling factor 4 (ENH_UPS0 = 4) */
639
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000640const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1]={
niklase@google.com470e71d2011-07-07 08:21:25 +0000641 {0, 0, 0, 4096, 0, 0, 0},
642 {64, -315, 1181, 3531, -436, 77, -64},
643 {97, -509, 2464, 2464, -509, 97, -97},
644 {77, -436, 3531, 1181, -315, 64, -77}
645};
646
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000647const int16_t WebRtcIlbcfix_kEnhWt[3] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000648 4800, 16384, 27968 /* Q16 */
649};
650
Peter Kasting1380e262015-08-28 17:31:03 -0700651const size_t WebRtcIlbcfix_kEnhPlocs[ENH_NBLOCKS_TOT] = {
niklase@google.com470e71d2011-07-07 08:21:25 +0000652 160, 480, 800, 1120, 1440, 1760, 2080, 2400 /* Q(-2) */
653};
654
655/* PLC table */
656
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000657const int16_t WebRtcIlbcfix_kPlcPerSqr[6] = { /* Grid points for square of periodiciy in Q15 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000658 839, 1343, 2048, 2998, 4247, 5849
659};
660
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000661const int16_t WebRtcIlbcfix_kPlcPitchFact[6] = { /* Value of y=(x^4-0.4)/(0.7-0.4) in grid points in Q15 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000662 0, 5462, 10922, 16384, 21846, 27306
663};
664
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000665const int16_t WebRtcIlbcfix_kPlcPfSlope[6] = { /* Slope of y=(x^4-0.4)/(0.7-0.4) in Q11 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000666 26667, 18729, 13653, 10258, 7901, 6214
667};