changeset 62:c87ccddf3fd1

libgsmefr: d_homing.c compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Nov 2022 00:53:14 +0000
parents a18782a7d270
children 6a623cb57d07
files libgsmefr/Makefile libgsmefr/d_homing.c
diffstat 2 files changed, 37 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmefr/Makefile	Fri Nov 25 20:19:30 2022 +0000
+++ b/libgsmefr/Makefile	Sat Nov 26 00:53:14 2022 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2
 OBJS=	agc.o autocorr.o az_lsp.o basicop2.o c1035pf.o cod_12k2.o convolve.o \
-	d1035pf.o d_gains.o dec_create.o enc_create.o frame2params.o \
+	d1035pf.o d_gains.o d_homing.o dec_create.o enc_create.o frame2params.o\
 	params2frame.o sid_class.o sid_insert.o tls_flags.o
 HDRS=	basic_op.h cnst.h codec.h d_homing.h dec_state.h dtx.h e_homing.h \
 	enc_state.h gains_tb.h gsm_efr.h memops.h namespace.h no_count.h \
--- a/libgsmefr/d_homing.c	Fri Nov 25 20:19:30 2022 +0000
+++ b/libgsmefr/d_homing.c	Sat Nov 26 00:53:14 2022 +0000
@@ -18,10 +18,14 @@
  *
  **************************************************************************/
 
+#include "gsm_efr.h"
 #include "typedef.h"
+#include "namespace.h"
 #include "cnst.h"
 #include "dtx.h"
 #include "codec.h"
+#include "memops.h"
+#include "dec_state.h"
 #include "d_homing.h"
 #include "q_plsf_5.tab"
 
@@ -207,111 +211,66 @@
  *
  **************************************************************************/
 
