# HG changeset patch # User Mychaela Falconia # Date 1669488769 0 # Node ID d80e9f12a1d1b37f2fdecccc0fdfd962a13c8522 # Parent b651adfce60defe57c2fcc1476002ed251a83c01 libgsmefr: decoder main function put together diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/Makefile --- a/libgsmefr/Makefile Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/Makefile Sat Nov 26 18:52:49 2022 +0000 @@ -2,12 +2,12 @@ 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_12k2.o dec_create.o \ - 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 pre_proc.o pred_lt6.o preemph.o pstfilt2.o q_gains.o \ - q_plsf_5.o reorder.o residu.o sid_class.o sid_insert.o syn_filt.o \ - tls_flags.o weight_a.o + dec_lag6.o dec_main.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 pre_proc.o pred_lt6.o \ + preemph.o pstfilt2.o q_gains.o q_plsf_5.o reorder.o residu.o \ + sid_class.o sid_insert.o syn_filt.o tls_flags.o weight_a.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 b651adfce60d -r d80e9f12a1d1 libgsmefr/codec.h --- a/libgsmefr/codec.h Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/codec.h Sat Nov 26 18:52:49 2022 +0000 @@ -10,10 +10,10 @@ void Decoder_12k2 ( 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 bfi, /* input : Bad Frame Indication */ + const 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 ); @@ -36,8 +36,8 @@ Word16 indx[] /* (o) : index of 10 pulses (sign + position) */ ); void dec_10i40_35bits ( - Word16 index[], /* (i) : index of 10 pulses (sign+position) */ - Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */ + const Word16 index[],/* (i) : index of 10 pulses (sign+position) */ + Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */ ); Word16 Dec_lag6 ( /* output: return integer pitch lag */ @@ -77,11 +77,11 @@ ); void D_plsf_5 ( struct EFR_decoder_state *st, - Word16 *indice, /* input : quantization indices of 5 submatrices */ - Word16 *lsp1_q, /* output: quantized 1st LSP vector */ - Word16 *lsp2_q, /* output: quantized 2nd LSP vector */ - Word16 bfi, /* input : bad frame indicator (set to 1 if a bad - frame is received) */ + const Word16 *indice,/* input : quantization indices of 5 submatrices */ + Word16 *lsp1_q, /* output: quantized 1st LSP vector */ + Word16 *lsp2_q, /* output: quantized 2nd LSP vector */ + Word16 bfi, /* input : bad frame indicator (set to 1 if a bad + frame is received) */ Word16 rxdtx_ctrl, Word16 rx_dtx_state ); diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/d1035pf.c --- a/libgsmefr/d1035pf.c Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/d1035pf.c Sat Nov 26 18:52:49 2022 +0000 @@ -22,8 +22,8 @@ #define NB_TRACK 5 /* number of track */ void dec_10i40_35bits ( - Word16 index[], /* (i) : index of 10 pulses (sign+position) */ - Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */ + const Word16 index[], /* (i) : index of 10 pulses (sign+position) */ + Word16 cod[] /* (o) : algebraic (fixed) codebook excitation */ ) { static const Word16 dgray[8] = {0, 1, 3, 2, 5, 6, 4, 7}; diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/d_homing.c --- a/libgsmefr/d_homing.c Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/d_homing.c Sat Nov 26 18:52:49 2022 +0000 @@ -114,7 +114,7 @@ * **************************************************************************/ -Word16 decoder_homing_frame_test (Word16 parm[], Word16 nbr_of_params) +Word16 decoder_homing_frame_test (const Word16 parm[], Word16 nbr_of_params) { static const Word16 dhf_mask[PRM_NO] = { diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/d_homing.h --- a/libgsmefr/d_homing.h Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/d_homing.h Sat Nov 26 18:52:49 2022 +0000 @@ -13,6 +13,6 @@ /* Function Prototypes */ -Word16 decoder_homing_frame_test (Word16 parm[], Word16 nbr_of_params); +Word16 decoder_homing_frame_test (const Word16 parm[], Word16 nbr_of_params); void decoder_reset (struct EFR_decoder_state *st); diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/d_plsf_5.c --- a/libgsmefr/d_plsf_5.c Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/d_plsf_5.c Sat Nov 26 18:52:49 2022 +0000 @@ -43,7 +43,7 @@ void D_plsf_5 ( struct EFR_decoder_state *st, - Word16 *indice, /* input : quantization indices of 5 submatrices */ + const Word16 *indice, /* input : quantization indices of 5 submatrices */ Word16 *lsp1_q, /* output: quantized 1st LSP vector */ Word16 *lsp2_q, /* output: quantized 2nd LSP vector */ Word16 bfi, /* input : bad frame indicator (set to 1 if a bad diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/dec_12k2.c --- a/libgsmefr/dec_12k2.c Sat Nov 26 17:56:24 2022 +0000 +++ b/libgsmefr/dec_12k2.c Sat Nov 26 18:52:49 2022 +0000 @@ -91,10 +91,10 @@ void Decoder_12k2 ( 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 bfi, /* input : Bad Frame Indication */ + const 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 ) diff -r b651adfce60d -r d80e9f12a1d1 libgsmefr/dec_main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmefr/dec_main.c Sat Nov 26 18:52:49 2022 +0000 @@ -0,0 +1,90 @@ +/* + * This module contains our GSM EFR decoder main function, EFR_decode_params(), + * that stands at the boundary between our public interface and the guts of + * ETSI-based codec. + */ + +#include "gsm_efr.h" +#include "typedef.h" +#include "namespace.h" +#include "cnst.h" +#include "codec.h" +#include "sig_proc.h" +#include "memops.h" +#include "dec_state.h" +#include "d_homing.h" + +/* These constants define the number of consecutive parameters + that function decoder_homing_frame_test() checks */ + +#define WHOLE_FRAME 57 +#define TO_FIRST_SUBFRAME 18 + +void EFR_decode_params(struct EFR_decoder_state *st, const int16_t *params, + int bfi, int SID_flag, int TAF, int16_t *pcm_out) +{ + Word16 *synth = st->synth_buf + M; + Word16 Az_dec[AZ_SIZE]; + Word16 i, temp; + Word16 reset_flag; + + if (!bfi) /* BFI == 0, perform DHF check */ + { + if (st->reset_flag_old) /* Check for second and further + successive DHF (to first subfr.) */ + { + reset_flag = decoder_homing_frame_test (params, + TO_FIRST_SUBFRAME); + } + else + { + reset_flag = 0; + } + } + else /* BFI==1, bypass DHF check (frame + is taken as not being a DHF) */ + { + reset_flag = 0; + } + + if (reset_flag && st->reset_flag_old) + { + /* Force the output to be the encoder homing frame pattern */ + + for (i = 0; i < L_FRAME; i++) + { + synth[i] = EHF_MASK; + } + } + else + { + /* Synthesis */ + Decoder_12k2 (st, bfi, params, synth, Az_dec, TAF, SID_flag); + + Post_Filter (st, synth, Az_dec); /* Post-filter */ + + for (i = 0; i < L_FRAME; i++) + /* Upscale the 15 bit linear PCM to 16 bits, + then truncate to 13 bits */ + { + temp = synth[i] << 1; + synth[i] = temp & 0xfff8; + } + } /* else */ + + Copy (synth, pcm_out, L_FRAME); + + /* BFI == 0, perform check for first DHF (whole frame) */ + if (!bfi && !st->reset_flag_old) + { + reset_flag = decoder_homing_frame_test (params, WHOLE_FRAME); + } + + if (reset_flag) + { + /* Bring the decoder and receive DTX to the home state */ + EFR_decoder_reset(st); + } else { + st->reset_flag_old = 0; + } +}