changeset 371:4a8cabac281e

libtwamr: integrate q_plsf.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 03:45:04 +0000
parents 8861f41e4507
children 9cca139a20a8
files libtwamr/Makefile libtwamr/namespace.list libtwamr/q_plsf.c libtwamr/q_plsf.h
diffstat 4 files changed, 122 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Mon May 06 03:38:26 2024 +0000
+++ b/libtwamr/Makefile	Mon May 06 03:45:04 2024 +0000
@@ -8,9 +8,9 @@
 	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 gains_tab.o gc_pred.o\
 	gmed_n.o graytab.o inv_sqrt.o log2.o lsfwt.o lsp_lsf.o oper_32b.o \
-	pow2.o prmno.o q_gain_c.o q_gain_p.o q_plsf3_tab.o q_plsf5_tab.o \
-	qua_gain_tab.o reorder.o s10_8pf.o set_sign.o sqrt_l.o tls_flags.o \
-	window.o
+	pow2.o prmno.o q_gain_c.o q_gain_p.o q_plsf.o q_plsf3_tab.o \
+	q_plsf5_tab.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
 
--- a/libtwamr/namespace.list	Mon May 06 03:38:26 2024 +0000
+++ b/libtwamr/namespace.list	Mon May 06 03:45:04 2024 +0000
@@ -23,6 +23,7 @@
 Enc_lag3 Enc_lag6 Ex_ctrl
 G_code G_pitch
 Lsf_lsp Lsp_lsf Reorder_lsf Lsf_wt
+Q_plsf_reset Q_plsf_3 Q_plsf_5
 
 agc agc2 agc_reset
 pseudonoise build_CN_code build_CN_param
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/q_plsf.c	Mon May 06 03:45:04 2024 +0000
@@ -0,0 +1,53 @@
+/*
+********************************************************************************
+*
+*      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             : q_plsf.c
+*      Purpose          : common part (init, exit, reset) of LSF quantization
+*                         module (rest in q_plsf_3.c and q_plsf_5.c)
+*
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#include "namespace.h"
+#include "q_plsf.h"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+#include "basic_op.h"
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+
+/*
+**************************************************************************
+*
+*  Function    : Q_plsf_reset
+*  Purpose     : Resets state memory
+*
+**************************************************************************
+*/
+void Q_plsf_reset (Q_plsfState *state)
+{
+  Word16 i;
+  
+  for ( i = 0; i < M; i++)
+      state->past_rq[i] = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/q_plsf.h	Mon May 06 03:45:04 2024 +0000
@@ -0,0 +1,65 @@
+/*
+********************************************************************************
+*
+*      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             : q_plsf.h
+*      Purpose          : common include file for LSF vector/matrix quanti-
+*                         sation modules (q_plsf_3.c/q_plsf_5.c)
+*
+********************************************************************************
+*/
+#ifndef q_plsf_h
+#define q_plsf_h "$Id $"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "tw_amr.h"
+#include "typedef.h"
+#include "cnst.h"
+/*
+********************************************************************************
+*                         DEFINITION OF DATA TYPES
+********************************************************************************
+*/
+typedef struct {
+    Word16 past_rq[M];    /* Past quantized prediction error, Q15 */
+} Q_plsfState;
+ 
+/*
+********************************************************************************
+*                         DECLARATION OF PROTOTYPES
+********************************************************************************
+*/
+
+void Q_plsf_reset (Q_plsfState *st);
+/* reset of state (i.e. set state memory to zero)
+   returns 0 on success
+ */
+
+void Q_plsf_3(
+    Q_plsfState *st,    /* i/o: state struct                             */
+    enum Mode mode,     /* i  : coder mode                               */
+    Word16 *lsp1,       /* i  : 1st LSP vector                      Q15  */
+    Word16 *lsp1_q,     /* o  : quantized 1st LSP vector            Q15  */
+    Word16 *indice,     /* o  : quantization indices of 3 vectors   Q0   */
+    Word16 *pred_init_i /* o  : init index for MA prediction in DTX mode */
+);
+
+void Q_plsf_5 (
+    Q_plsfState *st,
+    Word16 *lsp1,      /* i  : 1st LSP vector,                     Q15 */
+    Word16 *lsp2,      /* i  : 2nd LSP vector,                     Q15 */   
+    Word16 *lsp1_q,    /* o  : quantized 1st LSP vector,           Q15 */
+    Word16 *lsp2_q,    /* o  : quantized 2nd LSP vector,           Q15 */
+    Word16 *indice     /* o  : quantization indices of 5 matrices, Q0  */
+);
+ 
+#endif