changeset 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 c275e57132f8
files libgsmhr1/Makefile libgsmhr1/namespace.list libgsmhr1/sp_rom.c libgsmhr1/sp_rom.h
diffstat 4 files changed, 56 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmhr1/Makefile	Wed Jun 19 01:55:54 2024 +0000
+++ b/libgsmhr1/Makefile	Wed Jun 19 02:13:56 2024 +0000
@@ -1,7 +1,8 @@
 OBJS=	dhf_params.o enc_out_order.o mathdp31.o mathhalf.o pack_frame.o \
-	rtp_in.o sid_detect.o sid_reset.o twts002_in.o twts002_out.o \
+	rtp_in.o sid_detect.o sid_reset.o sp_rom.o twts002_in.o twts002_out.o \
 	unpack_frame.o
-HDRS=	enc_out_order.h mathdp31.h mathhalf.h namespace.h tw_gsmhr.h typedefs.h
+HDRS=	enc_out_order.h mathdp31.h mathhalf.h namespace.h sp_rom.h tw_gsmhr.h \
+	typedefs.h
 LIB=	libgsmhr1.a
 
 include ../config.defs
--- a/libgsmhr1/namespace.list	Wed Jun 19 01:55:54 2024 +0000
+++ b/libgsmhr1/namespace.list	Wed Jun 19 02:13:56 2024 +0000
@@ -14,3 +14,9 @@
 L_mpy_ls L_mpy_ll isSwLimit isLwLimit
 
 fillBitAlloc
+
+pppsrGsp0 pppsrUvCodeVec pppsrVcdCodeVec
+psrQuant1 psrQuant2 psrQuant3 psrPreQ1 psrPreQ2 psrPreQ3
+psrQuantSz psrPreQSz psrSQuant psvqIndex ppsrSqrtP0
+ppsrCGIntFilt ppsrPVecIntFilt psrLagTbl psrR0DecTbl
+psrHPFCoefs psrNWCoefs pL_rFlatSstCoefs psrOldCont psrNewCont
--- a/libgsmhr1/sp_rom.c	Wed Jun 19 01:55:54 2024 +0000
+++ b/libgsmhr1/sp_rom.c	Wed Jun 19 02:13:56 2024 +0000
@@ -13,7 +13,7 @@
  |                              Include Files                              |
  |_________________________________________________________________________|
 */
-#include "mathhalf.h"
+#include "namespace.h"
 #include "sp_rom.h"
 
 /*_________________________________________________________________________
@@ -30,7 +30,7 @@
   THE GSP0 TABLE WAS READ FROM THE FILES gsp0_1_*.qnt_97CQ_4
   ET VALUES WRITTEN WERE SCALED BY  4  */
 
