diff libtwamr/residu.c @ 393:a2351f2ad4f8

libtwamr: integrate residu.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 18:44:13 +0000
parents
children
line wrap: on
line diff
--- /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;
+}