changeset 417:f17e42c63058

libtwamr: integrate ol_ltp.c
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 03:21:14 +0000
parents 48c7f8e8c9af
children 93d6c6960a46
files libtwamr/Makefile libtwamr/namespace.list libtwamr/ol_ltp.c libtwamr/ol_ltp.h
diffstat 4 files changed, 149 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libtwamr/Makefile	Tue May 07 03:15:19 2024 +0000
+++ b/libtwamr/Makefile	Tue May 07 03:21:14 2024 +0000
@@ -10,9 +10,9 @@
 	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 inter_36.o inv_sqrt.o lag_wind.o\
 	levinson.o lflg_upd.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o lsp_az.o \
-	lsp_lsf.o lsp_tab.o mac_32.o oper_32b.o p_ol_wgh.o ph_disp.o pitch_fr.o\
-	pitch_ol.o post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o preemph.o \
-	prm2bits.o prmno.o pstfilt.o q_gain_c.o q_gain_p.o q_plsf.o \
+	lsp_lsf.o lsp_tab.o mac_32.o ol_ltp.o oper_32b.o p_ol_wgh.o ph_disp.o \
+	pitch_fr.o pitch_ol.o post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o \
+	preemph.o prm2bits.o prmno.o pstfilt.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 r_fft.o reorder.o residu.o s10_8pf.o \
 	set_sign.o sid_sync.o spreproc.o spstproc.o sqrt_l.o syn_filt.o \
@@ -27,9 +27,9 @@
 	gain_q.h gains_tab.h gc_pred.h gmed_n.h graytab.h hp_max.h int_defs.h \
 	int_lpc.h int_lsf.h inter_36.h inv_sqrt.h lag_wind.h levinson.h log2.h \
 	lpc.h lsfwt.h lsp.h lsp_avg.h lsp_az.h lsp_lsf.h lsp_tab.h mac_32.h \
-	memops.h namespace.h no_count.h oper_32b.h p_ol_wgh.h ph_disp.h \
-	pitch_fr.h pitch_ol.h post_pro.h pow2.h pre_big.h pre_proc.h pred_lt.h \
-	preemph.h prm2bits.h pstfilt.h q_gain_c.h q_gain_p.h q_plsf.h \
+	memops.h namespace.h no_count.h ol_ltp.h oper_32b.h p_ol_wgh.h \
+	ph_disp.h pitch_fr.h pitch_ol.h post_pro.h pow2.h pre_big.h pre_proc.h \
+	pred_lt.h preemph.h prm2bits.h pstfilt.h q_gain_c.h q_gain_p.h q_plsf.h\
 	q_plsf3_tab.h q_plsf5_tab.h qgain475.h qgain795.h qua_gain.h \
 	qua_gain_tab.h reorder.h residu.h s10_8pf.h set_sign.h sid_sync.h \
 	spreproc.h spstproc.h sqrt_l.h syn_filt.h ton_stab.h tw_amr.h typedef.h\
--- a/libtwamr/namespace.list	Tue May 07 03:15:19 2024 +0000
+++ b/libtwamr/namespace.list	Tue May 07 03:21:14 2024 +0000
@@ -38,7 +38,7 @@
 sqrt_l_exp
 set_sign set_sign12k2
 cor_h cor_h_x cor_h_x2 comp_corr
-cbsearch cl_ltp cl_ltp_reset
+cbsearch cl_ltp cl_ltp_reset ol_ltp
 d_gain_code d_gain_pitch
 gain_adapt gain_adapt_reset
 gainQuant gainQuant_reset
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/ol_ltp.c	Tue May 07 03:21:14 2024 +0000
@@ -0,0 +1,98 @@
+/*
+********************************************************************************
+*
+*      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             : ol_ltp.c
+*      Purpose          : Compute the open loop pitch lag.
+*
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+*                         MODULE INCLUDE FILE AND VERSION ID
+********************************************************************************
+*/
+#include "namespace.h"
+#include "ol_ltp.h"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+#include "cnst.h"
+#include "pitch_ol.h"
+#include "p_ol_wgh.h"
+#include "no_count.h"
+#include "basic_op.h"
+
+/*
+********************************************************************************
+*                         LOCAL VARIABLES AND TABLES
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+*                         PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+int ol_ltp(
+    pitchOLWghtState *st, /* i/o : State struct                            */
+    vadState *vadSt,      /* i/o : VAD state struct                        */
+    enum Mode mode,       /* i   : coder mode                              */
+    Word16 wsp[],         /* i   : signal used to compute the OL pitch, Q0 */
+                          /*       uses signal[-pit_max] to signal[-1]     */
+    Word16 *T_op,         /* o   : open loop pitch lag,                 Q0 */
+    Word16 old_lags[],    /* i   : history with old stored Cl lags         */
+    Word16 ol_gain_flg[], /* i   : OL gain flag                            */
+    Word16 idx,           /* i   : index                                   */
+    Flag dtx              /* i   : dtx flag; use dtx=1, do not use dtx=0   */
+    )
+{
+   test ();   
+   if (sub (mode, MR102) != 0 )
+   {
+      ol_gain_flg[0] = 0;                                       move16 ();
+      ol_gain_flg[1] = 0;                                       move16 ();
+   }
+   
+   test (); test ();
+   if (sub (mode, MR475) == 0 || sub (mode, MR515) == 0 )
+   {
+      *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME, idx, dtx);
+                                                                move16 ();
+   }
+   else
+   {
+      if ( sub (mode, MR795) <= 0 )
+      {
+         test();
+         *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
+                          idx, dtx);
+                                                                move16 ();
+      }
+      else if ( sub (mode, MR102) == 0 )
+      {
+         test(); test();
+         *T_op = Pitch_ol_wgh(st, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2,
+                              old_lags, ol_gain_flg, idx, dtx);
+                                                                move16 ();
+      }
+      else
+      {
+         test(); test();          
+         *T_op = Pitch_ol(vadSt, mode, wsp, PIT_MIN_MR122, PIT_MAX,
+                          L_FRAME_BY2, idx, dtx);
+                                                                move16 ();
+      }
+   }
+   return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libtwamr/ol_ltp.h	Tue May 07 03:21:14 2024 +0000
@@ -0,0 +1,44 @@
+/*
+********************************************************************************
+*
+*      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             : ol_ltp.h
+*      Purpose          : Compute the open loop pitch lag.
+*
+********************************************************************************
+*/
+#ifndef ol_ltp_h
+#define ol_ltp_h "$Id $"
+ 
+/*
+********************************************************************************
+*                         INCLUDE FILES
+********************************************************************************
+*/
+#include "tw_amr.h"
+#include "typedef.h"
+#include "p_ol_wgh.h"
+
+/*
+********************************************************************************
+*                         DECLARATION OF PROTOTYPES
+********************************************************************************
+*/
+int ol_ltp(
+    pitchOLWghtState *st, /* i/o : State struct                            */
+    vadState *vadSt,      /* i/o : VAD state struct                        */
+    enum Mode mode,       /* i   : coder mode                              */
+    Word16 wsp[],         /* i   : signal used to compute the OL pitch, Q0 */
+                          /*       uses signal[-pit_max] to signal[-1]     */
+    Word16 *T_op,         /* o   : open loop pitch lag,                 Q0 */
+    Word16 old_lags[],    /* i   : history with old stored Cl lags         */
+    Word16 ol_gain_flg[], /* i   : OL gain flag                            */
+    Word16 idx,           /* i   : index                                   */
+    Flag dtx              /* i   : dtx flag; use dtx=1, do not use dtx=0   */
+);
+#endif