changeset 618:e6e9d5104503

libgsmhr1: integrate DTX encoder function lpcCorrQntz()
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Mar 2026 20:11:30 +0000
parents ff5857556c44
children 8fadd238642b
files libgsmhr1/dtx_enc.c libgsmhr1/dtx_enc.h
diffstat 2 files changed, 18 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmhr1/dtx_enc.c	Thu Mar 05 19:48:10 2026 +0000
+++ b/libgsmhr1/dtx_enc.c	Thu Mar 05 20:11:30 2026 +0000
@@ -22,6 +22,7 @@
 #include "dtx_const.h"
 #include "dtx_enc.h"
 #include "dtx_rxfe.h"
+#include "sp_frm.h"
 
 /*________________________________________________________________________
  |                                                                        |
@@ -240,7 +241,7 @@
       /* Quantize the averaged correlation */
       /* --------------------------------- */
 
-      lpcCorrQntz(pL_RefCorr,
+      lpcCorrQntz(st, pL_RefCorr,
                   pswFinalRc,
                   cn_st->piRefVqCodewds);
 
@@ -455,10 +456,8 @@
  *
  *************************************************************************/
 
-#if 0
-void   lpcCorrQntz(Longword pL_CorrelSeq[],
-                          Shortword pswFinalRc[],
-                          int piVQCodewds[])
+void lpcCorrQntz(struct gsmhr_encoder_state *st, Longword pL_CorrelSeq[],
+		 Shortword pswFinalRc[], int piVQCodewds[])
 {
 
 /*_________________________________________________________________________
@@ -538,25 +537,25 @@
     /* do aflat for all vectors in the list */
     /*--------------------------------------*/
 
-    setupPreQ(iSeg, quantList.iRCIndex);        /* set up vector ptrs */
+    setupPreQ(st, iSeg, quantList.iRCIndex);    /* set up vector ptrs */
 
     for (iCnt = 0; iCnt < quantList.iNum; iCnt++)
     {
       /* get a vector */
       /*--------------*/
 
-      getNextVec(pswRc);
+      getNextVec(st, pswRc);
 
       /* clear the limiter flag */
       /*------------------------*/
 
-      iLimit = 0;
+      st->iLimit = 0;
 
       /* find the error values for each vector */
       /*---------------------------------------*/
 
       quantList.pswPredErr[iCnt] =
-              aflatRecursion(&pswRc[psvqIndex[iSeg - 1].l],
+              aflatRecursion(st, &pswRc[psvqIndex[iSeg - 1].l],
                              pswPBar, pswVBar,
                              ppswPAddrs, ppswVAddrs,
                              psvqIndex[iSeg - 1].len);
@@ -564,7 +563,7 @@
       /* check the limiter flag */
       /*------------------------*/
 
-      if (iLimit)
+      if (st->iLimit)
         quantList.pswPredErr[iCnt] = 0x7fff;    /* set error to bad value */
 
     }                                  /* done list loop */
@@ -583,7 +582,7 @@
       quantList.iNum = psrQuantSz[iSeg - 1];
       quantList.iRCIndex = bestPql[iVec].iRCIndex * psrQuantSz[iSeg - 1];
 
-      setupQuant(iSeg, quantList.iRCIndex);     /* set up vector ptrs */
+      setupQuant(st, iSeg, quantList.iRCIndex);     /* set up vector ptrs */
 
       /* do aflat recursion on each element of list */
       /*--------------------------------------------*/
@@ -593,18 +592,18 @@
         /* get a vector */
         /*--------------*/
 
-        getNextVec(pswRc);
+        getNextVec(st, pswRc);
 
         /* clear the limiter flag */
         /*------------------------*/
 
-        iLimit = 0;
+        st->iLimit = 0;
 
         /* find the error values for each vector */
         /*---------------------------------------*/
 
         quantList.pswPredErr[iCnt] =
-                aflatRecursion(&pswRc[psvqIndex[iSeg - 1].l],
+                aflatRecursion(st, &pswRc[psvqIndex[iSeg - 1].l],
                                pswPBar, pswVBar,
                                ppswPAddrs, ppswVAddrs,
                                psvqIndex[iSeg - 1].len);
@@ -612,7 +611,7 @@
         /* check the limiter flag */
         /*------------------------*/
 
-        if (iLimit)
+        if (st->iLimit)
           quantList.pswPredErr[iCnt] = 0x7fff;  /* set error to the worst
                                                  * value */
 
@@ -632,8 +631,8 @@
     /* find the quantized reflection coefficients */
     /*--------------------------------------------*/
 
-    setupQuant(iSeg, bestQl[iSeg].iRCIndex);    /* set up vector ptrs */
-    getNextVec((Shortword *) (pswFinalRc - 1));
+    setupQuant(st, iSeg, bestQl[iSeg].iRCIndex);    /* set up vector ptrs */
+    getNextVec(st, (Shortword *) (pswFinalRc - 1));
 
 
     /* Update pBarFull and vBarFull for the next Rc-VQ segment, and */
@@ -653,4 +652,3 @@
     piVQCodewds[iSeg - 1] = bestQl[iSeg].iRCIndex;
 
 }
-#endif
--- a/libgsmhr1/dtx_enc.h	Thu Mar 05 19:48:10 2026 +0000
+++ b/libgsmhr1/dtx_enc.h	Thu Mar 05 20:11:30 2026 +0000
@@ -21,8 +21,7 @@
 		  Longword *pL_UnqntzdCorr, Longword pL_R0Hist[],
 		  Longword ppL_CorrHist[OVERHANG][NP + 1]);
 
-void   lpcCorrQntz(Longword pL_CorrelSeq[],
-                          Shortword pswFinalRc[],
-                          int piVQCodewds[]);
+void lpcCorrQntz(struct gsmhr_encoder_state *st, Longword pL_CorrelSeq[],
+		 Shortword pswFinalRc[], int piVQCodewds[]);
 
 #endif