# HG changeset patch # User Mychaela Falconia # Date 1669428351 0 # Node ID 1cc2968f883f3e5d98f240cbf237737bf6e2d071 # Parent 6a623cb57d0744626dc69777038015aae6738c18 libgsmefr: dec_12k2.c compiles diff -r 6a623cb57d07 -r 1cc2968f883f libgsmefr/Makefile --- a/libgsmefr/Makefile Sat Nov 26 01:11:04 2022 +0000 +++ b/libgsmefr/Makefile Sat Nov 26 02:05:51 2022 +0000 @@ -1,8 +1,9 @@ CC= gcc CFLAGS= -O2 OBJS= agc.o autocorr.o az_lsp.o basicop2.o c1035pf.o cod_12k2.o convolve.o \ - d1035pf.o d_gains.o d_homing.o d_plsf_5.o dec_create.o enc_create.o \ - frame2params.o params2frame.o sid_class.o sid_insert.o tls_flags.o + d1035pf.o d_gains.o d_homing.o d_plsf_5.o dec_12k2.o dec_create.o \ + enc_create.o frame2params.o params2frame.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 diff -r 6a623cb57d07 -r 1cc2968f883f libgsmefr/codec.h --- a/libgsmefr/codec.h Sat Nov 26 01:11:04 2022 +0000 +++ b/libgsmefr/codec.h Sat Nov 26 02:05:51 2022 +0000 @@ -10,8 +10,8 @@ void Decoder_12k2 ( struct EFR_decoder_state *st, - Word16 parm[], /* input : vector of synthesis parameters - parm[0] = bad frame indicator (bfi) */ + Word16 bfi, /* input : Bad Frame Indication */ + Word16 parm[], /* input : vector of synthesis parameters */ Word16 synth[], /* output: synthesis speech */ Word16 A_t[], /* output: decoded LP filter in 4 subframes */ Word16 TAF, diff -r 6a623cb57d07 -r 1cc2968f883f libgsmefr/dec_12k2.c --- a/libgsmefr/dec_12k2.c Sat Nov 26 01:11:04 2022 +0000 +++ b/libgsmefr/dec_12k2.c Sat Nov 26 02:05:51 2022 +0000 @@ -14,17 +14,19 @@ * ***************************************************************************/ +#include "gsm_efr.h" #include "typedef.h" +#include "namespace.h" #include "basic_op.h" #include "sig_proc.h" -#include "count.h" +#include "memops.h" +#include "no_count.h" #include "codec.h" #include "cnst.h" +#include "dec_state.h" #include "dtx.h" -extern Word16 dtx_mode; - /*---------------------------------------------------------------* * Decoder constant parameters (defined in "cnst.h") * *---------------------------------------------------------------* @@ -43,24 +45,6 @@ * Static memory allocation. * *--------------------------------------------------------*/ - /* Excitation vector */ - -static Word16 old_exc[L_FRAME + PIT_MAX + L_INTERPOL]; -static Word16 *exc; - - /* Lsp (Line spectral pairs) */ - -static Word16 lsp_old[M]; - - /* Filter's memory */ - -static Word16 mem_syn[M]; - - /* Memories for bad frame handling */ - -static Word16 prev_bf; -static Word16 state; - /*************************************************************************** * * FUNCTION: Init_Decoder_12k2 @@ -69,34 +53,30 @@ * ***************************************************************************/ -void Init_Decoder_12k2 (void) +void Init_Decoder_12k2 (struct EFR_decoder_state *st) { - /* Initialize static pointer */ - - exc = old_exc + PIT_MAX + L_INTERPOL; - /* Static vectors to zero */ - Set_zero (old_exc, PIT_MAX + L_INTERPOL); - Set_zero (mem_syn, M); + Set_zero (st->old_exc, PIT_MAX + L_INTERPOL); + Set_zero (st->mem_syn, M); /* Initialize lsp_old [] */ - lsp_old[0] = 30000; - lsp_old[1] = 26000; - lsp_old[2] = 21000; - lsp_old[3] = 15000; - lsp_old[4] = 8000; - lsp_old[5] = 0; - lsp_old[6] = -8000; - lsp_old[7] = -15000; - lsp_old[8] = -21000; - lsp_old[9] = -26000; + st->lsp_old[0] = 30000; + st->lsp_old[1] = 26000; + st->lsp_old[2] = 21000; + st->lsp_old[3] = 15000; + st->lsp_old[4] = 8000; + st->lsp_old[5] = 0; + st->lsp_old[6] = -8000; + st->lsp_old[7] = -15000; + st->lsp_old[8] = -21000; + st->lsp_old[9] = -26000; /* Initialize memories of bad frame handling */ - prev_bf = 0; - state = 0; + st->prev_bf = 0; + st->bf_state = 0; return; } @@ -110,14 +90,16 @@ ***************************************************************************/ void Decoder_12k2 ( - Word16 parm[], /* input : vector of synthesis parameters - parm[0] = bad frame indicator (bfi) */ + struct EFR_decoder_state *st, + Word16 bfi, /* input : Bad Frame Indication */ + Word16 parm[], /* input : vector of synthesis parameters */ Word16 synth[],/* output: synthesis speech */ Word16 A_t[], /* output: decoded LP filter in 4 subframes */ Word16 TAF, Word16 SID_flag ) { + Word16 *exc = st->old_exc + PIT_MAX + L_INTERPOL; /* LPC coefficients */ @@ -140,39 +122,30 @@ Word16 i, i_subfr; Word16 T0, T0_frac, index; - Word16 gain_pit, gain_code, bfi, pit_sharp; + Word16 gain_pit, gain_code, pit_sharp; Word16 temp; Word32 L_temp; - extern Word16 rxdtx_ctrl, rx_dtx_state; - extern Word32 L_pn_seed_rx; - - /* Test bad frame indicator (bfi) */ - - bfi = *parm++; move16 (); - /* Set state machine */ - test (); test (); if (bfi != 0) { - state = add (state, 1); + st->bf_state = add (st->bf_state, 1); } - else if (sub (state, 6) == 0) + else if (sub (st->bf_state, 6) == 0) { - state = 5; + st->bf_state = 5; } else { - state = 0; + st->bf_state = 0; } - test (); - if (sub (state, 6) > 0) + if (sub (st->bf_state, 6) > 0) { - state = 6; + st->bf_state = 6; } - rx_dtx (&rxdtx_ctrl, TAF, bfi, SID_flag); + rx_dtx (st, TAF, bfi, SID_flag); /* If this frame is the first speech frame after CNI period, */ /* set the BFH state machine to an appropriate state depending */ @@ -183,49 +156,31 @@ /* keep the audible noise resulting from a SID frame which is */ /* erroneously interpreted as a good speech frame as small as */ /* possible (the decoder output in this case is quickly muted) */ - test (); logic16 (); - if ((rxdtx_ctrl & RX_FIRST_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_FIRST_SP_FLAG) != 0) { - test (); logic16 (); - if ((rxdtx_ctrl & RX_PREV_DTX_MUTING) != 0) + if ((st->rxdtx_ctrl & RX_PREV_DTX_MUTING) != 0) { - state = 5; move16 (); - prev_bf = 1; move16 (); + st->bf_state = 5; + st->prev_bf = 1; } else { - state = 5; move16 (); - prev_bf = 0; move16 (); + st->bf_state = 5; + st->prev_bf = 0; } } -#if (WMOPS) - fwc (); /* function worst case */ + D_plsf_5 (st, parm, lsp_mid, lsp_new, bfi, st->rxdtx_ctrl, + st->rx_dtx_state); - /* Note! The following test is performed only for determining - whether or not DTX mode is active, in order to switch off - worst worst case complexity printout when DTX mode is active - */ - if ((rxdtx_ctrl & RX_SP_FLAG) == 0) - { - dtx_mode = 1; - } -#endif - - D_plsf_5 (parm, lsp_mid, lsp_new, bfi, rxdtx_ctrl, rx_dtx_state); - -#if (WMOPS) - fwc (); /* function worst case */ -#endif /* Advance synthesis parameters pointer */ parm += 5; move16 (); - test (); logic16 (); - if ((rxdtx_ctrl & RX_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0) { /* Interpolation of LPC for the 4 subframes */ - Int_lpc (lsp_old, lsp_mid, lsp_new, A_t); + Int_lpc (st->lsp_old, lsp_mid, lsp_new, A_t); } else { @@ -243,11 +198,8 @@ /* update the LSPs for the next frame */ for (i = 0; i < M; i++) { - lsp_old[i] = lsp_new[i]; move16 (); + st->lsp_old[i] = lsp_new[i]; } -#if (WMOPS) - fwc (); /* function worst case */ -#endif /*---------------------------------------------------------------------* * Loop for every subframe in the analysis frame * @@ -268,23 +220,16 @@ index = *parm++; move16 (); /* pitch index */ - test (); logic16 (); - if ((rxdtx_ctrl & RX_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0) { - T0 = Dec_lag6 (index, PIT_MIN, PIT_MAX, i_subfr, L_FRAME_BY2, + T0 = Dec_lag6 (st, index, PIT_MIN, PIT_MAX, i_subfr, L_FRAME_BY2, &T0_frac, bfi); -#if (WMOPS) - fwc (); /* function worst case */ -#endif /*-------------------------------------------------* * - Find the adaptive codebook vector. * *-------------------------------------------------*/ Pred_lt_6 (&exc[i_subfr], T0, T0_frac, L_SUBFR); -#if (WMOPS) - fwc (); /* function worst case */ -#endif } else { @@ -297,30 +242,23 @@ index = *parm++; move16 (); - gain_pit = d_gain_pitch (index, bfi, state, prev_bf, rxdtx_ctrl); - move16 (); -#if (WMOPS) - fwc (); /* function worst case */ -#endif + gain_pit = d_gain_pitch (st, index, bfi, st->bf_state, st->prev_bf, + st->rxdtx_ctrl); /*-------------------------------------------------------* * - Decode innovative codebook. * *-------------------------------------------------------*/ - test (); logic16 (); - if ((rxdtx_ctrl & RX_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0) { dec_10i40_35bits (parm, code); } else { /* Use pseudo noise for excitation when SP_flag == 0 */ - build_CN_code (code, &L_pn_seed_rx); + build_CN_code (code, &st->L_pn_seed_rx); } parm += 10; move16 (); -#if (WMOPS) - fwc (); /* function worst case */ -#endif /*-------------------------------------------------------* * - Add the pitch contribution to code[]. * @@ -338,9 +276,7 @@ code[i] = add (code[i], temp); move16 (); } -#if (WMOPS) - fwc (); /* function worst case */ -#endif + /* post processing of excitation elements */ test (); /* This test is not passed when SP_FLAG is 0 */ @@ -361,11 +297,8 @@ index = *parm++; move16 (); /* index of energy VQ */ - d_gain_code (index, code, L_SUBFR, &gain_code, bfi, state, prev_bf, - rxdtx_ctrl, i_subfr, rx_dtx_state); -#if (WMOPS) - fwc (); /* function worst case */ -#endif + d_gain_code (st, index, code, L_SUBFR, &gain_code, bfi, st->bf_state, + st->prev_bf, st->rxdtx_ctrl, i_subfr, st->rx_dtx_state); /*-------------------------------------------------------* * - Find the total excitation. * @@ -382,29 +315,22 @@ exc[i + i_subfr] = round (L_temp); move16 (); } -#if (WMOPS) - fwc (); /* function worst case */ -#endif - test (); if (sub (pit_sharp, 16384) > 0) { for (i = 0; i < L_SUBFR; i++) { excp[i] = add (excp[i], exc[i + i_subfr]); - move16 (); } agc2 (&exc[i_subfr], excp, L_SUBFR); - Syn_filt (Az, excp, &synth[i_subfr], L_SUBFR, mem_syn, 1); + Syn_filt (Az, excp, &synth[i_subfr], L_SUBFR, st->mem_syn, 1); } else { - Syn_filt (Az, &exc[i_subfr], &synth[i_subfr], L_SUBFR, mem_syn, 1); + Syn_filt (Az, &exc[i_subfr], &synth[i_subfr], L_SUBFR, + st->mem_syn, 1); } -#if (WMOPS) - fwc (); /* function worst case */ -#endif /* interpolated LPC parameters for next subframe */ Az += MP1; move16 (); } @@ -414,11 +340,8 @@ * -> shift to the left by L_FRAME exc[] * *--------------------------------------------------*/ - Copy (&old_exc[L_FRAME], &old_exc[0], PIT_MAX + L_INTERPOL); -#if (WMOPS) - fwc (); /* function worst case */ -#endif - prev_bf = bfi; move16 (); + Copy (&st->old_exc[L_FRAME], &st->old_exc[0], PIT_MAX + L_INTERPOL); + st->prev_bf = bfi; return; }