-ShortwordRom pppsrGsp0
+const ShortwordRom pppsrGsp0
        [GSP0_NUM_OF_TABLES][GSP0_NUM][GSP0_VECTOR_SIZE] =
 {
   {
@@ -176,7 +176,7 @@
 /* unvoiced code vectors */
 /*-----------------------*/
 
-ShortwordRom pppsrUvCodeVec
+const ShortwordRom pppsrUvCodeVec
        [UVCODEVEC_NUM_OF_CODE_BOOKS][UVCODEVEC_NUM_OF_CODE_BITS][S_LEN] =
 {
   {
@@ -329,7 +329,7 @@
 /* voiced code vectors */
 /*---------------------*/
 
-ShortwordRom pppsrVcdCodeVec
+const ShortwordRom pppsrVcdCodeVec
        [VCDCODEVEC_NUM_OF_CODE_BOOKS][VCDCODEVEC_NUM_OF_CODE_BITS][S_LEN] =
 {
   {
@@ -430,7 +430,7 @@
 /* vector quantizer tables */
 /*-------------------------*/
 
-ShortwordRom psrQuant1
+const ShortwordRom psrQuant1
        [QUANT1_NUM_OF_WORDS] =
 {
   -5980,                               /* Vector    0, coef 1(232), 2(164) */
@@ -4531,7 +4531,7 @@
   -4772                                /* Vector 2047, coef 2(237), 3( 92) */
 };
 
-ShortwordRom psrQuant2[QUANT2_NUM_OF_WORDS] =
+const ShortwordRom psrQuant2[QUANT2_NUM_OF_WORDS] =
 {
   -15195,                              /* Vector    0, coef 1(196), 2(165) */
   -24371,                              /* Vector    0, coef 3(160) Vector 1,
@@ -5559,7 +5559,7 @@
   27538                                /* Vector  511, coef 2(107), 3(146) */
 };
 
-ShortwordRom psrQuant3[QUANT3_NUM_OF_WORDS] =
+const ShortwordRom psrQuant3[QUANT3_NUM_OF_WORDS] =
 {
   -26192,                              /* Vector    0, coef 1(153), 2(176) */
   -32358,                              /* Vector    0, coef 3(129), 4(154) */
@@ -6079,7 +6079,7 @@
 /* lpc pre-quantizer */
 /*-------------------*/
 
-ShortwordRom psrPreQ1[PREQ1_NUM_OF_WORDS] =
+const ShortwordRom psrPreQ1[PREQ1_NUM_OF_WORDS] =
 {
   -13624,                              /* Vector    0, coef 1(202), 2(200) */
   -31561,                              /* Vector    0, coef 3(132) Vector 1,
@@ -6211,7 +6211,7 @@
   -5029                                /* Vector   63, coef 2(236), 3( 91) */
 };
 
-ShortwordRom psrPreQ2[PREQ2_NUM_OF_WORDS] =
+const ShortwordRom psrPreQ2[PREQ2_NUM_OF_WORDS] =
 {
   -14954,                              /* Vector    0, coef 1(197), 2(150) */
   -26695,                              /* Vector    0, coef 3(151) Vector 1,
@@ -6279,7 +6279,7 @@
   30111                                /* Vector   31, coef 2(117), 3(159) */
 };
 
-ShortwordRom psrPreQ3[PREQ3_NUM_OF_WORDS] =
+const ShortwordRom psrPreQ3[PREQ3_NUM_OF_WORDS] =
 {
   -28246,                              /* Vector    0, coef 1(145), 2(170) */
   30356,                               /* Vector    0, coef 3(118), 4(148) */
@@ -6319,7 +6319,7 @@
 /* size of the vq subset in the kth segment */
 /*------------------------------------------*/
 
-ShortwordRom psrQuantSz[QUANT_NUM_OF_TABLES] =
+const ShortwordRom psrQuantSz[QUANT_NUM_OF_TABLES] =
 {
   1 << (QUANT1_NUM_OF_BITS - PREQ1_NUM_OF_BITS),
   1 << (QUANT2_NUM_OF_BITS - PREQ2_NUM_OF_BITS),
@@ -6330,7 +6330,7 @@
 /* pre-quantizer size */
 /*--------------------*/
 
-ShortwordRom psrPreQSz[QUANT_NUM_OF_TABLES] =
+const ShortwordRom psrPreQSz[QUANT_NUM_OF_TABLES] =
 {
   1 << PREQ1_NUM_OF_BITS,
   1 << PREQ2_NUM_OF_BITS,
@@ -6341,7 +6341,7 @@
 /* reflection coeff scalar quantizer */
 /*-----------------------------------*/
 
-ShortwordRom psrSQuant[SQUANT_NUM_OF_ROWS] =
+const ShortwordRom psrSQuant[SQUANT_NUM_OF_ROWS] =
 {
   -32766, -32758, -32746, -32729,
   -32707, -32680, -32648, -32611,
@@ -6413,7 +6413,7 @@
 /* index structure for LPC Vector Quantizer */
 /*------------------------------------------*/
 
-struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES] =
+const struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES] =
 {
   {1, 3, 3},                           /* Table 1 - low, high, length */
   {4, 6, 3},                           /* Table 2 - low, high, length */
@@ -6424,7 +6424,7 @@
 /* square root of p0 table */
 /*-------------------------*/
 
-ShortwordRom ppsrSqrtP0[SQRTP0_NUM_OF_MODES][SQRTP0_NUM_OF_ROWS] =
+const ShortwordRom ppsrSqrtP0[SQRTP0_NUM_OF_MODES][SQRTP0_NUM_OF_ROWS] =
 {
   {
     23853, 24682, 21337, 16698,
@@ -6462,7 +6462,7 @@
 /* interpolation filter used for C and G */
 /*---------------------------------------*/
 
-ShortwordRom ppsrCGIntFilt[CGINTFILT_MACS][OS_FCTR] =
+const ShortwordRom ppsrCGIntFilt[CGINTFILT_MACS][OS_FCTR] =
 {
   {0, 126, 0, -299, -778, -1381},
   {-1980, -2375, -2326, -1596, 0, 2535},
@@ -6476,7 +6476,7 @@
 /* interpolation filter used pitch */
 /*---------------------------------*/
 
-ShortwordRom ppsrPVecIntFilt[PVECINTFILT_MACS][OS_FCTR] =
+const ShortwordRom ppsrPVecIntFilt[PVECINTFILT_MACS][OS_FCTR] =
 {
   {0, 183, 249, 251, 149, -67},
   {-368, -681, -897, -904, -622, -38},
@@ -6494,7 +6494,7 @@
 /* fractional pitch lag table lag*OS_FCTR */
 /*----------------------------------------*/
 
-ShortwordRom psrLagTbl[LAGTBL_NUM_OF_ROWS] =
+const ShortwordRom psrLagTbl[LAGTBL_NUM_OF_ROWS] =
 {
   126, 128, 130, 132, 134, 136, 138, 139,
   140, 141, 142, 143, 144, 145, 146, 147,
@@ -6534,7 +6534,7 @@
 /* R0 decision value table defines range (not the levels themselves */
 /*------------------------------------------------------------------*/
 
-ShortwordRom psrR0DecTbl[R0DECTBL_NUM_OF_ROWS] =
+const ShortwordRom psrR0DecTbl[R0DECTBL_NUM_OF_ROWS] =
 {
   6, 7, 8, 9, 10, 12, 13, 15,
   16, 18, 21, 23, 26, 29, 33, 37,
@@ -6549,7 +6549,7 @@
 /* high pass filter coefficients */
 /*-------------------------------*/
 
-ShortwordRom psrHPFCoefs[HPFCOEFS_NUM_OF_CODES] =
+const ShortwordRom psrHPFCoefs[HPFCOEFS_NUM_OF_CODES] =
 {
   10979, -21954, 10979, -14071, 30347,
   10979, -21936, 10979, -15385, 31632
@@ -6559,7 +6559,7 @@
 /* spectral smoothing coefficients */
 /*---------------------------------*/
 
-ShortwordRom psrNWCoefs[NWCOEFS_NUM_OF_CODES] =
+const ShortwordRom psrNWCoefs[NWCOEFS_NUM_OF_CODES] =
 {
   30474, 28341, 26357, 24512, 22796,
   21201, 19717, 18336, 17053, 15859,
@@ -6571,20 +6571,20 @@
 /* spectral smoothing coefficients for FLAT */
 /*------------------------------------------*/
 
-LongwordRom pL_rFlatSstCoefs[FLATSSTCOEFS_NUM_OF_CODES] =
+const LongwordRom pL_rFlatSstCoefs[FLATSSTCOEFS_NUM_OF_CODES] =
 {
   2145262551, 2138972761, 2129579484, 2118274784, 2106083684,
   2093615080, 2081026796, 2068156528, 2054704628, 2040382328
 };
 
-ShortwordRom psrOldCont[4] = {
+const ShortwordRom psrOldCont[4] = {
   0x599a,                              /* 0.70 */
   0x30a4,                              /* 0.38 */
   0x0a3d,                              /* 0.08 */
   0x0000,                              /* 0.00 */
 };
 
-ShortwordRom psrNewCont[4] = {
+const ShortwordRom psrNewCont[4] = {
   0x2666,                              /* 0.30 */
   0x4f5c,                              /* 0.62 */
   0x75c3,                              /* 0.92 */
--- a/libgsmhr1/sp_rom.h	Wed Jun 19 01:55:54 2024 +0000
+++ b/libgsmhr1/sp_rom.h	Wed Jun 19 02:13:56 2024 +0000
@@ -8,8 +8,6 @@
 #define ___ROM
 
 #include "typedefs.h"
-#include "mathhalf.h"
-#include "mathdp31.h"
 
 /*_________________________________________________________________________
  |                                                                         |
@@ -23,7 +21,7 @@
 #define GSP0_NUM 32
 #define GSP0_VECTOR_SIZE 5
 
-extern ShortwordRom pppsrGsp0
+extern const ShortwordRom pppsrGsp0
        [GSP0_NUM_OF_TABLES][GSP0_NUM][GSP0_VECTOR_SIZE];
 
 
@@ -32,7 +30,7 @@
 #define UVCODEVEC_NUM_OF_CODE_BOOKS 2
 #define UVCODEVEC_NUM_OF_CODE_BITS 7
 
-extern ShortwordRom pppsrUvCodeVec
+extern const ShortwordRom pppsrUvCodeVec
        [UVCODEVEC_NUM_OF_CODE_BOOKS][UVCODEVEC_NUM_OF_CODE_BITS][S_LEN];
 
 
@@ -41,7 +39,7 @@
 #define VCDCODEVEC_NUM_OF_CODE_BOOKS 1
 #define VCDCODEVEC_NUM_OF_CODE_BITS 9
 
-extern ShortwordRom pppsrVcdCodeVec
+extern const ShortwordRom pppsrVcdCodeVec
        [VCDCODEVEC_NUM_OF_CODE_BOOKS][VCDCODEVEC_NUM_OF_CODE_BITS][S_LEN];
 
 
@@ -64,11 +62,11 @@
 #define QUANT3_NUM_OF_STAGES 4
 #define QUANT3_NUM_OF_WORDS (QUANT3_NUM_OF_ROWS*QUANT3_NUM_OF_STAGES/2)
 
-extern ShortwordRom psrQuant1[QUANT1_NUM_OF_WORDS];
+extern const ShortwordRom psrQuant1[QUANT1_NUM_OF_WORDS];
 
-extern ShortwordRom psrQuant2[QUANT2_NUM_OF_WORDS];
+extern const ShortwordRom psrQuant2[QUANT2_NUM_OF_WORDS];
 
-extern ShortwordRom psrQuant3[QUANT3_NUM_OF_WORDS];
+extern const ShortwordRom psrQuant3[QUANT3_NUM_OF_WORDS];
 
 
 /* lpc pre-quantizer */
@@ -88,21 +86,21 @@
 #define PREQ3_NUM_OF_STAGES 4
 #define PREQ3_NUM_OF_WORDS (PREQ3_NUM_OF_ROWS*PREQ3_NUM_OF_STAGES/2)
 
-extern ShortwordRom psrPreQ1[PREQ1_NUM_OF_WORDS];
+extern const ShortwordRom psrPreQ1[PREQ1_NUM_OF_WORDS];
 
-extern ShortwordRom psrPreQ2[PREQ2_NUM_OF_WORDS];
+extern const ShortwordRom psrPreQ2[PREQ2_NUM_OF_WORDS];
 
-extern ShortwordRom psrPreQ3[PREQ3_NUM_OF_WORDS];
+extern const ShortwordRom psrPreQ3[PREQ3_NUM_OF_WORDS];
 
 
 /* size of the vq subset in the kth segment */
 /*------------------------------------------*/
-extern ShortwordRom psrQuantSz[QUANT_NUM_OF_TABLES];
+extern const ShortwordRom psrQuantSz[QUANT_NUM_OF_TABLES];
 
 
 /* pre-quantizer size */
 /*--------------------*/
-extern ShortwordRom psrPreQSz[QUANT_NUM_OF_TABLES];
+extern const ShortwordRom psrPreQSz[QUANT_NUM_OF_TABLES];
 
 
 /* reflection coeff scalar quantizer */
@@ -110,7 +108,7 @@
 #define SQUANT_NUM_OF_BITS 8
 #define SQUANT_NUM_OF_ROWS (1 << SQUANT_NUM_OF_BITS)
 
-extern ShortwordRom psrSQuant[SQUANT_NUM_OF_ROWS];
+extern const ShortwordRom psrSQuant[SQUANT_NUM_OF_ROWS];
 
 
 /* index structure for LPC Vector Quantizer */
@@ -125,7 +123,7 @@
 };
 
 
-extern struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES];
+extern const struct IsubLHn psvqIndex[QUANT_NUM_OF_TABLES];
 
 
 /* square root of p0 table */
@@ -134,28 +132,28 @@
 #define SQRTP0_NUM_OF_ROWS (1 << SQRTP0_NUM_OF_BITS)
 #define SQRTP0_NUM_OF_MODES 3
 
-extern ShortwordRom ppsrSqrtP0[SQRTP0_NUM_OF_MODES][SQRTP0_NUM_OF_ROWS];
+extern const ShortwordRom ppsrSqrtP0[SQRTP0_NUM_OF_MODES][SQRTP0_NUM_OF_ROWS];
 
 
 /* interpolation filter used for C and G */
 /*---------------------------------------*/
 #define CGINTFILT_MACS 6
 
-extern ShortwordRom ppsrCGIntFilt[CGINTFILT_MACS][OS_FCTR];
+extern const ShortwordRom ppsrCGIntFilt[CGINTFILT_MACS][OS_FCTR];
 
 
 /* interpolation filter used pitch */
 /*---------------------------------*/
 #define PVECINTFILT_MACS 10
 
-extern ShortwordRom ppsrPVecIntFilt[PVECINTFILT_MACS][OS_FCTR];
+extern const ShortwordRom ppsrPVecIntFilt[PVECINTFILT_MACS][OS_FCTR];
 
 
 /* fractional pitch lag table lag*OS_FCTR */
 /*----------------------------------------*/
 #define LAGTBL_NUM_OF_ROWS 256
 
-extern ShortwordRom psrLagTbl[LAGTBL_NUM_OF_ROWS];
+extern const ShortwordRom psrLagTbl[LAGTBL_NUM_OF_ROWS];
 
 
 /* R0 decision value table defines range (not the levels themselves */
@@ -164,30 +162,30 @@
 #define R0DECTBL_NUM_OF_R0BITS 5
 #define R0DECTBL_NUM_OF_ROWS ((1 << R0DECTBL_NUM_OF_R0BITS)*2 - 1)
 
-extern ShortwordRom psrR0DecTbl[R0DECTBL_NUM_OF_ROWS];
+extern const ShortwordRom psrR0DecTbl[R0DECTBL_NUM_OF_ROWS];
 
 
 /* high pass filter coefficients */
 /*-------------------------------*/
 #define HPFCOEFS_NUM_OF_CODES 10
 
-extern ShortwordRom psrHPFCoefs[HPFCOEFS_NUM_OF_CODES];
+extern const ShortwordRom psrHPFCoefs[HPFCOEFS_NUM_OF_CODES];
 
 
 /* spectral smoothing coefficients */
 /*---------------------------------*/
 #define NWCOEFS_NUM_OF_CODES 20
 
-extern ShortwordRom psrNWCoefs[NWCOEFS_NUM_OF_CODES];
+extern const ShortwordRom psrNWCoefs[NWCOEFS_NUM_OF_CODES];
 
 
 /* spectral smoothing coefficients for FLAT */
 /*------------------------------------------*/
 #define FLATSSTCOEFS_NUM_OF_CODES 10
 
-extern LongwordRom pL_rFlatSstCoefs[FLATSSTCOEFS_NUM_OF_CODES];
+extern const LongwordRom pL_rFlatSstCoefs[FLATSSTCOEFS_NUM_OF_CODES];
 
-extern ShortwordRom psrOldCont[4];
-extern ShortwordRom psrNewCont[4];
+extern const ShortwordRom psrOldCont[4];
+extern const ShortwordRom psrNewCont[4];
 
 #endif