changeset 340:e18452a4fbac

libtwamr: integrate d_gain_p.c
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 18 Apr 2024 23:45:25 +0000
parents a723d9f9f697
children 450b090f2fd7
files libtwamr/Makefile libtwamr/d_gain_p.c libtwamr/d_gain_p.h libtwamr/namespace.h
diffstat 4 files changed, 118 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Thu Apr 18 23:33:00 2024 +0000
+++ b/libtwamr/Makefile	Thu Apr 18 23:45:25 2024 +0000
@@ -4,8 +4,9 @@
 	bitno.o bits2prm.o c1035pf.o c2_11pf.o c2_9pf.o c3_14pf.o c4_17pf.o \
 	c8_31pf.o c_g_aver.o calc_cor.o calc_en.o cbsearch.o convolve.o cor_h.o\
 	d1035pf.o d2_11pf.o d2_9pf.o d3_14pf.o d4_17pf.o d8_31pf.o d_gain_c.o \
-	gains_tab.o gc_pred.o gmed_n.o graytab.o inv_sqrt.o log2.o oper_32b.o \
-	pow2.o prmno.o s10_8pf.o set_sign.o sqrt_l.o tls_flags.o window.o
+	d_gain_p.o gains_tab.o gc_pred.o gmed_n.o graytab.o inv_sqrt.o log2.o \
+	oper_32b.o pow2.o prmno.o s10_8pf.o set_sign.o sqrt_l.o tls_flags.o \
+	window.o
 LIB=	libtwamr.a
 
 INSTALL_PREFIX=	/usr/local
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/d_gain_p.c	Thu Apr 18 23:45:25 2024 +0000
@@ -0,0 +1,71 @@
+/*
+********************************************************************************
+*
+*      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             : d_gain_p.c
+*
+********************************************************************************
+*/
+ 
+ 
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#include "namespace.h"
+#include "d_gain_p.h"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "tw_amr.h"
+#include "typedef.h"
+#include "basic_op.h"
+#include "oper_32b.h"
+#include "no_count.h"
+#include "cnst.h"
+#include "gains_tab.h"
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+
+/*
+**************************************************************************
+*
+*  Function    : d_gain_pitch
+*  Purpose     : Decodes the pitch gain using the received index.
+*                output is in Q14 
+*
+**************************************************************************
+*/
+Word16 d_gain_pitch (      /* return value: gain (Q14)                */
+    enum Mode mode,        /* i   : AMR mode                          */   
+    Word16 index           /* i   : index of quantization             */
+)
+{
+    Word16 gain;
+
+    test ();
+    if (sub(mode, MR122) == 0)
+    {
+       /* clear 2 LSBits */
+       gain = shl (shr (qua_gain_pitch[index], 2), 2);    move16 ();
+    }
+    else
+    {
+       gain = qua_gain_pitch[index];                      move16 (); 
+    }
+    
+    return gain;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/d_gain_p.h	Thu Apr 18 23:45:25 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             : d_gain_p.h
+*      Purpose          : Decodes the pitch gain using the received index.
+*
+********************************************************************************
+*/
+#ifndef d_gain_p_h
+#define d_gain_p_h "$Id $"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "tw_amr.h"
+#include "typedef.h"
+ 
+/*
+**************************************************************************
+*
+*  Function    : d_gain_pitch
+*  Purpose     : Decodes the pitch gain using the received index.
+*  Description : In case of no frame erasure, the gain is obtained 
+*                from the quantization table at the given index; 
+*                otherwise, a downscaled past gain is used.
+*  Returns     : Quantized pitch gain
+*
+**************************************************************************
+*/
+Word16 d_gain_pitch (      /* return value: gain (Q14)                */
+    enum Mode mode,        /* i : AMR mode                            */
+    Word16 index           /* i   : index of quantization             */
+);
+ 
+#endif
--- a/libtwamr/namespace.h	Thu Apr 18 23:33:00 2024 +0000
+++ b/libtwamr/namespace.h	Thu Apr 18 23:45:25 2024 +0000
@@ -82,6 +82,7 @@
 #define	comp_corr 	AMR__comp_corr
 #define	cbsearch	AMR__cbsearch
 #define	d_gain_code	AMR__d_gain_code
+#define	d_gain_pitch	AMR__d_gain_pitch
 
 #define	Bits2prm	AMR__Bits2prm
 #define	Prm2bits	AMR__Prm2bits