changeset 393:a2351f2ad4f8

libtwamr: integrate residu.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 18:44:13 +0000
parents a0f914a28371
children 2af94ba0c075
files libtwamr/Makefile libtwamr/namespace.list libtwamr/residu.c libtwamr/residu.h
diffstat 4 files changed, 124 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Mon May 06 18:37:52 2024 +0000
+++ b/libtwamr/Makefile	Mon May 06 18:44:13 2024 +0000
@@ -12,8 +12,8 @@
 	lsp_az.o lsp_lsf.o lsp_tab.o mac_32.o oper_32b.o ph_disp.o pitch_fr.o \
 	post_pro.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
+	qua_gain_tab.o reorder.o residu.o s10_8pf.o set_sign.o sqrt_l.o \
+	tls_flags.o window.o
 HDRS=	namespace.h
 LIB=	libtwamr.a
 
--- a/libtwamr/namespace.list	Mon May 06 18:37:52 2024 +0000
+++ b/libtwamr/namespace.list	Mon May 06 18:44:13 2024 +0000
@@ -29,7 +29,7 @@
 Lsf_lsp Lsp_lsf Reorder_lsf Lsf_wt Lsp_Az
 Pitch_fr Pitch_fr_reset
 Post_Process Post_Process_reset
-Q_plsf_reset Q_plsf_3 Q_plsf_5 Qua_gain
+Q_plsf_reset Q_plsf_3 Q_plsf_5 Qua_gain Residu
 
 agc agc2 agc_reset
 pseudonoise build_CN_code build_CN_param
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/residu.c	Mon May 06 18:44:13 2024 +0000
@@ -0,0 +1,74 @@
+/*
+********************************************************************************
+*
+*      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             : residu.c
+*      Purpose          : Computes the LP residual.
+*      Description      : The LP residual is computed by filtering the input
+*                       : speech through the LP inverse filter A(z).
+*
+********************************************************************************
+*/
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#include "namespace.h"
+#include "residu.h"
+
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+#include "basic_op.h"
+#include "no_count.h"
+#include "cnst.h"
+
+/*
+********************************************************************************
+*                         LOCAL VARIABLES AND TABLES
+********************************************************************************
+*/
+/*
+*--------------------------------------*
+* Constants (defined in cnst.h         *
+*--------------------------------------*
+*  M         : LPC order               *
+*--------------------------------------*
+*/
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+void Residu (
+    Word16 a[], /* (i)     : prediction coefficients                      */
+    Word16 x[], /* (i)     : speech signal                                */
+    Word16 y[], /* (o)     : residual signal                              */
+    Word16 lg   /* (i)     : size of filtering                            */
+)
+{
+    Word16 i, j;
+    Word32 s;
+
+    for (i = 0; i < lg; i++)
+    {
+        s = L_mult (x[i], a[0]);
+        for (j = 1; j <= M; j++)
+        {
+            s = L_mac (s, a[j], x[i - j]);
+        }
+        s = L_shl (s, 3);
+        y[i] = round (s);       move16 (); 
+    }
+    return;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/residu.h	Mon May 06 18:44:13 2024 +0000
@@ -0,0 +1,47 @@
+/*
+********************************************************************************
+*
+*      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             : residu.h
+*      Purpose          : Computes the LP residual.
+*      Description      : The LP residual is computed by filtering the input
+*                       : speech through the LP inverse filter A(z).
+*
+*
+********************************************************************************
+*/
+#ifndef residu_h
+#define residu_h "$Id $"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+ 
+/*
+********************************************************************************
+*                         DEFINITION OF DATA TYPES
+********************************************************************************
+*/
+ 
+/*
+********************************************************************************
+*                         DECLARATION OF PROTOTYPES
+********************************************************************************
+*/
+ 
+void Residu (
+    Word16 a[],        /* (i)  : prediction coefficients                    */
+    Word16 x[],        /* (i)  : speech signal                              */
+    Word16 y[],        /* (o)  : residual signal                            */
+    Word16 lg          /* (i)  : size of filtering                          */
+);
+ 
+#endif