changeset 383:838ed426bb76

libtwamr: integrate inter_36.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 05:49:47 +0000
parents 693ea1d5cf1e
children a8dab7028e4d
files libtwamr/Makefile libtwamr/inter_36.c libtwamr/inter_36.h libtwamr/inter_36.tab libtwamr/namespace.list
diffstat 5 files changed, 177 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Mon May 06 05:45:31 2024 +0000
+++ b/libtwamr/Makefile	Mon May 06 05:49:47 2024 +0000
@@ -7,11 +7,11 @@
 	d_gain_p.o d_plsf.o d_plsf_3.o d_plsf_5.o dec_gain.o dec_lag3.o \
 	dec_lag6.o dhf_check.o dhf_tables.o e_homing.o ec_gains.o enc_lag3.o \
 	enc_lag6.o ex_ctrl.o g_adapt.o g_code.o g_pitch.o gain_q.o gains_tab.o \
-	gc_pred.o gmed_n.o graytab.o hp_max.o int_lpc.o int_lsf.o inv_sqrt.o \
-	log2.o lsfwt.o lsp_az.o lsp_lsf.o mac_32.o oper_32b.o pow2.o prmno.o \
-	q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o q_plsf_3.o \
-	q_plsf_5.o qgain475.o qgain795.o qua_gain.o qua_gain_tab.o reorder.o \
-	s10_8pf.o set_sign.o sqrt_l.o tls_flags.o window.o
+	gc_pred.o gmed_n.o graytab.o hp_max.o int_lpc.o int_lsf.o inter_36.o \
+	inv_sqrt.o log2.o lsfwt.o lsp_az.o lsp_lsf.o mac_32.o oper_32b.o pow2.o\
+	prmno.o q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o \
+	q_plsf_3.o q_plsf_5.o qgain475.o qgain795.o qua_gain.o qua_gain_tab.o \
+	reorder.o s10_8pf.o set_sign.o sqrt_l.o tls_flags.o window.o
 HDRS=	namespace.h
 LIB=	libtwamr.a
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/inter_36.c	Mon May 06 05:49:47 2024 +0000
@@ -0,0 +1,93 @@
+/*
+********************************************************************************
+*
+*      GSM AMR-NB speech codec   R98   Version 7.6.0   December 12, 2001
+*                                R99   Version 3.3.0                
+*                                REL-4 Version 4.1.0                
+*
+********************************************************************************
+*
+*      File             : inter_36.c
+*      Purpose          : Interpolating the normalized correlation
+*                       : with 1/3 or 1/6 resolution.
+*
+********************************************************************************
+*/
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#include "namespace.h"
+#include "inter_36.h"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+#include "basic_op.h"
+#include "no_count.h"
+#include "cnst.h"
+
+/*
+********************************************************************************
+*                         LOCAL VARIABLES AND TABLES
+********************************************************************************
+*/
+#define UP_SAMP_MAX  6
+
+#include "inter_36.tab"
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+/*************************************************************************
+ *
+ *  FUNCTION:  Interpol_3or6()
+ *
+ *  PURPOSE:  Interpolating the normalized correlation with 1/3 or 1/6
+ *            resolution.
+ *
+ *************************************************************************/
+Word16 Interpol_3or6 (  /* o : interpolated value                        */
+    Word16 *x,          /* i : input vector                              */
+    Word16 frac,        /* i : fraction  (-2..2 for 3*, -3..3 for 6*)    */
+    Word16 flag3        /* i : if set, upsampling rate = 3 (6 otherwise) */
+)
+{
+    Word16 i, k;
+    Word16 *x1, *x2;
+    const Word16 *c1, *c2;
+    Word32 s;
+
+    test();
+    if (flag3 != 0)
+    {
+      frac = shl (frac, 1);   /* inter_3[k] = inter_6[2*k] -> k' = 2*k */
+    }
+    
+    test (); 
+    if (frac < 0)
+    {
+        frac = add (frac, UP_SAMP_MAX);
+        x--;
+    }
+    
+    x1 = &x[0];                         move16 (); 
+    x2 = &x[1];                         move16 (); 
+    c1 = &inter_6[frac];                move16 (); 
+    c2 = &inter_6[sub (UP_SAMP_MAX, frac)]; move16 (); 
+
+    s = 0;                              move32 (); 
+    for (i = 0, k = 0; i < L_INTER_SRCH; i++, k += UP_SAMP_MAX)
+    {
+        s = L_mac (s, x1[-i], c1[k]);
+        s = L_mac (s, x2[i], c2[k]);
+    }
+
+    return round (s);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/inter_36.h	Mon May 06 05:49:47 2024 +0000
@@ -0,0 +1,43 @@
+/*
+********************************************************************************
+*
+*      GSM AMR-NB speech codec   R98   Version 7.6.0   December 12, 2001
+*                                R99   Version 3.3.0                
+*                                REL-4 Version 4.1.0                
+*
+********************************************************************************
+*
+*      File             : inter_36.h
+*      Purpose          : Interpolating the normalized correlation
+*                       : with 1/3 or 1/6 resolution.
+*
+********************************************************************************
+*/
+#ifndef inter_36_h
+#define inter_36_h "$Id $"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+ 
+/*
+********************************************************************************
+*                         DEFINITION OF DATA TYPES
+********************************************************************************
+*/
+ 
+/*
+********************************************************************************
+*                         DECLARATION OF PROTOTYPES
+********************************************************************************
+*/
+Word16 Interpol_3or6 (  /* (o)  : interpolated value                        */
+    Word16 *x,          /* (i)  : input vector                              */
+    Word16 frac,        /* (i)  : fraction  (-2..2 for 3*, -3..3 for 6*)    */
+    Word16 flag3        /* (i)  : if set, upsampling rate = 3 (6 otherwise) */
+);
+ 
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/inter_36.tab	Mon May 06 05:49:47 2024 +0000
@@ -0,0 +1,34 @@
+/*
+********************************************************************************
+*
+*      GSM AMR-NB speech codec   R98   Version 7.6.0   December 12, 2001
+*                                R99   Version 3.3.0                
+*                                REL-4 Version 4.1.0                
+*
+********************************************************************************
+*
+*      File             : inter_36.tab
+*      Purpose          : Tables for interpolating the normalized correlation 
+*                         with 1/3 or 1/6 resolution.
+*      $Id $
+*
+********************************************************************************
+*/
+#define FIR_SIZE     (UP_SAMP_MAX*L_INTER_SRCH+1)
+
+/* 1/6 resolution interpolation filter  (-3 dB at 3600 Hz) */
+/* Note: The IS641 (7.4) 1/3 resolution filter is simply a subsampled
+         version of the 1/6 resolution filter, i.e. it uses
+         every second coefficient:
+         
+         inter_3[k] = inter_6[2*k], 0 <= k <= 3*L_INTER_SRCH
+ */
+
+static const Word16 inter_6[FIR_SIZE] =
+{
+    29519,
+    28316, 24906, 19838, 13896, 7945, 2755,
+    -1127, -3459, -4304, -3969, -2899, -1561,
+    -336, 534, 970, 1023, 823, 516,
+    220, 0, -131, -194, -215, 0
+};
--- a/libtwamr/namespace.list	Mon May 06 05:45:31 2024 +0000
+++ b/libtwamr/namespace.list	Mon May 06 05:49:47 2024 +0000
@@ -23,7 +23,8 @@
 D_plsf_reset D_plsf_5 D_plsf_3 Init_D_plsf_3
 Enc_lag3 Enc_lag6 Ex_ctrl
 G_code G_pitch
-Int_lpc_1and3 Int_lpc_1and3_2 Int_lpc_1to3 Int_lpc_1to3_2 Int_lsf
+Int_lpc_1and3 Int_lpc_1and3_2 Int_lpc_1to3 Int_lpc_1to3_2
+Int_lsf Interpol_3or6
 Lsf_lsp Lsp_lsf Reorder_lsf Lsf_wt Lsp_Az
 Q_plsf_reset Q_plsf_3 Q_plsf_5 Qua_gain