changeset 65:cb080ec1817e

libgsmefr: dec_lag6.c compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Nov 2022 02:50:06 +0000
parents 1cc2968f883f
children 824ff833bda9
files libgsmefr/Makefile libgsmefr/codec.h libgsmefr/dec_12k2.c libgsmefr/dec_lag6.c
diffstat 4 files changed, 31 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/libgsmefr/Makefile	Sat Nov 26 02:05:51 2022 +0000
+++ b/libgsmefr/Makefile	Sat Nov 26 02:50:06 2022 +0000
@@ -2,8 +2,8 @@
 CFLAGS=	-O2
 OBJS=	agc.o autocorr.o az_lsp.o basicop2.o c1035pf.o cod_12k2.o convolve.o \
 	d1035pf.o d_gains.o d_homing.o d_plsf_5.o dec_12k2.o dec_create.o \
-	enc_create.o frame2params.o params2frame.o sid_class.o sid_insert.o \
-	tls_flags.o
+	dec_lag6.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 \
 	oper_32b.h sig_proc.h typedef.h vad.h
--- a/libgsmefr/codec.h	Sat Nov 26 02:05:51 2022 +0000
+++ b/libgsmefr/codec.h	Sat Nov 26 02:50:06 2022 +0000
@@ -48,7 +48,9 @@
     Word16 i_subfr,    /* input : subframe flag                             */
     Word16 L_frame_by2,/* input : speech frame size divided by 2            */
     Word16 *T0_frac,   /* output: fractional part of pitch lag              */
-    Word16 bfi         /* input : bad frame indicator                       */
+    Word16 bfi,        /* input : bad frame indicator                       */
+    Word16 *T0_min,    /* var from one subframe to the next */
+    Word16 *T0_max     /* ditto */
 );
 Word16 d_gain_pitch (  /* out      : quantized pitch gain                   */
     struct EFR_decoder_state *st,
--- a/libgsmefr/dec_12k2.c	Sat Nov 26 02:05:51 2022 +0000
+++ b/libgsmefr/dec_12k2.c	Sat Nov 26 02:50:06 2022 +0000
@@ -217,13 +217,14 @@
 
     for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
     {
+        Word16 T0_min, T0_max;	/* previously static inside Dec_lag6() */
 
         index = *parm++;                move16 (); /* pitch index */
 
         if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0)
         {
             T0 = Dec_lag6 (st, index, PIT_MIN, PIT_MAX, i_subfr, L_FRAME_BY2,
-                           &T0_frac, bfi);
+                           &T0_frac, bfi, &T0_min, &T0_max);
 
             /*-------------------------------------------------*
              * - Find the adaptive codebook vector.            *
--- a/libgsmefr/dec_lag6.c	Sat Nov 26 02:05:51 2022 +0000
+++ b/libgsmefr/dec_lag6.c	Sat Nov 26 02:50:06 2022 +0000
@@ -16,28 +16,30 @@
  *
  *************************************************************************/
 
+#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 "cnst.h"
+#include "dec_state.h"
 
-/* Old integer lag */
-
-Word16 old_T0;
-
-Word16 
-Dec_lag6 (             /* output: return integer pitch lag       */
+Word16 Dec_lag6 (      /* output: return integer pitch lag       */
+    struct EFR_decoder_state *st,
     Word16 index,      /* input : received pitch index           */
     Word16 pit_min,    /* input : minimum pitch lag              */
     Word16 pit_max,    /* input : maximum pitch lag              */
     Word16 i_subfr,    /* input : subframe flag                  */
     Word16 L_frame_by2,/* input : speech frame size divided by 2 */
     Word16 *T0_frac,   /* output: fractional part of pitch lag   */
-    Word16 bfi         /* input : bad frame indicator            */
+    Word16 bfi,        /* input : bad frame indicator            */
+    Word16 *T0_min,
+    Word16 *T0_max
 )
 {
     Word16 pit_flag;
     Word16 T0, i;
-    static Word16 T0_min, T0_max;
 
     pit_flag = i_subfr;         move16 (); /* flag for 1st or 3rd subframe */
     test (); 
@@ -70,24 +72,22 @@
         else
             /* bfi == 1 */
         {
-            T0 = old_T0;        move16 (); 
-            *T0_frac = 0;       move16 (); 
+            T0 = st->old_T0;
+            *T0_frac = 0;
         }
 
         /* find T0_min and T0_max for 2nd (or 4th) subframe */
 
-        T0_min = sub (T0, 5);
-        test (); 
-        if (sub (T0_min, pit_min) < 0)
+        *T0_min = sub (T0, 5);
+        if (sub (*T0_min, pit_min) < 0)
         {
-            T0_min = pit_min;   move16 (); 
+            *T0_min = pit_min;
         }
-        T0_max = add (T0_min, 9);
-        test (); 
-        if (sub (T0_max, pit_max) > 0)
+        *T0_max = add (*T0_min, 9);
+        if (sub (*T0_max, pit_max) > 0)
         {
-            T0_max = pit_max;   move16 (); 
-            T0_min = sub (T0_max, 9);
+            *T0_max = pit_max;
+            *T0_min = sub (*T0_max, 9);
         }
     }
     else
@@ -99,20 +99,19 @@
         {
             /* i = (index+5)/6 - 1 */
             i = sub (mult (add (index, 5), 5462), 1);
-            T0 = add (i, T0_min);
+            T0 = add (i, *T0_min);
             i = add (add (i, i), i);
             *T0_frac = sub (sub (index, 3), add (i, i));
-                                move16 (); 
         }
         else
             /* bfi == 1  OR index >= 61 */
         {
-            T0 = old_T0;        move16 (); 
-            *T0_frac = 0;       move16 (); 
+            T0 = st->old_T0;
+            *T0_frac = 0;
         }
     }
 
-    old_T0 = T0;                move16 (); 
+    st->old_T0 = T0;
 
     return T0;
 }