FreeCalypso > hg > gsm-codec-lib
changeset 84:3ea19a9aa2a1
libgsmefr: pre_proc.c compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 26 Nov 2022 07:30:53 +0000 |
parents | 33714b36841a |
children | db8e0b69a6bb |
files | libgsmefr/Makefile libgsmefr/pre_proc.c |
diffstat | 2 files changed, 29 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libgsmefr/Makefile Sat Nov 26 07:22:27 2022 +0000 +++ b/libgsmefr/Makefile Sat Nov 26 07:30:53 2022 +0000 @@ -5,7 +5,7 @@ dec_lag6.o dtx.o e_homing.o enc_create.o enc_lag6.o frame2params.o \ g_code.o g_pitch.o int_lpc.o inter_6.o inv_sqrt.o lag_wind.o levinson.o\ log2.o lsp_az.o lsp_lsf.o oper_32b.o params2frame.o pitch_f6.o \ - pitch_ol.o pow2.o sid_class.o sid_insert.o tls_flags.o + pitch_ol.o pow2.o pre_proc.o sid_class.o sid_insert.o tls_flags.o HDRS= basic_op.h cnst.h codec.h d_homing.h dec_state.h dtx.h e_homing.h \ enc_state.h gains_tb.h gsm_efr.h memops.h namespace.h no_count.h \ oper_32b.h sig_proc.h typedef.h vad.h
--- a/libgsmefr/pre_proc.c Sat Nov 26 07:22:27 2022 +0000 +++ b/libgsmefr/pre_proc.c Sat Nov 26 07:30:53 2022 +0000 @@ -10,10 +10,15 @@ * *************************************************************************/ +#include "gsm_efr.h" #include "typedef.h" +#include "namespace.h" #include "basic_op.h" #include "oper_32b.h" -#include "count.h" +#include "no_count.h" +#include "sig_proc.h" +#include "cnst.h" +#include "enc_state.h" /*------------------------------------------------------------------------* * * @@ -31,50 +36,49 @@ static const Word16 b[3] = {1899, -3798, 1899}; static const Word16 a[3] = {4096, 7807, -3733}; -/* Static values to be preserved between calls */ -/* y[] values are kept in double precision */ - -static Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1; - /* Initialization of static values */ -void Init_Pre_Process (void) +void Init_Pre_Process (struct EFR_encoder_state *st) { - y2_hi = 0; - y2_lo = 0; - y1_hi = 0; - y1_lo = 0; - x0 = 0; - x1 = 0; + struct preproc_state *pps = &st->pre_proc; + + pps->y2_hi = 0; + pps->y2_lo = 0; + pps->y1_hi = 0; + pps->y1_lo = 0; + pps->x0 = 0; + pps->x1 = 0; } void Pre_Process ( + struct EFR_encoder_state *st, Word16 signal[], /* input/output signal */ Word16 lg) /* lenght of signal */ { + struct preproc_state *pps = &st->pre_proc; Word16 i, x2; Word32 L_tmp; for (i = 0; i < lg; i++) { - x2 = x1; move16 (); - x1 = x0; move16 (); - x0 = signal[i]; move16 (); + x2 = pps->x1; + pps->x1 = pps->x0; + pps->x0 = signal[i]; /* y[i] = b[0]*x[i]/2 + b[1]*x[i-1]/2 + b140[2]*x[i-2]/2 */ /* + a[1]*y[i-1] + a[2] * y[i-2]; */ - L_tmp = Mpy_32_16 (y1_hi, y1_lo, a[1]); - L_tmp = L_add (L_tmp, Mpy_32_16 (y2_hi, y2_lo, a[2])); - L_tmp = L_mac (L_tmp, x0, b[0]); - L_tmp = L_mac (L_tmp, x1, b[1]); + L_tmp = Mpy_32_16 (pps->y1_hi, pps->y1_lo, a[1]); + L_tmp = L_add (L_tmp, Mpy_32_16 (pps->y2_hi, pps->y2_lo, a[2])); + L_tmp = L_mac (L_tmp, pps->x0, b[0]); + L_tmp = L_mac (L_tmp, pps->x1, b[1]); L_tmp = L_mac (L_tmp, x2, b[2]); L_tmp = L_shl (L_tmp, 3); - signal[i] = round (L_tmp); move16 (); + signal[i] = round (L_tmp); - y2_hi = y1_hi; move16 (); - y2_lo = y1_lo; move16 (); - L_Extract (L_tmp, &y1_hi, &y1_lo); + pps->y2_hi = pps->y1_hi; + pps->y2_lo = pps->y1_lo; + L_Extract (L_tmp, &pps->y1_hi, &pps->y1_lo); } return; }