diff libgsmefr/d_plsf_5.c @ 63:6a623cb57d07

libgsmefr: d_plsf_5.c compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Nov 2022 01:11:04 +0000
parents 49dd1ac8e75b
children d80e9f12a1d1
line wrap: on
line diff
--- a/libgsmefr/d_plsf_5.c	Sat Nov 26 00:53:14 2022 +0000
+++ b/libgsmefr/d_plsf_5.c	Sat Nov 26 01:11:04 2022 +0000
@@ -13,15 +13,20 @@
  *
  *************************************************************************/
 
+#include "gsm_efr.h"
 #include "typedef.h"
+#include "namespace.h"
 #include "basic_op.h"
-#include "count.h"
+#include "no_count.h"
+#include "codec.h"
 #include "sig_proc.h"
+#include "memops.h"
 
 #include "q_plsf_5.tab"         /* Codebooks of LSF prediction residual */
 
 #include "cnst.h"
 #include "dtx.h"
+#include "dec_state.h"
 
 /* M  ->order of linear prediction filter                      */
 /* LSF_GAP  -> Minimum distance between LSF after quantization */
@@ -36,27 +41,8 @@
 #define ALPHA     31128
 #define ONE_ALPHA 1639
 
-/* Past quantized prediction error */
-
-Word16 past_r2_q[M];
-
-/* Past dequantized lsfs */
-
-Word16 past_lsf_q[M];
-
-/* Reference LSF parameter vector (comfort noise) */
-
-Word16 lsf_p_CN[M];
-
-/*  LSF memories for comfort noise interpolation */
-
-Word16 lsf_old_CN[M], lsf_new_CN[M];
-
- /* LSF parameter buffer */
-
-extern Word16 lsf_old_rx[DTX_HANGOVER][M];
-
 void D_plsf_5 (
+    struct EFR_decoder_state *st,
     Word16 *indice,       /* input : quantization indices of 5 submatrices */
     Word16 *lsp1_q,       /* output: quantized 1st LSP vector              */
     Word16 *lsp2_q,       /* output: quantized 2nd LSP vector              */
@@ -74,42 +60,38 @@
     Word16 lsf1_q[M], lsf2_q[M];
 
     /* Update comfort noise LSF quantizer memory */
-    test (); logic16 (); 
     if ((rxdtx_ctrl & RX_UPD_SID_QUANT_MEM) != 0)
     {
-        update_lsf_p_CN (lsf_old_rx, lsf_p_CN);
+        update_lsf_p_CN (st->lsf_old_rx, st->lsf_p_CN);
     }
     /* Handle cases of comfort noise LSF decoding in which past
     valid SID frames are repeated */
 
-    test (); logic16 (); 
-    test (); logic16 (); 
-    test (); logic16 (); 
     if (((rxdtx_ctrl & RX_NO_TRANSMISSION) != 0)
         || ((rxdtx_ctrl & RX_INVALID_SID_FRAME) != 0)
         || ((rxdtx_ctrl & RX_LOST_SID_FRAME) != 0))
     {
 
-        test (); logic16 (); 
         if ((rxdtx_ctrl & RX_NO_TRANSMISSION) != 0)
         {
             /* DTX active: no transmission. Interpolate LSF values in memory */
-            interpolate_CN_lsf (lsf_old_CN, lsf_new_CN, lsf2_q, rx_dtx_state);
+            interpolate_CN_lsf (st->lsf_old_CN, st->lsf_new_CN, lsf2_q,
+                                rx_dtx_state);
         }
         else
         {                       /* Invalid or lost SID frame: use LSFs
                                    from last good SID frame */
             for (i = 0; i < M; i++)
             {
-                lsf_old_CN[i] = lsf_new_CN[i];  move16 (); 
-                lsf2_q[i] = lsf_new_CN[i];      move16 (); 
-                past_r2_q[i] = 0;               move16 (); 
+                st->lsf_old_CN[i] = st->lsf_new_CN[i];
+                lsf2_q[i] = st->lsf_new_CN[i];
+                st->past_r2_q[i] = 0;
             }
         }
 
         for (i = 0; i < M; i++)
         {
-            past_lsf_q[i] = lsf2_q[i];          move16 (); 
+            st->past_lsf_q[i] = lsf2_q[i];
         }
 
         /*  convert LSFs to the cosine domain */
@@ -118,7 +100,6 @@
         return;
     }
 
-    test (); 
     if (bfi != 0)                               /* if bad frame */
     {
         /* use the past LSFs slightly shifted towards their mean */
@@ -127,11 +108,10 @@
         {
             /* lsfi_q[i] = ALPHA*past_lsf_q[i] + ONE_ALPHA*mean_lsf[i]; */
 
-            lsf1_q[i] = add (mult (past_lsf_q[i], ALPHA),
+            lsf1_q[i] = add (mult (st->past_lsf_q[i], ALPHA),
                              mult (mean_lsf[i], ONE_ALPHA));
-                                                move16 (); 
 
-            lsf2_q[i] = lsf1_q[i];              move16 (); 
+            lsf2_q[i] = lsf1_q[i];
         }
 
         /* estimate past quantized residual to be used in next frame */
@@ -140,10 +120,9 @@
         {
             /* temp  = mean_lsf[i] +  past_r2_q[i] * PRED_FAC; */
 
-            temp = add (mean_lsf[i], mult (past_r2_q[i], PRED_FAC));
+            temp = add (mean_lsf[i], mult (st->past_r2_q[i], PRED_FAC));
 
-            past_r2_q[i] = sub (lsf2_q[i], temp);
-                                                move16 (); 
+            st->past_r2_q[i] = sub (lsf2_q[i], temp);
         }
     }
     else
@@ -199,30 +178,26 @@
         /* Use lsf_p_CN as predicted LSF vector in case of no speech
            activity */
 
-        test (); logic16 (); 
         if ((rxdtx_ctrl & RX_SP_FLAG) != 0)
         {
             for (i = 0; i < M; i++)
             {
-                temp = add (mean_lsf[i], mult (past_r2_q[i], PRED_FAC));
+                temp = add (mean_lsf[i], mult (st->past_r2_q[i], PRED_FAC));
                 lsf1_q[i] = add (lsf1_r[i], temp);
-                                                move16 (); 
                 lsf2_q[i] = add (lsf2_r[i], temp);
-                                                move16 (); 
-                past_r2_q[i] = lsf2_r[i];       move16 (); 
+                st->past_r2_q[i] = lsf2_r[i];
             }
         }
         else
         {                       /* Valid SID frame */
             for (i = 0; i < M; i++)
             {
-                lsf2_q[i] = add (lsf2_r[i], lsf_p_CN[i]);
-                                                move16 (); 
+                lsf2_q[i] = add (lsf2_r[i], st->lsf_p_CN[i]);
 
                 /* Use the dequantized values of lsf2 also for lsf1 */
-                lsf1_q[i] = lsf2_q[i];          move16 (); 
+                lsf1_q[i] = lsf2_q[i];
 
-                past_r2_q[i] = 0;               move16 (); 
+                st->past_r2_q[i] = 0;
             }
         }
     }
@@ -232,24 +207,21 @@
     Reorder_lsf (lsf1_q, LSF_GAP, M);
     Reorder_lsf (lsf2_q, LSF_GAP, M);
 
-    test (); logic16 (); 
     if ((rxdtx_ctrl & RX_FIRST_SID_UPDATE) != 0)
     {
         for (i = 0; i < M; i++)
         {
-            lsf_new_CN[i] = lsf2_q[i];          move16 (); 
+            st->lsf_new_CN[i] = lsf2_q[i];
         }
     }
-    test (); logic16 (); 
     if ((rxdtx_ctrl & RX_CONT_SID_UPDATE) != 0)
     {
         for (i = 0; i < M; i++)
         {
-            lsf_old_CN[i] = lsf_new_CN[i];      move16 (); 
-            lsf_new_CN[i] = lsf2_q[i];          move16 (); 
+            st->lsf_old_CN[i] = st->lsf_new_CN[i];
+            st->lsf_new_CN[i] = lsf2_q[i];
         }
     }
-    test (); logic16 (); 
     if ((rxdtx_ctrl & RX_SP_FLAG) != 0)
     {
         /* Update lsf history with quantized LSFs
@@ -258,26 +230,27 @@
 
         if (bfi==0)
         {
-            update_lsf_history (lsf1_q, lsf2_q, lsf_old_rx);
+            update_lsf_history (lsf1_q, lsf2_q, st->lsf_old_rx);
         }
         else
         {
-            update_lsf_history (lsf_new_CN, lsf_new_CN, lsf_old_rx);
+            update_lsf_history (st->lsf_new_CN, st->lsf_new_CN, st->lsf_old_rx);
         }
 
         for (i = 0; i < M; i++)
         {
-            lsf_old_CN[i] = lsf2_q[i];          move16 (); 
+            st->lsf_old_CN[i] = lsf2_q[i];
         }
     }
     else
     {
-        interpolate_CN_lsf (lsf_old_CN, lsf_new_CN, lsf2_q, rx_dtx_state);
+        interpolate_CN_lsf (st->lsf_old_CN, st->lsf_new_CN, lsf2_q,
+                            rx_dtx_state);
     }
 
     for (i = 0; i < M; i++)
     {
-        past_lsf_q[i] = lsf2_q[i];              move16 (); 
+        st->past_lsf_q[i] = lsf2_q[i];
     }
 
     /*  convert LSFs to the cosine domain */