# HG changeset patch # User Mychaela Falconia # Date 1714976666 0 # Node ID 9adfe3863a416e82df344fab97a71b98e85e5f98 # Parent c713061b6edfa1403941bb991032f3ad5be4b6ff libtwamr: integrate lpc.c diff -r c713061b6edf -r 9adfe3863a41 libtwamr/Makefile --- a/libtwamr/Makefile Mon May 06 06:01:56 2024 +0000 +++ b/libtwamr/Makefile Mon May 06 06:24:26 2024 +0000 @@ -8,11 +8,11 @@ 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 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 log2.o lsfwt.o lsp_az.o lsp_lsf.o \ - mac_32.o oper_32b.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 + inv_sqrt.o lag_wind.o levinson.o log2.o lpc.o lsfwt.o lsp_az.o \ + lsp_lsf.o mac_32.o oper_32b.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 HDRS= namespace.h LIB= libtwamr.a diff -r c713061b6edf -r 9adfe3863a41 libtwamr/lpc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/lpc.c Mon May 06 06:24:26 2024 +0000 @@ -0,0 +1,97 @@ +/* +******************************************************************************** +* +* 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 : lpc.c +* +******************************************************************************** +*/ + +/* +******************************************************************************** +* MODULE INCLUDE FILE AND VERSION ID +******************************************************************************** +*/ +#include "namespace.h" +#include "lpc.h" + +/* +******************************************************************************** +* INCLUDE FILES +******************************************************************************** +*/ +#include "tw_amr.h" +#include "typedef.h" +#include "basic_op.h" +#include "oper_32b.h" +#include "autocorr.h" +#include "lag_wind.h" +#include "levinson.h" +#include "cnst.h" +#include "no_count.h" +#include "window.h" + +/* +******************************************************************************** +* PUBLIC PROGRAM CODE +******************************************************************************** +*/ + +/************************************************************************* +* +* Function: lpc_reset +* +************************************************************************** +*/ +void lpc_reset (lpcState *state) +{ + Levinson_reset(&state->levinsonSt); +} + +int lpc( + lpcState *st, /* i/o: State struct */ + enum Mode mode, /* i : coder mode */ + Word16 x[], /* i : Input signal Q15 */ + Word16 x_12k2[], /* i : Input signal (EFR) Q15 */ + Word16 a[] /* o : predictor coefficients Q12 */ +) +{ + Word16 rc[4]; /* First 4 reflection coefficients Q15 */ + Word16 rLow[MP1], rHigh[MP1]; /* Autocorrelations low and hi */ + /* No fixed Q value but normalized */ + /* so that overflow is avoided */ + + test (); + if ( sub (mode, MR122) == 0) + { + /* Autocorrelations */ + Autocorr(x_12k2, M, rHigh, rLow, window_160_80); + /* Lag windowing */ + Lag_window(M, rHigh, rLow); + /* Levinson Durbin */ + Levinson(&st->levinsonSt, rHigh, rLow, &a[MP1], rc); + + /* Autocorrelations */ + Autocorr(x_12k2, M, rHigh, rLow, window_232_8); + /* Lag windowing */ + Lag_window(M, rHigh, rLow); + /* Levinson Durbin */ + Levinson(&st->levinsonSt, rHigh, rLow, &a[MP1 * 3], rc); + } + else + { + /* Autocorrelations */ + Autocorr(x, M, rHigh, rLow, window_200_40); + /* Lag windowing */ + Lag_window(M, rHigh, rLow); + /* Levinson Durbin */ + Levinson(&st->levinsonSt, rHigh, rLow, &a[MP1 * 3], rc); + } + + return 0; +} diff -r c713061b6edf -r 9adfe3863a41 libtwamr/lpc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/lpc.h Mon May 06 06:24:26 2024 +0000 @@ -0,0 +1,63 @@ +/* +******************************************************************************** +* +* 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 : lpc.h +* Purpose : 2 LP analyses centered at 2nd and 4th subframe +* for mode 12.2. For all other modes a +* LP analysis centered at 4th subframe is +* performed. +* +******************************************************************************** +*/ +#ifndef lpc_h +#define lpc_h "$Id $" + +/* +******************************************************************************** +* INCLUDE FILES +******************************************************************************** +*/ +#include "tw_amr.h" +#include "typedef.h" +#include "levinson.h" + +/* +******************************************************************************** +* LOCAL VARIABLES AND TABLES +******************************************************************************** +*/ +/* +******************************************************************************** +* DEFINITION OF DATA TYPES +******************************************************************************** +*/ +typedef struct { + LevinsonState levinsonSt; +} lpcState; + +/* +******************************************************************************** +* DECLARATION OF PROTOTYPES +******************************************************************************** +*/ + +void lpc_reset (lpcState *st); +/* reset of pre processing state (i.e. set state memory to zero) + returns 0 on success + */ + +int lpc( + lpcState *st, /* i/o: State struct */ + enum Mode mode, /* i : coder mode */ + Word16 x[], /* i : Input signal Q15 */ + Word16 x_12k2[], /* i : Input signal (EFR) Q15 */ + Word16 a[] /* o : predictor coefficients Q12 */ +); + +#endif diff -r c713061b6edf -r 9adfe3863a41 libtwamr/namespace.list --- a/libtwamr/namespace.list Mon May 06 06:01:56 2024 +0000 +++ b/libtwamr/namespace.list Mon May 06 06:24:26 2024 +0000 @@ -40,6 +40,7 @@ gainQuant gainQuant_reset gc_pred gc_pred_copy gc_pred_reset gc_pred_update gc_pred_average_limited gmed_n hp_max +lpc lpc_reset q_gain_code q_gain_pitch Bits2prm Prm2bits