1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 /**************************************************************************************** 19 Portions of this file are derived from the following 3GPP standard: 20 21 3GPP TS 26.073 22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec 23 Available from http://www.3gpp.org 24 25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) 26 Permission to distribute, modify and use this file under the standard license 27 terms listed above has been obtained from the copyright holder. 28 ****************************************************************************************/ 29 /* 30 31 Filename: /audio/gsm_amr/c/src/qua_gain_tbl.c 32 33 ------------------------------------------------------------------------------ 34 REVISION HISTORY 35 36 Description: Created this file from the reference, qua_gain.tab 37 38 Description: Added #ifdef __cplusplus and removed "extern" from table 39 definition. 40 41 Description: Put "extern" back. 42 43 Who: Date: 44 Description: 45 46 ------------------------------------------------------------------------------ 47 MODULE DESCRIPTION 48 49 ------------------------------------------------------------------------------ 50 */ 51 52 /*---------------------------------------------------------------------------- 53 ; INCLUDES 54 ----------------------------------------------------------------------------*/ 55 #include "typedef.h" 56 #include "qua_gain.h" 57 #include "qua_gain_tbl.h" 58 59 /*--------------------------------------------------------------------------*/ 60 #ifdef __cplusplus 61 extern "C" 62 { 63 #endif 64 65 /*---------------------------------------------------------------------------- 66 ; MACROS 67 ; [Define module specific macros here] 68 ----------------------------------------------------------------------------*/ 69 70 /*---------------------------------------------------------------------------- 71 ; DEFINES 72 ; [Include all pre-processor statements here. Include conditional 73 ; compile variables also.] 74 ----------------------------------------------------------------------------*/ 75 76 /*---------------------------------------------------------------------------- 77 ; LOCAL FUNCTION DEFINITIONS 78 ; [List function prototypes here] 79 ----------------------------------------------------------------------------*/ 80 81 /*---------------------------------------------------------------------------- 82 ; LOCAL VARIABLE DEFINITIONS 83 ; [Variable declaration - defined here and used outside this module] 84 ----------------------------------------------------------------------------*/ 85 86 /* The tables contains the following data: 87 * 88 * g_pitch (Q14), 89 * g_fac (Q12), (g_code = g_code0*g_fac), 90 * qua_ener_MR122 (Q10), (log2(g_fac)) 91 * qua_ener (Q10) (20*log10(g_fac)) 92 * 93 * The log2() and log10() values are calculated on the fixed point value 94 * (g_fac Q12) and not on the original floating point value of g_fac 95 * to make the quantizer/MA predictdor use corresponding values. 96 */ 97 98 /* table used in 'high' rates: MR67 MR74 */ 99 100 const Word16 table_gain_highrates[VQ_SIZE_HIGHRATES*4] = 101 { 102 103 /* 104 * Note: column 4 (qua_ener) contains the original values from IS641 105 * to ensure bit-exactness; however, they are not exactly the 106 * rounded value of (20*log10(g_fac)) 107 * 108 */ 109 110 /*g_pit, g_fac, qua_ener_MR122, qua_ener */ 111 577, 662, -2692, -16214, 112 806, 1836, -1185, -7135, 113 3109, 1052, -2008, -12086, 114 4181, 1387, -1600, -9629, 115 2373, 1425, -1560, -9394, 116 3248, 1985, -1070, -6442, 117 1827, 2320, -840, -5056, 118 941, 3314, -313, -1885, 119 2351, 2977, -471, -2838, 120 3616, 2420, -777, -4681, 121 3451, 3096, -414, -2490, 122 2955, 4301, 72, 434, 123 1848, 4500, 139, 836, 124 3884, 5416, 413, 2484, 125 1187, 7210, 835, 5030, 126 3083, 9000, 1163, 7002, 127 7384, 883, -2267, -13647, 128 5962, 1506, -1478, -8900, 129 5155, 2134, -963, -5800, 130 7944, 2009, -1052, -6335, 131 6507, 2250, -885, -5327, 132 7670, 2752, -588, -3537, 133 5952, 3016, -452, -2724, 134 4898, 3764, -125, -751, 135 6989, 3588, -196, -1177, 136 8174, 3978, -43, -260, 137 6064, 4404, 107, 645, 138 7709, 5087, 320, 1928, 139 5523, 6021, 569, 3426, 140 7769, 7126, 818, 4926, 141 6060, 7938, 977, 5885, 142 5594, 11487, 1523, 9172, 143 10581, 1356, -1633, -9831, 144 9049, 1597, -1391, -8380, 145 9794, 2035, -1033, -6220, 146 8946, 2415, -780, -4700, 147 10296, 2584, -681, -4099, 148 9407, 2734, -597, -3595, 149 8700, 3218, -356, -2144, 150 9757, 3395, -277, -1669, 151 10177, 3892, -75, -454, 152 9170, 4528, 148, 891, 153 10152, 5004, 296, 1781, 154 9114, 5735, 497, 2993, 155 10500, 6266, 628, 3782, 156 10110, 7631, 919, 5534, 157 8844, 8727, 1117, 6728, 158 8956, 12496, 1648, 9921, 159 12924, 976, -2119, -12753, 160 11435, 1755, -1252, -7539, 161 12138, 2328, -835, -5024, 162 11388, 2368, -810, -4872, 163 10700, 3064, -429, -2580, 164 12332, 2861, -530, -3192, 165 11722, 3327, -307, -1848, 166 11270, 3700, -150, -904, 167 10861, 4413, 110, 663, 168 12082, 4533, 150, 902, 169 11283, 5205, 354, 2132, 170 11960, 6305, 637, 3837, 171 11167, 7534, 900, 5420, 172 12128, 8329, 1049, 6312, 173 10969, 10777, 1429, 8604, 174 10300, 17376, 2135, 12853, 175 13899, 1681, -1316, -7921, 176 12580, 2045, -1026, -6179, 177 13265, 2439, -766, -4610, 178 14033, 2989, -465, -2802, 179 13452, 3098, -413, -2482, 180 12396, 3658, -167, -1006, 181 13510, 3780, -119, -713, 182 12880, 4272, 62, 374, 183 13533, 4861, 253, 1523, 184 12667, 5457, 424, 2552, 185 13854, 6106, 590, 3551, 186 13031, 6483, 678, 4084, 187 13557, 7721, 937, 5639, 188 12957, 9311, 1213, 7304, 189 13714, 11551, 1532, 9221, 190 12591, 15206, 1938, 11667, 191 15113, 1540, -1445, -8700, 192 15072, 2333, -832, -5007, 193 14527, 2511, -723, -4352, 194 14692, 3199, -365, -2197, 195 15382, 3560, -207, -1247, 196 14133, 3960, -50, -300, 197 15102, 4236, 50, 298, 198 14332, 4824, 242, 1454, 199 14846, 5451, 422, 2542, 200 15306, 6083, 584, 3518, 201 14329, 6888, 768, 4623, 202 15060, 7689, 930, 5602, 203 14406, 9426, 1231, 7413, 204 15387, 9741, 1280, 7706, 205 14824, 14271, 1844, 11102, 206 13600, 24939, 2669, 16067, 207 16396, 1969, -1082, -6517, 208 16817, 2832, -545, -3283, 209 15713, 2843, -539, -3248, 210 16104, 3336, -303, -1825, 211 16384, 3963, -49, -294, 212 16940, 4579, 165, 992, 213 15711, 4599, 171, 1030, 214 16222, 5448, 421, 2537, 215 16832, 6382, 655, 3945, 216 15745, 7141, 821, 4944, 217 16326, 7469, 888, 5343, 218 16611, 8624, 1100, 6622, 219 17028, 10418, 1379, 8303, 220 15905, 11817, 1565, 9423, 221 16878, 14690, 1887, 11360, 222 16515, 20870, 2406, 14483, 223 18142, 2083, -999, -6013, 224 19401, 3178, -375, -2257, 225 17508, 3426, -264, -1589, 226 20054, 4027, -25, -151, 227 18069, 4249, 54, 326, 228 18952, 5066, 314, 1890, 229 17711, 5402, 409, 2461, 230 19835, 6192, 610, 3676, 231 17950, 7014, 795, 4784, 232 21318, 7877, 966, 5816, 233 17910, 9289, 1210, 7283, 234 19144, 9290, 1210, 7284, 235 20517, 11381, 1510, 9089, 236 18075, 14485, 1866, 11234, 237 19999, 17882, 2177, 13108, 238 18842, 32764, 3072, 18494 239 }; 240 241 242 /* table used in 'low' rates: MR475, MR515, MR59 */ 243 244 const Word16 table_gain_lowrates[VQ_SIZE_LOWRATES*4] = 245 { 246 /*g_pit, g_fac, qua_ener_MR122, qua_ener */ 247 10813, 28753, 2879, 17333, 248 20480, 2785, -570, -3431, 249 18841, 6594, 703, 4235, 250 6225, 7413, 876, 5276, 251 17203, 10444, 1383, 8325, 252 21626, 1269, -1731, -10422, 253 21135, 4423, 113, 683, 254 11304, 1556, -1430, -8609, 255 19005, 12820, 1686, 10148, 256 17367, 2498, -731, -4398, 257 17858, 4833, 244, 1472, 258 9994, 2498, -731, -4398, 259 17530, 7864, 964, 5802, 260 14254, 1884, -1147, -6907, 261 15892, 3153, -387, -2327, 262 6717, 1802, -1213, -7303, 263 18186, 20193, 2357, 14189, 264 18022, 3031, -445, -2678, 265 16711, 5857, 528, 3181, 266 8847, 4014, -30, -180, 267 15892, 8970, 1158, 6972, 268 18022, 1392, -1594, -9599, 269 16711, 4096, 0, 0, 270 8192, 655, -2708, -16305, 271 15237, 13926, 1808, 10884, 272 14254, 3112, -406, -2444, 273 14090, 4669, 193, 1165, 274 5406, 2703, -614, -3697, 275 13434, 6553, 694, 4180, 276 12451, 901, -2237, -13468, 277 12451, 2662, -637, -3833, 278 3768, 655, -2708, -16305, 279 14745, 23511, 2582, 15543, 280 19169, 2457, -755, -4546, 281 20152, 5079, 318, 1913, 282 6881, 4096, 0, 0, 283 20480, 8560, 1089, 6556, 284 19660, 737, -2534, -15255, 285 19005, 4259, 58, 347, 286 7864, 2088, -995, -5993, 287 11468, 12288, 1623, 9771, 288 15892, 1474, -1510, -9090, 289 15728, 4628, 180, 1086, 290 9175, 1433, -1552, -9341, 291 16056, 7004, 793, 4772, 292 14827, 737, -2534, -15255, 293 15073, 2252, -884, -5321, 294 5079, 1228, -1780, -10714, 295 13271, 17326, 2131, 12827, 296 16547, 2334, -831, -5002, 297 15073, 5816, 518, 3118, 298 3932, 3686, -156, -938, 299 14254, 8601, 1096, 6598, 300 16875, 778, -2454, -14774, 301 15073, 3809, -107, -646, 302 6062, 614, -2804, -16879, 303 9338, 9256, 1204, 7251, 304 13271, 1761, -1247, -7508, 305 13271, 3522, -223, -1343, 306 2457, 1966, -1084, -6529, 307 11468, 5529, 443, 2668, 308 10485, 737, -2534, -15255, 309 11632, 3194, -367, -2212, 310 1474, 778, -2454, -14774 311 }; 312 313 /*--------------------------------------------------------------------------*/ 314 #ifdef __cplusplus 315 } 316 #endif 317 318 /* 319 ------------------------------------------------------------------------------ 320 FUNCTION NAME: 321 ------------------------------------------------------------------------------ 322 INPUT AND OUTPUT DEFINITIONS 323 324 Inputs: 325 None 326 327 Outputs: 328 None 329 330 Returns: 331 None 332 333 Global Variables Used: 334 None 335 336 Local Variables Needed: 337 None 338 339 ------------------------------------------------------------------------------ 340 FUNCTION DESCRIPTION 341 342 None 343 344 ------------------------------------------------------------------------------ 345 REQUIREMENTS 346 347 None 348 349 ------------------------------------------------------------------------------ 350 REFERENCES 351 352 [1] qua_gain.tab, UMTS GSM AMR speech codec, 353 R99 - Version 3.2.0, March 2, 2001 354 355 ------------------------------------------------------------------------------ 356 PSEUDO-CODE 357 358 359 ------------------------------------------------------------------------------ 360 RESOURCES USED [optional] 361 362 When the code is written for a specific target processor the 363 the resources used should be documented below. 364 365 HEAP MEMORY USED: x bytes 366 367 STACK MEMORY USED: x bytes 368 369 CLOCK CYCLES: (cycle count equation for this function) + (variable 370 used to represent cycle count for each subroutine 371 called) 372 where: (cycle count variable) = cycle count for [subroutine 373 name] 374 375 ------------------------------------------------------------------------------ 376 CAUTION [optional] 377 [State any special notes, constraints or cautions for users of this function] 378 379 ------------------------------------------------------------------------------ 380 */ 381 382 /*---------------------------------------------------------------------------- 383 ; FUNCTION CODE 384 ----------------------------------------------------------------------------*/ 385 386 387 388 389 390 391 392