-void decoder_reset (void)
+void decoder_reset (struct EFR_decoder_state *st)
 {
-    /* External declarations for decoder variables which need to be reset */
-
-    /* variable defined in decoder.c */
-    /* ----------------------------- */
-    extern Word16 synth_buf[L_FRAME + M];
-
-    /* variable defined in agc.c */
-    /* -------------------------- */
-    extern Word16 past_gain;
-
-    /* variables defined in d_gains.c */
-    /* ------------------------------ */
-    /* Error concealment */
-    extern Word16 pbuf[5], past_gain_pit, prev_gp, gbuf[5], past_gain_code,
-     prev_gc;
-
-    /* CNI */
-    extern Word16 gcode0_CN, gain_code_old_CN, gain_code_new_CN;
-    extern Word16 gain_code_muting_CN;
-
-    /* Memories of gain dequantization: */
-    extern Word16 past_qua_en[4], pred[4];
-
-    /* variables defined in d_plsf_5.c */
-    /* ------------------------------ */
-    /* Past quantized prediction error */
-    extern Word16 past_r2_q[M];
-
-    /* Past dequantized lsfs */
-    extern Word16 past_lsf_q[M];
-
-    /* CNI */
-    extern Word16 lsf_p_CN[M], lsf_new_CN[M], lsf_old_CN[M];
-
-    /* variables defined in dec_lag6.c */
-    /* ------------------------------ */
-    extern Word16 old_T0;
-
-    /* variable defined in preemph.c */
-    /* ------------------------------ */
-    extern Word16 mem_pre;
-
     Word16 i;
 
     /* reset all the decoder state variables */
     /* ------------------------------------- */
 
     /* Variable in decoder.c: */
-    for (i = 0; i < M; i++)
-    {
-        synth_buf[i] = 0;
-    }
+    Set_zero (st->synth_buf, M);
 
     /* Variables in dec_12k2.c: */
-    Init_Decoder_12k2 ();
+    Init_Decoder_12k2 (st);
 
     /* Variable in agc.c: */
-    past_gain = 4096;
+    st->past_gain = 4096;
 
     /* Variables in d_gains.c: */
     for (i = 0; i < 5; i++)
     {
-        pbuf[i] = 410;          /* Error concealment */
-        gbuf[i] = 1;            /* Error concealment */
+        st->pbuf[i] = 410;          /* Error concealment */
+        st->gbuf[i] = 1;            /* Error concealment */
     }
 
-    past_gain_pit = 0;          /* Error concealment */
-    prev_gp = 4096;             /* Error concealment */
-    past_gain_code = 0;         /* Error concealment */
-    prev_gc = 1;                /* Error concealment */
-    gcode0_CN = 0;              /* CNI */
-    gain_code_old_CN = 0;       /* CNI */
-    gain_code_new_CN = 0;       /* CNI */
-    gain_code_muting_CN = 0;    /* CNI */
+    st->past_gain_pit = 0;          /* Error concealment */
+    st->prev_gp = 4096;             /* Error concealment */
+    st->past_gain_code = 0;         /* Error concealment */
+    st->prev_gc = 1;                /* Error concealment */
+    st->gcode0_CN = 0;              /* CNI */
+    st->gain_code_old_CN = 0;       /* CNI */
+    st->gain_code_new_CN = 0;       /* CNI */
+    st->gain_code_muting_CN = 0;    /* CNI */
 
     for (i = 0; i < 4; i++)
     {
-        past_qua_en[i] = -2381; /* past quantized energies */
+        st->past_qua_en[i] = -2381; /* past quantized energies */
     }
 
-    pred[0] = 44;               /* MA prediction coeff */
-    pred[1] = 37;               /* MA prediction coeff */
-    pred[2] = 22;               /* MA prediction coeff */
-    pred[3] = 12;               /* MA prediction coeff */
+    st->pred[0] = 44;               /* MA prediction coeff */
+    st->pred[1] = 37;               /* MA prediction coeff */
+    st->pred[2] = 22;               /* MA prediction coeff */
+    st->pred[3] = 12;               /* MA prediction coeff */
 
     /* Variables in d_plsf_5.c: */
     for (i = 0; i < M; i++)
     {
-        past_r2_q[i] = 0;               /* Past quantized prediction error */
-        past_lsf_q[i] = mean_lsf[i];    /* Past dequantized lsfs */
-        lsf_p_CN[i] = mean_lsf[i];      /* CNI */
-        lsf_new_CN[i] = mean_lsf[i];    /* CNI */
-        lsf_old_CN[i] = mean_lsf[i];    /* CNI */
+        st->past_r2_q[i] = 0;             /* Past quantized prediction error */
+        st->past_lsf_q[i] = mean_lsf[i];  /* Past dequantized lsfs */
+        st->lsf_p_CN[i] = mean_lsf[i];    /* CNI */
+        st->lsf_new_CN[i] = mean_lsf[i];  /* CNI */
+        st->lsf_old_CN[i] = mean_lsf[i];  /* CNI */
     }
 
     /* Variable in dec_lag6.c: */
-    old_T0 = 40;                /* Old integer lag */
+    st->old_T0 = 40;                /* Old integer lag */
 
     /* Variable in preemph.c: */
-    mem_pre = 0;                /* Filter memory */
+    st->mem_pre = 0;                /* Filter memory */
 
     /* Variables in pstfilt2.c: */
-    Init_Post_Filter ();
+    Init_Post_Filter (st);
 
     return;
 }
@@ -335,10 +294,12 @@
  *
  **************************************************************************/
 
-void reset_dec (void)
+void EFR_decoder_reset (struct EFR_decoder_state *st)
 {
-    decoder_reset (); /* reset all the state variables in the speech decoder*/
-    reset_rx_dtx ();  /* reset all the receive DTX and CN state variables */
+    st->reset_flag_old = 1;
+
+    decoder_reset (st); /* reset all the state variables in the speech decoder*/
+    reset_rx_dtx (st);  /* reset all the receive DTX and CN state variables */
 
     return;
 }