comparison libgsmhr1/sp_rom.c @ 507:06578223a752

libgsmhr1: integrate sp_rom.c
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 19 Jun 2024 02:13:56 +0000
parents 2d6da062c452
children
comparison
equal deleted inserted replaced
506:2d6da062c452 507:06578223a752
11 /*_________________________________________________________________________ 11 /*_________________________________________________________________________
12 | | 12 | |
13 | Include Files | 13 | Include Files |
14 |_________________________________________________________________________| 14 |_________________________________________________________________________|
15 */ 15 */
16 #include "mathhalf.h" 16 #include "namespace.h"
17 #include "sp_rom.h" 17 #include "sp_rom.h"
18 18
19 /*_________________________________________________________________________ 19 /*_________________________________________________________________________
20 | | 20 | |
21 | Global Data | 21 | Global Data |
28 28
29 /* THE GSP0 ERROR TERM VECTORS FOR 5 BITS FOLLOW 29 /* THE GSP0 ERROR TERM VECTORS FOR 5 BITS FOLLOW
30 THE GSP0 TABLE WAS READ FROM THE FILES gsp0_1_*.qnt_97CQ_4 30 THE GSP0 TABLE WAS READ FROM THE FILES gsp0_1_*.qnt_97CQ_4
31 ET VALUES WRITTEN WERE SCALED BY 4 */ 31 ET VALUES WRITTEN WERE SCALED BY 4 */
32 32
33 ShortwordRom pppsrGsp0 33 const ShortwordRom pppsrGsp0
34 [GSP0_NUM_OF_TABLES][GSP0_NUM][GSP0_VECTOR_SIZE] = 34 [GSP0_NUM_OF_TABLES][GSP0_NUM][GSP0_VECTOR_SIZE] =
35 { 35 {
36 { 36 {
37 37
38 {33, 34, 0, 0, 0}, /* Table 1, Centroid # 1 */ 38 {33, 34, 0, 0, 0}, /* Table 1, Centroid # 1 */
174 174
175 175
176 /* unvoiced code vectors */ 176 /* unvoiced code vectors */
177 /*-----------------------*/ 177 /*-----------------------*/
178 178
179 ShortwordRom pppsrUvCodeVec 179 const ShortwordRom pppsrUvCodeVec
180 [UVCODEVEC_NUM_OF_CODE_BOOKS][UVCODEVEC_NUM_OF_CODE_BITS][S_LEN] = 180 [UVCODEVEC_NUM_OF_CODE_BOOKS][UVCODEVEC_NUM_OF_CODE_BITS][S_LEN] =
181 { 181 {
182 { 182 {
183 { 183 {
184 12, 11, -49, -53, 9, /* File# 1, Vec# 1, 1- 5 */ 184 12, 11, -49, -53, 9, /* File# 1, Vec# 1, 1- 5 */
327 327
328 328
329 /* voiced code vectors */ 329 /* voiced code vectors */
330 /*---------------------*/ 330 /*---------------------*/
331 331
332 ShortwordRom pppsrVcdCodeVec 332 const ShortwordRom pppsrVcdCodeVec
333 [VCDCODEVEC_NUM_OF_CODE_BOOKS][VCDCODEVEC_NUM_OF_CODE_BITS][S_LEN] = 333 [VCDCODEVEC_NUM_OF_CODE_BOOKS][VCDCODEVEC_NUM_OF_CODE_BITS][S_LEN] =
334 { 334 {
335 { 335 {
336 { 336 {
337 24, 13, -55, -51, -8, /* File# 1, Vec# 1, 1- 5 */ 337 24, 13, -55, -51, -8, /* File# 1, Vec# 1, 1- 5 */
428 428
429 429
430 /* vector quantizer tables */ 430 /* vector quantizer tables */
431 /*-------------------------*/ 431 /*-------------------------*/
432 432
433 ShortwordRom psrQuant1 433 const ShortwordRom psrQuant1
434 [QUANT1_NUM_OF_WORDS] = 434 [QUANT1_NUM_OF_WORDS] =
435 { 435 {
436 -5980, /* Vector 0, coef 1(232), 2(164) */ 436 -5980, /* Vector 0, coef 1(232), 2(164) */
437 25056, /* Vector 0, coef 3( 97) Vector 1, 437 25056, /* Vector 0, coef 3( 97) Vector 1,
438 * Coef 1(224) */ 438 * Coef 1(224) */
4529 21515, /* Vector 2046, coef 3( 84) Vector 4529 21515, /* Vector 2046, coef 3( 84) Vector
4530 * 2047, Coef 1( 11) */ 4530 * 2047, Coef 1( 11) */
4531 -4772 /* Vector 2047, coef 2(237), 3( 92) */ 4531 -4772 /* Vector 2047, coef 2(237), 3( 92) */
4532 }; 4532 };
4533 4533
4534 ShortwordRom psrQuant2[QUANT2_NUM_OF_WORDS] = 4534 const ShortwordRom psrQuant2[QUANT2_NUM_OF_WORDS] =
4535 { 4535 {
4536 -15195, /* Vector 0, coef 1(196), 2(165) */ 4536 -15195, /* Vector 0, coef 1(196), 2(165) */
4537 -24371, /* Vector 0, coef 3(160) Vector 1, 4537 -24371, /* Vector 0, coef 3(160) Vector 1,
4538 * Coef 1(205) */ 4538 * Coef 1(205) */
4539 -26463, /* Vector 1, coef 2(152), 3(161) */ 4539 -26463, /* Vector 1, coef 2(152), 3(161) */
5557 -24489, /* Vector 510, coef 3(160) Vector 5557 -24489, /* Vector 510, coef 3(160) Vector
5558 * 511, Coef 1( 87) */ 5558 * 511, Coef 1( 87) */
5559 27538 /* Vector 511, coef 2(107), 3(146) */ 5559 27538 /* Vector 511, coef 2(107), 3(146) */
5560 }; 5560 };
5561 5561
5562 ShortwordRom psrQuant3[QUANT3_NUM_OF_WORDS] = 5562 const ShortwordRom psrQuant3[QUANT3_NUM_OF_WORDS] =
5563 { 5563 {
5564 -26192, /* Vector 0, coef 1(153), 2(176) */ 5564 -26192, /* Vector 0, coef 1(153), 2(176) */
5565 -32358, /* Vector 0, coef 3(129), 4(154) */ 5565 -32358, /* Vector 0, coef 3(129), 4(154) */
5566 -27991, /* Vector 1, coef 1(146), 2(169) */ 5566 -27991, /* Vector 1, coef 1(146), 2(169) */
5567 31890, /* Vector 1, coef 3(124), 4(146) */ 5567 31890, /* Vector 1, coef 3(124), 4(146) */
6077 6077
6078 6078
6079 /* lpc pre-quantizer */ 6079 /* lpc pre-quantizer */
6080 /*-------------------*/ 6080 /*-------------------*/
6081 6081
6082 ShortwordRom psrPreQ1[PREQ1_NUM_OF_WORDS] = 6082 const ShortwordRom psrPreQ1[PREQ1_NUM_OF_WORDS] =
6083 { 6083 {
6084 -13624, /* Vector 0, coef 1(202), 2(200) */ 6084 -13624, /* Vector 0, coef 1(202), 2(200) */
6085 -31561, /* Vector 0, coef 3(132) Vector 1, 6085 -31561, /* Vector 0, coef 3(132) Vector 1,
6086 * Coef 1(183) */ 6086 * Coef 1(183) */
6087 -11886, /* Vector 1, coef 2(209), 3(146) */ 6087 -11886, /* Vector 1, coef 2(209), 3(146) */
6209 29455, /* Vector 62, coef 3(115) Vector 63, 6209 29455, /* Vector 62, coef 3(115) Vector 63,
6210 * Coef 1( 15) */ 6210 * Coef 1( 15) */
6211 -5029 /* Vector 63, coef 2(236), 3( 91) */ 6211 -5029 /* Vector 63, coef 2(236), 3( 91) */
6212 }; 6212 };
6213 6213
6214 ShortwordRom psrPreQ2[PREQ2_NUM_OF_WORDS] = 6214 const ShortwordRom psrPreQ2[PREQ2_NUM_OF_WORDS] =
6215 { 6215 {
6216 -14954, /* Vector 0, coef 1(197), 2(150) */ 6216 -14954, /* Vector 0, coef 1(197), 2(150) */
6217 -26695, /* Vector 0, coef 3(151) Vector 1, 6217 -26695, /* Vector 0, coef 3(151) Vector 1,
6218 * Coef 1(185) */ 6218 * Coef 1(185) */
6219 -31091, /* Vector 1, coef 2(134), 3(141) */ 6219 -31091, /* Vector 1, coef 2(134), 3(141) */
6277 -21144, /* Vector 30, coef 3(173) Vector 31, 6277 -21144, /* Vector 30, coef 3(173) Vector 31,
6278 * Coef 1(104) */ 6278 * Coef 1(104) */
6279 30111 /* Vector 31, coef 2(117), 3(159) */ 6279 30111 /* Vector 31, coef 2(117), 3(159) */
6280 }; 6280 };
6281 6281
6282 ShortwordRom psrPreQ3[PREQ3_NUM_OF_WORDS] = 6282 const ShortwordRom psrPreQ3[PREQ3_NUM_OF_WORDS] =
6283 { 6283 {
6284 -28246, /* Vector 0, coef 1(145), 2(170) */ 6284 -28246, /* Vector 0, coef 1(145), 2(170) */
6285 30356, /* Vector 0, coef 3(118), 4(148) */ 6285 30356, /* Vector 0, coef 3(118), 4(148) */
6286 -31320, /* Vector 1, coef 1(133), 2(168) */ 6286 -31320, /* Vector 1, coef 1(133), 2(168) */
6287 27523, /* Vector 1, coef 3(107), 4(131) */ 6287 27523, /* Vector 1, coef 3(107), 4(131) */
6317 6317
6318 6318
6319 /* size of the vq subset in the kth segment */ 6319 /* size of the vq subset in the kth segment */
6320 /*------------------------------------------*/ 6320 /*------------------------------------------*/
6321 6321
6322 ShortwordRom psrQuantSz[QUANT_NUM_OF_TABLES] = 6322 const ShortwordRom psrQuantSz[QUANT_NUM_OF_TABLES] =
6323 { 6323 {
6324 1 << (QUANT1_NUM_OF_BITS - PREQ1_NUM_OF_BITS), 6324 1 << (QUANT1_NUM_OF_BITS - PREQ1_NUM_OF_BITS),
6325 1 << (QUANT2_NUM_OF_BITS - PREQ2_NUM_OF_BITS), 6325 1 << (QUANT2_NUM_OF_BITS - PREQ2_NUM_OF_BITS),
6326 1 << (QUANT3_NUM_OF_BITS - PREQ3_NUM_OF_BITS) 6326 1 << (QUANT3_NUM_OF_BITS - PREQ3_NUM_OF_BITS)
6327 }; 6327 };
6328 6328
6329 6329
6330 /* pre-quantizer size */ 6330 /* pre-quantizer size */
6331 /*--------------------*/ 6331 /*--------------------*/
6332 6332
6333 ShortwordRom psrPreQSz[QUANT_NUM_OF_TABLES] = 6333 const ShortwordRom psrPreQSz[QUANT_NUM_OF_TABLES] =
6334 { 6334 {
6335 1 << PREQ1_NUM_OF_BITS, 6335 1 << PREQ1_NUM_OF_BITS,
6336 1 << PREQ2_NUM_OF_BITS, 6336 1 << PREQ2_NUM_OF_BITS,
6337 1 << PREQ3_NUM_OF_BITS 6337 1 << PREQ3_NUM_OF_BITS
6338 }; 6338 };
6339 6339
6340 6340
6341 /* reflection coeff scalar quantizer */ 6341 /* reflection coeff scalar quantizer */
6342 /*-----------------------------------*/ 6342 /*-----------------------------------*/
6343 6343
6344 ShortwordRom psrSQuant[SQUANT_NUM_OF_ROWS] = 6344 const ShortwordRom psrSQuant[SQUANT_NUM_OF_ROWS] =
6345 { 6345 {
6346 -32766, -32758, -32746, -32729, 6346 -32766, -32758, -32746, -32729,
6347 -32707, -32680, -32648, -32611, 6347 -32707, -32680, -32648, -32611,
6348 -32570, -32523, -32472, -32416, 6348 -32570, -32523, -32472, -32416,
6349 -32355, -32289, -32219, -32143, 6349 -32355, -32289, -32219, -32143,
6411 6411
6412 6412
6413 /* index structure for LPC Vector Quantizer */ 6413 /* index structure for LPC Vector Quantizer */
6414 /*------------------------------------------*/ 6414 /*------------------------------------------*/
6415 6415
6416 struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES] = 6416 const struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES] =
6417 { 6417 {
6418 {1, 3, 3}, /* Table 1 - low, high, length */ 6418 {1, 3, 3}, /* Table 1 - low, high, length */
6419 {4, 6, 3}, /* Table 2 - low, high, length */ 6419 {4, 6, 3}, /* Table 2 - low, high, length */
6420 {7, 10, 4} /* Table 3 - low, high, length */ 6420 {7, 10, 4} /* Table 3 - low, high, length */
6421 }; 6421 };
6422 6422
6423 6423
6424 /* square root of p0 table */ 6424 /* square root of p0 table */
6425 /*-------------------------*/ 6425 /*-------------------------*/
6426 6426
6427 ShortwordRom ppsrSqrtP0[SQRTP0_NUM_OF_MODES][SQRTP0_NUM_OF_ROWS] = 6427 const ShortwordRom ppsrSqrtP0[SQRTP0_NUM_OF_MODES][SQRTP0_NUM_OF_ROWS] =
6428 { 6428 {
6429 { 6429 {
6430 23853, 24682, 21337, 16698, 6430 23853, 24682, 21337, 16698,
6431 27731, 24699, 8804, 16227, 6431 27731, 24699, 8804, 16227,
6432 29760, 24223, 30248, 30903, 6432 29760, 24223, 30248, 30903,
6460 6460
6461 6461
6462 /* interpolation filter used for C and G */ 6462 /* interpolation filter used for C and G */
6463 /*---------------------------------------*/ 6463 /*---------------------------------------*/
6464 6464
6465 ShortwordRom ppsrCGIntFilt[CGINTFILT_MACS][OS_FCTR] = 6465 const ShortwordRom ppsrCGIntFilt[CGINTFILT_MACS][OS_FCTR] =
6466 { 6466 {
6467 {0, 126, 0, -299, -778, -1381}, 6467 {0, 126, 0, -299, -778, -1381},
6468 {-1980, -2375, -2326, -1596, 0, 2535}, 6468 {-1980, -2375, -2326, -1596, 0, 2535},
6469 {5936, 9968, 14254, 18322, 21678, 23889}, 6469 {5936, 9968, 14254, 18322, 21678, 23889},
6470 {24661, 23889, 21678, 18322, 14254, 9968}, 6470 {24661, 23889, 21678, 18322, 14254, 9968},
6474 6474
6475 6475
6476 /* interpolation filter used pitch */ 6476 /* interpolation filter used pitch */
6477 /*---------------------------------*/ 6477 /*---------------------------------*/
6478 6478
6479 ShortwordRom ppsrPVecIntFilt[PVECINTFILT_MACS][OS_FCTR] = 6479 const ShortwordRom ppsrPVecIntFilt[PVECINTFILT_MACS][OS_FCTR] =
6480 { 6480 {
6481 {0, 183, 249, 251, 149, -67}, 6481 {0, 183, 249, 251, 149, -67},
6482 {-368, -681, -897, -904, -622, -38}, 6482 {-368, -681, -897, -904, -622, -38},
6483 {762, 1595, 2214, 2360, 1842, 611}, 6483 {762, 1595, 2214, 2360, 1842, 611},
6484 {-1186, -3195, -4898, -5708, -5089, -2696}, 6484 {-1186, -3195, -4898, -5708, -5089, -2696},
6492 6492
6493 6493
6494 /* fractional pitch lag table lag*OS_FCTR */ 6494 /* fractional pitch lag table lag*OS_FCTR */
6495 /*----------------------------------------*/ 6495 /*----------------------------------------*/
6496 6496
6497 ShortwordRom psrLagTbl[LAGTBL_NUM_OF_ROWS] = 6497 const ShortwordRom psrLagTbl[LAGTBL_NUM_OF_ROWS] =
6498 { 6498 {
6499 126, 128, 130, 132, 134, 136, 138, 139, 6499 126, 128, 130, 132, 134, 136, 138, 139,
6500 140, 141, 142, 143, 144, 145, 146, 147, 6500 140, 141, 142, 143, 144, 145, 146, 147,
6501 148, 149, 150, 151, 152, 153, 154, 155, 6501 148, 149, 150, 151, 152, 153, 154, 155,
6502 156, 157, 158, 159, 160, 161, 162, 163, 6502 156, 157, 158, 159, 160, 161, 162, 163,
6532 6532
6533 6533
6534 /* R0 decision value table defines range (not the levels themselves */ 6534 /* R0 decision value table defines range (not the levels themselves */
6535 /*------------------------------------------------------------------*/ 6535 /*------------------------------------------------------------------*/
6536 6536
6537 ShortwordRom psrR0DecTbl[R0DECTBL_NUM_OF_ROWS] = 6537 const ShortwordRom psrR0DecTbl[R0DECTBL_NUM_OF_ROWS] =
6538 { 6538 {
6539 6, 7, 8, 9, 10, 12, 13, 15, 6539 6, 7, 8, 9, 10, 12, 13, 15,
6540 16, 18, 21, 23, 26, 29, 33, 37, 6540 16, 18, 21, 23, 26, 29, 33, 37,
6541 41, 46, 52, 58, 65, 73, 82, 92, 6541 41, 46, 52, 58, 65, 73, 82, 92,
6542 103, 115, 130, 145, 163, 183, 205, 230, 6542 103, 115, 130, 145, 163, 183, 205, 230,
6547 }; 6547 };
6548 6548
6549 /* high pass filter coefficients */ 6549 /* high pass filter coefficients */
6550 /*-------------------------------*/ 6550 /*-------------------------------*/
6551 6551
6552 ShortwordRom psrHPFCoefs[HPFCOEFS_NUM_OF_CODES] = 6552 const ShortwordRom psrHPFCoefs[HPFCOEFS_NUM_OF_CODES] =
6553 { 6553 {
6554 10979, -21954, 10979, -14071, 30347, 6554 10979, -21954, 10979, -14071, 30347,
6555 10979, -21936, 10979, -15385, 31632 6555 10979, -21936, 10979, -15385, 31632
6556 }; 6556 };
6557 6557
6558 6558
6559 /* spectral smoothing coefficients */ 6559 /* spectral smoothing coefficients */
6560 /*---------------------------------*/ 6560 /*---------------------------------*/
6561 6561
6562 ShortwordRom psrNWCoefs[NWCOEFS_NUM_OF_CODES] = 6562 const ShortwordRom psrNWCoefs[NWCOEFS_NUM_OF_CODES] =
6563 { 6563 {
6564 30474, 28341, 26357, 24512, 22796, 6564 30474, 28341, 26357, 24512, 22796,
6565 21201, 19717, 18336, 17053, 15859, 6565 21201, 19717, 18336, 17053, 15859,
6566 22938, 16056, 11239, 7868, 5507, 6566 22938, 16056, 11239, 7868, 5507,
6567 3855, 2699, 1889, 1322, 926 6567 3855, 2699, 1889, 1322, 926
6569 6569
6570 6570
6571 /* spectral smoothing coefficients for FLAT */ 6571 /* spectral smoothing coefficients for FLAT */
6572 /*------------------------------------------*/ 6572 /*------------------------------------------*/
6573 6573
6574 LongwordRom pL_rFlatSstCoefs[FLATSSTCOEFS_NUM_OF_CODES] = 6574 const LongwordRom pL_rFlatSstCoefs[FLATSSTCOEFS_NUM_OF_CODES] =
6575 { 6575 {
6576 2145262551, 2138972761, 2129579484, 2118274784, 2106083684, 6576 2145262551, 2138972761, 2129579484, 2118274784, 2106083684,
6577 2093615080, 2081026796, 2068156528, 2054704628, 2040382328 6577 2093615080, 2081026796, 2068156528, 2054704628, 2040382328
6578 }; 6578 };
6579 6579
6580 ShortwordRom psrOldCont[4] = { 6580 const ShortwordRom psrOldCont[4] = {
6581 0x599a, /* 0.70 */ 6581 0x599a, /* 0.70 */
6582 0x30a4, /* 0.38 */ 6582 0x30a4, /* 0.38 */
6583 0x0a3d, /* 0.08 */ 6583 0x0a3d, /* 0.08 */
6584 0x0000, /* 0.00 */ 6584 0x0000, /* 0.00 */
6585 }; 6585 };
6586 6586
6587 ShortwordRom psrNewCont[4] = { 6587 const ShortwordRom psrNewCont[4] = {
6588 0x2666, /* 0.30 */ 6588 0x2666, /* 0.30 */
6589 0x4f5c, /* 0.62 */ 6589 0x4f5c, /* 0.62 */
6590 0x75c3, /* 0.92 */ 6590 0x75c3, /* 0.92 */
6591 0x7fff, /* 1.00 */ 6591 0x7fff, /* 1.00 */
6592 }; 6592 };