From 0d74cb1c45727fe5b9798198ee17996bb127f6ea Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 15:59:18 +0100 Subject: [PATCH 01/14] removal of duplicated code, under CLEANUP_ACELP_ENC --- lib_com/options.h | 1 + lib_com/prot_fx.h | 10 ++- lib_enc/acelp_core_enc_fx.c | 3 +- lib_enc/acelp_core_switch_enc_fx.c | 46 ++++++---- lib_enc/analy_lp_fx.c | 4 +- lib_enc/cod_tcx_fx.c | 4 +- lib_enc/core_switching_enc_fx.c | 9 +- lib_enc/enc_amr_wb_fx.c | 9 +- lib_enc/enc_gen_voic_fx.c | 15 ++++ lib_enc/enc_higher_acelp_fx.c | 18 +++- lib_enc/enc_pit_exc_fx.c | 15 +++- lib_enc/enc_tran_fx.c | 15 ++++ lib_enc/gs_enc_fx.c | 4 +- lib_enc/inov_enc_fx.c | 89 ++++++++++++++----- lib_enc/ivas_core_enc_fx.c | 4 + lib_enc/nois_est_fx.c | 2 +- lib_enc/prot_fx_enc.h | 45 +++++----- lib_enc/transition_enc_fx.c | 135 ++++++++++++++++++++++++----- 18 files changed, 328 insertions(+), 100 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..0363ea893 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 577451b04..90bba96d6 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10898,11 +10898,15 @@ ivas_error IGF_Reconfig_fx( ); void core_switching_post_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ + Encoder_State *st /* i/o: encoder state structure */ +#ifndef CLEANUP_ACELP_ENC + , Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new ); + Word16 Q_new +#endif +); void residu_ivas_fx( const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ @@ -11194,7 +11198,7 @@ ivas_error acelp_core_enc_ivas_fx( Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - Word16 Q_new ); + const Word16 Q_new ); void flip_and_downmix_generic_fx32( Word32 input[], /* i : input spectrum Qx*/ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 0596b2f2d..b21bc566b 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -699,6 +699,7 @@ ivas_error acelp_core_enc_fx( * * ACELP core encoder *--------------------------------------------------------------------*/ + ivas_error acelp_core_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 inp[], /* i : input signal of the current frame Q_new*/ @@ -717,7 +718,7 @@ ivas_error acelp_core_enc_ivas_fx( Word16 *unbits, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - Word16 Q_new ) + const Word16 Q_new ) { Word16 i, nBits; /* reserved bits */ LPD_state_HANDLE hLPDmem; /* i/o: acelp memories */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 2f51be28e..db2c27344 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -15,15 +15,18 @@ * Local function prototypes *---------------------------------------------------------------------*/ -static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); - -static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); +static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new ); +#ifndef CLEANUP_ACELP_ENC +static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, const Word16 shift, const Word16 Q_new ); +#endif static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech ); +#ifndef CLEANUP_ACELP_ENC static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech ); +#endif +static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, const Word16 qx, const Word16 qy, Word16 *qo, const Word16 len, const Word16 delta ); -static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta ); /*-------------------------------------------------------------------* * acelp_core_switch_enc_fx() @@ -36,8 +39,8 @@ void acelp_core_switch_enc_fx( const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */ const Word16 inp16k[], /* i : input signal @16 kHz Q0 */ const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 i, j, T_op[2]; Word16 old_exc[L_EXC], *exc; /* excitation signal buffer Qexc */ @@ -163,7 +166,7 @@ void acelp_core_switch_enc_fx( return; } - +#ifndef CLEANUP_ACELP_ENC void acelp_core_switch_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */ @@ -273,7 +276,7 @@ void acelp_core_switch_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------* * encod_gen_voic_core_switch() @@ -290,8 +293,8 @@ static void encod_gen_voic_core_switch_fx( const Word16 T_op[], /* i : open loop pitch Q0*/ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 res[L_SUBFR]; /* residual signal Qexc */ Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */ @@ -431,8 +434,13 @@ static void encod_gen_voic_core_switch_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, + h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); +#endif /*-----------------------------------------------------------------* * Gain encoding @@ -489,6 +497,7 @@ static void encod_gen_voic_core_switch_fx( return; } +#ifndef CLEANUP_ACELP_ENC static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -498,8 +507,8 @@ static void encod_gen_voic_core_switch_ivas_fx( const Word16 T_op[], /* i : open loop pitch Q0*/ Word16 *exc, /* i/o: current non-enhanced excitation Q_exc*/ const Word32 core_bitrate, /* i : switching frame bitrate Q0*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 res[L_SUBFR]; /* residual signal Qexc */ Word16 Ap[M + 1]; /* A(z) with spectral expansion Q12 */ @@ -699,6 +708,7 @@ static void encod_gen_voic_core_switch_ivas_fx( return; } +#endif /*-------------------------------------------------------------------* * bwe_switch_enc() @@ -849,7 +859,7 @@ static void bwe_switch_enc_fx( return; } - +#ifndef CLEANUP_ACELP_ENC static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *new_speech_fx /* i : original input signal Q0 */ @@ -989,16 +999,16 @@ static void bwe_switch_enc_ivas_fx( return; } - +#endif static Word16 dotprod_satcont( const Word16 *x, /* qx */ const Word16 *y, /* qy */ - Word16 qx, - Word16 qy, + const Word16 qx, + const Word16 qy, Word16 *qo, - Word16 len, /* Q0 */ - Word16 delta /* Q0 */ + const Word16 len, /* Q0 */ + const Word16 delta /* Q0 */ ) { Word16 tmp_tabx[L_FRAME48k], tmp_taby[L_FRAME48k]; diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index 873966116..ee8b57c6b 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -39,7 +39,7 @@ void analy_lp_fx( const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ const Word16 element_mode, /* i : element mode */ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ - Word16 Q_new, /* i : stores Q for speech */ + const Word16 Q_new, /* i : stores Q for speech */ Word16 *Q_r /*stores q for ener*/ ) { @@ -152,7 +152,7 @@ void analy_lp_AMR_WB_fx( Word16 isf_new[], /* o : current frame ISPs Q15*/ Word16 Top, /* i : open loop pitch lag Q0*/ Word16 Tnc, /* i : open loop pitch gain Qx*/ - Word16 Q_new, + const Word16 Q_new, Word16 *Q_r ) { Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 5d54b9729..e1a246817 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3908,8 +3908,8 @@ void coder_tcx_post_fx( const Word16 *A, const Word16 *Ai, Word16 *wsig, - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, + const Word16 shift ) { Word16 xn_buf[L_FRAME_MAX]; diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index aa06b12d2..2d44ba36a 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -1052,16 +1052,22 @@ void core_switching_pre_enc_ivas_fx( *---------------------------------------------------------------------*/ void core_switching_post_enc_ivas_fx( +#ifdef CLEANUP_ACELP_ENC + Encoder_State *st /* i/o: encoder state structure */ +#else Encoder_State *st, /* i/o: encoder state structure */ Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz Q_new-1 */ Word16 *old_inp_16k_fx, /* i : old input signal @16kHz Q_new-1 */ Word16 A_fx[], /* i : unquant. LP filter coefs. Q12 */ - Word16 Q_new ) + Word16 Q_new +#endif +) { IF( EQ_16( st->core, HQ_CORE ) ) { st->use_acelp_preq = 0; move16(); +#ifndef CLEANUP_ACELP_ENC test(); test(); IF( ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) && st->element_mode == EVS_MONO ) /* core switching ==> ACELP subframe encoding */ @@ -1079,6 +1085,7 @@ void core_switching_post_enc_ivas_fx( acelp_core_switch_enc_ivas_fx( st, old_inp_12k8_fx + L_INP_MEM - NS2SA( INT_FS_12k8, ACELP_LOOK_NS ), old_inp_16k_fx + L_INP_MEM - NS2SA( INT_FS_16k, ACELP_LOOK_NS ), A_fx, 0, sub( Q_new, 1 ) ); } +#endif st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index f68b94daf..9bb9d3a6f 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -29,8 +29,8 @@ void encod_amr_wb_fx( Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ const Word16 *speech16k_fx, /* i : input speech @16kHz Qx*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 xn[L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[L_SUBFR]; /* Target vector for codebook search */ @@ -174,8 +174,13 @@ void encod_amr_wb_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, + exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); +#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index bfe50a588..ee075c134 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -292,9 +292,14 @@ void encod_gen_voic_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift ); +#endif /*-----------------------------------------------------------------* * Gain encoding @@ -652,8 +657,13 @@ void encod_gen_voic_ivas_fx( test(); IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_16( st_fx->coder_type, INACTIVE ) ) { +#ifdef CLEANUP_ACELP_ENC + transf_cdbk_enc_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, + xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#else transf_cdbk_enc_ivas_fx( st_fx, harm_flag_acelp, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#endif } /*-----------------------------------------------------------------* @@ -708,8 +718,13 @@ void encod_gen_voic_ivas_fx( test(); IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) ) { +#ifdef CLEANUP_ACELP_ENC + transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, + Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#else transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx, Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 82296aa4a..a7afd750c 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -22,6 +22,7 @@ static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq *-----------------------------------------------------------------*/ #define Q_MINUS 4 +#ifndef CLEANUP_ACELP_ENC void transf_cdbk_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ @@ -375,9 +376,13 @@ void transf_cdbk_enc_fx( return; } +#endif - +#ifdef CLEANUP_ACELP_ENC +void transf_cdbk_enc_fx( +#else void transf_cdbk_enc_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ const Word16 i_subfr, /* i : subframe index Q0*/ @@ -490,7 +495,16 @@ void transf_cdbk_enc_ivas_fx( * Split algebraic vector quantizer based on RE8 lattice *--------------------------------------------------------------*/ - AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); + } + ELSE +#endif + { + AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, Qdct ); + } /*--------------------------------------------------------------* * Find prequantizer excitation gain diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 2d5902bc3..a69175aa7 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -63,8 +63,8 @@ void enc_pit_exc_fx( Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, + const Word16 shift ) { Word16 xn[PIT_EXC_L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[PIT_EXC_L_SUBFR]; /* Target vector for codebook search */ @@ -387,8 +387,13 @@ void enc_pit_exc_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); +#endif } /*-----------------------------------------------------------------* @@ -402,6 +407,7 @@ void enc_pit_exc_fx( /*-----------------------------------------------------------------* * Innovation & gain encoding *-----------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -411,8 +417,13 @@ void enc_pit_exc_fx( ELSE #endif { +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 879ed6dd0..43e0b8759 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -187,8 +187,13 @@ Word16 encod_tran_fx( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); +#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); +#endif test(); test(); @@ -564,8 +569,13 @@ Word16 encod_tran_ivas_fx( * adaptive/glottal part of excitation construction *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + transition_enc_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, + h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); +#else transition_enc_ivas_fx( st_fx, i_subfr, &tc_subfr, &Jopt_flag, &position, &T0, &T0_frac, &T0_min, &T0_max, exc_fx, y1, h1, xn, xn2, st_fx->clip_var_fx, &gain_pit, g_corr, &clip_gain, &pt_pitch, bwe_exc_fx, &unbits_ACELP, Q_new, shift ); +#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames @@ -573,8 +583,13 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { +#ifdef CLEANUP_ACELP_ENC + transf_cdbk_enc_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, + &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); +#else transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); +#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index b2800da5b..23a9a84fa 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -39,8 +39,8 @@ void encod_audio_fx( Word16 *tmp_noise, /* o : noise energy Q2 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0 */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6 */ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, + const Word16 shift ) { const Word16 *p_Aq; Word16 i, i_subfr, nb_subfr, last_pit_bin; diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 81b9ba49e..624988941 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -54,7 +54,7 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==============================================================================*/ - +#ifndef CLEANUP_ACELP_ENC Word16 inov_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -340,9 +340,13 @@ Word16 inov_encode_fx( return stack_pulses; } +#endif - +#ifdef CLEANUP_ACELP_ENCaa +Word16 inov_encode_fx( +#else Word16 inov_encode_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -365,8 +369,8 @@ Word16 inov_encode_ivas_fx( Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/ Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ - Word16 shift, - Word16 Q_new ) + const Word16 shift, + const Word16 Q_new ) { Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2; Word16 nBits, cmpl_flag; @@ -395,16 +399,35 @@ Word16 inov_encode_ivas_fx( move16(); } - maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); - IF( max_xn2 ) +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) +#endif { - Qxn = add( sub( Q_new, 1 ), shift ); + maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); + IF( max_xn2 ) + { + Qxn = add( sub( Q_new, 1 ), shift ); + } + ELSE + { + Qxn = 0; + move16(); + } +#ifdef CLEANUP_ACELP_ENC + + Qcn = Q_new; + move16(); +#endif } +#ifdef CLEANUP_ACELP_ENC ELSE { Qxn = 0; move16(); + Qcn = 0; + move16(); } +#endif /*----------------------------------------------------------------* * Update target vector for codebook search in residual domain @@ -414,8 +437,10 @@ Word16 inov_encode_ivas_fx( test(); test(); +#ifndef CLEANUP_ACELP_ENC Qcn = Q_new; move16(); +#endif IF( GT_32( core_brate, ACELP_13k20 ) && !Opt_AMR_WB && EQ_16( L_subfr, L_SUBFR ) ) { acelpautoc = 1; @@ -436,23 +461,42 @@ Word16 inov_encode_ivas_fx( acelpautoc = 0; move16(); updt_tar_fx( cn, cn, &exc[i_subfr], gain_pit, L_subfr ); + /* scaling of cn[] to limit dynamic at 12 bits */ Scale_sig( cn, L_subfr, shift ); - Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); - Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ - cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); - corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1 - IF( LT_16( Qdn, Qcn ) ) + +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) { - scale_sig( cn, L_subfr, sub( Qdn, Qcn ) ); - Qcn = Qdn; + cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); + + corr_xh_fx( xn2, dn, h2 ); + + Qdn = 0; move16(); } ELSE +#endif { - scale_sig( dn, L_subfr, sub( Qcn, Qdn ) ); - Qdn = Qcn; - move16(); + Word16 q_h1 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( 11, q_h1 ) ); /* set h2[] in Q11*/ + + cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); + + corr_xh_ivas_fx( xn2, Qxn, dn, &Qdn, h2, L_subfr ); // Q(dn) = Q_new+1 + + IF( LT_16( Qdn, Qcn ) ) + { + scale_sig( cn, L_subfr, sub( Qdn, Qcn ) ); + Qcn = Qdn; + move16(); + } + ELSE + { + scale_sig( dn, L_subfr, sub( Qcn, Qdn ) ); + Qdn = Qcn; + move16(); + } } } @@ -584,8 +628,13 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); - Qh2 = sub( 14, norm_s( h2[0] ) ); - Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) +#endif + { + Qh2 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); + } IF( !Opt_AMR_WB ) { @@ -683,7 +732,7 @@ Word16 inov_encode_ivas_fx( } ELSE { - nBits = st_fx->acelp_cfg.fixed_cdk_index[i_subfr >> 6]; + nBits = st_fx->acelp_cfg.fixed_cdk_index[shr( i_subfr, 6 )]; move16(); diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 2ee800325..c19ec47db 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -647,7 +647,11 @@ ivas_error ivas_core_enc_fx( * Postprocessing for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + core_switching_post_enc_ivas_fx( st ); +#else core_switching_post_enc_ivas_fx( st, old_inp_12k8_fx[n], old_inp_16k_fx[n], A_fx[n], Q_new[n] ); +#endif /*---------------------------------------------------------------------* * WB TBE encoding diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 41078054c..756ee4ac3 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -650,7 +650,7 @@ void noise_est_down_fx( Word16 Etot, /* i : Energy of current frame */ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */ - Word16 Q_new, + const Word16 Q_new, const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 13d11e72b..a32d7efd3 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -78,7 +78,7 @@ void analy_lp_fx( const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ const Word16 element_mode, /* i : element mode */ const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ - Word16 Q_new, /* i : stores Q for speech */ + const Word16 Q_new, /* i : stores Q for speech */ Word16 *Q_r /*stores q for ener*/ ); @@ -322,7 +322,7 @@ void noise_est_down_fx( Word16 Etot, /* i : Energy of current frame */ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */ Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */ - Word16 Q_new, + const Word16 Q_new, const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */ ); @@ -2125,9 +2125,10 @@ void encod_audio_fx( Word16 *tmp_noise, /* o : noise energy */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ - Word16 Q_new, - Word16 shift ); + const Word16 Q_new, + const Word16 shift ); +#ifndef CLEANUP_ACELP_ENC void encod_audio_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 speech[], /* i : input speech Q_new */ @@ -2146,7 +2147,7 @@ void encod_audio_ivas_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ Word16 Q_new, Word16 shift ); - +#endif void stat_noise_uv_enc_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 *LepsP, /* i : LP prediction errors */ @@ -2558,8 +2559,8 @@ void coder_tcx_post_fx( const Word16 *A, const Word16 *Ai, Word16 *wsig, - Word16 Q_new, - Word16 shift ); + const Word16 Q_new, + const Word16 shift ); void coder_tcx_post_ivas_fx( Encoder_State *st, @@ -3512,6 +3513,7 @@ Word16 lp_filt_exc_enc_fx( Word16 *lp_flag /* i/o: mode selection Q0 */ ); +#ifndef CLEANUP_ACELP_ENC Word16 inov_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -3536,7 +3538,7 @@ Word16 inov_encode_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ Word16 shift ); - +#endif Word16 inov_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -3560,8 +3562,8 @@ Word16 inov_encode_ivas_fx( Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/ Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ - Word16 shift, - Word16 Q_new ); + const Word16 shift, + const Word16 Q_new ); void gain_enc_mless_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -3608,7 +3610,7 @@ void analy_lp_AMR_WB_fx( Word16 isf_new[], /* o : current frame ISPs Q15*/ Word16 Top, /* i : open loop pitch lag Q0*/ Word16 Tnc, /* i : open loop pitch gain Qx*/ - Word16 Q_new, + const Word16 Q_new, Word16 *Q_r ); void encod_amr_wb_fx( @@ -3623,8 +3625,8 @@ void encod_amr_wb_fx( Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ - Word16 shift, - Word16 Q_new ); + const Word16 shift, + const Word16 Q_new ); void re8_cod_fx( Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ @@ -3644,9 +3646,10 @@ void acelp_core_switch_enc_fx( const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); + const Word16 shift, + const Word16 Q_new ); +#ifndef CLEANUP_ACELP_ENC void acelp_core_switch_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ @@ -3654,7 +3657,7 @@ void acelp_core_switch_enc_ivas_fx( const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ Word16 shift, Word16 Q_new ); - +#endif void gain_enc_amr_wb_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *xn, /* i : target vector Q_xn*/ @@ -3714,6 +3717,7 @@ void transf_cdbk_enc_fx( const Word16 shift /* i : shifting applied to y1, xn,... */ ); +#ifndef CLEANUP_ACELP_ENC void transf_cdbk_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ @@ -3738,7 +3742,7 @@ void transf_cdbk_enc_ivas_fx( const Word16 Q_new, /* i : Current frame scaling */ const Word16 shift /* i : shifting applied to y1, xn,... */ ); - +#endif void gain_enc_lbr_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3848,6 +3852,7 @@ void transition_enc_fx( Word16 shift /* i : downscaling needs for 12 bits convolutions */ ); +#ifndef CLEANUP_ACELP_ENC void transition_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index */ @@ -3873,7 +3878,7 @@ void transition_enc_ivas_fx( Word16 Q_new, /* i : Current scaling */ Word16 shift /* i : downscaling needs for 12 bits convolutions */ ); - +#endif void gain_enc_tc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -4010,8 +4015,8 @@ void enc_pit_exc_fx( Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ); + const Word16 Q_new, + const Word16 shift ); #ifndef FIX_1904_HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 547502eab..fce2df6c5 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -16,8 +16,9 @@ static void gain_trans_enc_fx( Word32 gain_trans32, Word16 exc[], Word16 *quant_index, Word16 *quant_sign, Word16 Q_new ); static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); +#ifndef CLEANUP_ACELP_ENC static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); - +#endif /*==========================================================================*/ /* FUNCTION : void transition_enc_fx () */ @@ -163,14 +164,29 @@ void transition_enc_fx( move16(); *clip_gain = 0; move16(); - g_corr_fx[0] = 16384; - move16(); - g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 ); - move16(); - g_corr_fx[2] = -16384; - move16(); - g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 ); - move16(); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; + move16(); + g_corr_fx[1] = 0; + move16(); + g_corr_fx[2] = MAX16B /* 1.0f in Q15 */; + move16(); + g_corr_fx[3] = 0; + } + ELSE +#endif + { + g_corr_fx[0] = 16384; + move16(); + g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 ); + move16(); + g_corr_fx[2] = -16384; + move16(); + g_corr_fx[3] = shl( sub( shift_wsp, 1 ), 1 ); + move16(); + } set16_fx( &exc_fx[i_subfr], 0, L_SUBFR ); /* set excitation for current subrame to 0 */ @@ -197,6 +213,7 @@ void transition_enc_fx( /*-----------------------------------------------------------------* * glottal codebook contribution construction *-----------------------------------------------------------------*/ + ELSE IF( EQ_16( *tc_subfr, i_subfr ) ) { IF( EQ_16( st_fx->L_frame, L_FRAME ) ) @@ -395,7 +412,16 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -443,11 +469,19 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; @@ -508,7 +542,16 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -533,11 +576,19 @@ void transition_enc_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); - FOR( i = 0; i < L_SUBFR * HIBND_ACB_L_FAC; i++ ) { bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr * HIBND_ACB_L_FAC - offset]; @@ -571,7 +622,16 @@ void transition_enc_fx( pit_Q_enc_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -807,10 +867,26 @@ void transition_enc_fx( move16(); *clip_gain = 0; move16(); - g_corr_fx[0] = 0; - move16(); - g_corr_fx[1] = 0; - move16(); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + g_corr_fx[0] = 328 /* 0.01f in Q15 */; + move16(); + g_corr_fx[1] = 0; + move16(); + g_corr_fx[2] = 328 /* 0.01f in Q15 */; + move16(); + g_corr_fx[3] = 0; + move16(); + } + ELSE +#endif + { + g_corr_fx[0] = 0; + move16(); + g_corr_fx[1] = 0; + move16(); + } *Jopt_flag = 0; move16(); @@ -824,7 +900,17 @@ void transition_enc_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode > EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + offset = L_deposit_l( 0 ); tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ @@ -889,6 +975,7 @@ void transition_enc_fx( return; } +#ifndef CLEANUP_ACELP_ENC void transition_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subframe index */ @@ -1717,7 +1804,7 @@ void transition_enc_ivas_fx( return; } - +#endif /*-------------------------------------------------------------------------------------------* * tc_enc() @@ -1959,7 +2046,7 @@ static void tc_enc_fx( return; } - +#ifndef CLEANUP_ACELP_ENC static void tc_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 i_subfr, /* i : subrame index */ @@ -2180,7 +2267,7 @@ static void tc_enc_ivas_fx( move16(); return; } - +#endif /*-----------------------------------------------------------------* * gain_trans_enc() -- GitLab From 4342d7e98271d36b519fffff757d10ba39d34598 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 16:29:04 +0100 Subject: [PATCH 02/14] removal of duplicated code, under CLEANUP_ACELP_ENC --- lib_enc/acelp_core_switch_enc_fx.c | 2 +- lib_enc/enc_amr_wb_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 9 +- lib_enc/enc_pit_exc_fx.c | 14 +- lib_enc/enc_tran_fx.c | 9 +- lib_enc/enc_uv_fx.c | 5 + lib_enc/inov_enc_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 7 +- lib_enc/prot_fx_enc.h | 2435 ++++++++++++++-------------- 9 files changed, 1257 insertions(+), 1228 deletions(-) diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index db2c27344..977bc099b 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -435,7 +435,7 @@ static void encod_gen_voic_core_switch_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, + inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 9bb9d3a6f..d3f0636ae 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -175,7 +175,7 @@ void encod_amr_wb_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, + inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index ee075c134..591c6e9bb 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -293,8 +293,8 @@ void encod_gen_voic_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, @@ -670,9 +670,14 @@ void encod_gen_voic_ivas_fx( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); +#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index a69175aa7..7cc932164 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -377,8 +377,13 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); +#endif } ELSE #endif @@ -388,7 +393,7 @@ void enc_pit_exc_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, @@ -411,14 +416,19 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#endif } ELSE #endif { #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 43e0b8759..639d34048 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -188,8 +188,8 @@ Word16 encod_tran_fx( *-----------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); @@ -596,8 +596,13 @@ Word16 encod_tran_ivas_fx( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#endif test(); test(); diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index eb6149359..86215f5b8 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -373,9 +373,14 @@ void encod_unvoiced_ivas_fx( * Encode the algebraic innovation * *----------------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); +#endif E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 624988941..4a9ba19fc 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -342,7 +342,7 @@ Word16 inov_encode_fx( } #endif -#ifdef CLEANUP_ACELP_ENCaa +#ifdef CLEANUP_ACELP_ENC Word16 inov_encode_fx( #else Word16 inov_encode_ivas_fx( diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index ef28b3c0a..6773a8839 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -322,14 +322,17 @@ void encod_gen_2sbfr( * Innovation encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new ); +#else inov_encode_ivas_fx( st, st->core_brate, 0, L_frame, st->last_L_frame, coder_type, st->bwidth, st->sharpFlag, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &i, 2 * L_SUBFR, shift, Q_new ); +#endif /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, - st->element_mode ); + gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); IF( st->Opt_SC_VBR ) { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a32d7efd3..f33abae3f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3513,8 +3513,8 @@ Word16 lp_filt_exc_enc_fx( Word16 *lp_flag /* i/o: mode selection Q0 */ ); -#ifndef CLEANUP_ACELP_ENC Word16 inov_encode_fx( +#ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -3538,8 +3538,9 @@ Word16 inov_encode_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ Word16 shift ); + +Word16 inov_encode_fx( #endif -Word16 inov_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -3565,1236 +3566,1236 @@ Word16 inov_encode_ivas_fx( const Word16 shift, const Word16 Q_new ); -void gain_enc_mless_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ -); - -void updt_IO_switch_enc_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 input_frame /* i : i frame length */ -); - -void hf_cod_init_fx( - Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ - Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ - Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ - Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ - Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ -); - -void analy_lp_AMR_WB_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 isp_new[], /* o : current frame ISPs Q15*/ - Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ - Word16 isf_new[], /* o : current frame ISPs Q15*/ - Word16 Top, /* i : open loop pitch lag Q0*/ - Word16 Tnc, /* i : open loop pitch gain Qx*/ - const Word16 Q_new, - Word16 *Q_r ); - -void encod_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 speech[], /* i : i speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *syn, /* i/o: core synthesis st->Q_syn*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ - const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ - const Word16 shift, - const Word16 Q_new ); - -void re8_cod_fx( - Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ - UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ - Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ -); - -void TBEreset_enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 last_core, /* i : last core */ - Word16 bandwidth /* i : bandwidth mode */ -); - -void acelp_core_switch_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - const Word16 shift, - const Word16 Q_new ); + void gain_enc_mless_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 scaling */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ + ); + + void updt_IO_switch_enc_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 input_frame /* i : i frame length */ + ); + + void hf_cod_init_fx( + Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ + Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ + Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ + Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ + Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ + ); + + void analy_lp_AMR_WB_fx( + const Word16 speech[], /* i : pointer to the speech frame Q_new*/ + Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ + Word16 A[], /* o : A(z) filter coefficients Q14*/ + Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 isp_new[], /* o : current frame ISPs Q15*/ + Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ + Word16 isf_new[], /* o : current frame ISPs Q15*/ + Word16 Top, /* i : open loop pitch lag Q0*/ + Word16 Tnc, /* i : open loop pitch gain Qx*/ + const Word16 Q_new, + Word16 *Q_r ); + + void encod_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 speech[], /* i : i speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *syn, /* i/o: core synthesis st->Q_syn*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ + const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ + const Word16 shift, + const Word16 Q_new ); + + void re8_cod_fx( + Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ + UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ + Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ + ); + + void TBEreset_enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ + ); + + void acelp_core_switch_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + const Word16 shift, + const Word16 Q_new ); #ifndef CLEANUP_ACELP_ENC -void acelp_core_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); + void acelp_core_switch_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + Word16 shift, + Word16 Q_new ); #endif -void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 Q_xn, /* i : xn and yy1 format */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ -); - -void hf_cod_fx( - const Word32 core_brate_fx, /* i : core bitrate */ - const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ - const Word16 Aq_fx[], /* i : quantized Aq */ - const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ - Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ - Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ - Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ - Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ - Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ - Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ - const Word16 dtxHangoverCount_fx, - Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ - Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ - Word16 Q_exc, - Word16 Q_syn ); - -void transf_cdbk_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ -); + void gain_enc_amr_wb_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 Q_xn, /* i : xn and yy1 format */ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ + ); + + void hf_cod_fx( + const Word32 core_brate_fx, /* i : core bitrate */ + const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ + const Word16 Aq_fx[], /* i : quantized Aq */ + const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ + Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ + Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ + Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ + Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ + Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ + Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ + const Word16 dtxHangoverCount_fx, + Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ + Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ + Word16 Q_exc, + Word16 Q_syn ); + + void transf_cdbk_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ + ); #ifndef CLEANUP_ACELP_ENC -void transf_cdbk_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ -); + void transf_cdbk_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ + ); #endif -void gain_enc_lbr_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 format */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr, /* i : subframe length Q0*/ - const Word16 element_mode /* i : mode element Q0*/ -); - -void gain_enc_SQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); - -void updt_tar_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 L /* i : subframe size */ -); - -void updt_tar_HR_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 Qx, /* i : Scaling factor to adapt output to i */ - const Word16 L /* i : subframe size */ -); - -Flag conv_fx( - const Word16 x[], /* i : i vector Q_new*/ - const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ - Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ - const Word16 L /* i : vector size */ -); - -ivas_error ppp_voiced_encoder_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - SC_VBR_ENC_HANDLE hSC_VBR, - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 last_coder_type_raw, /* i : raw last_coder_type */ - const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ - Word16 *in_fx, /* i : residual signal */ - Word16 *out_fx, /* o : Quantized residual signal */ - Word16 delay_fx, /* i : open loop pitch */ - Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ - Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ - Word16 *exc_fx, /* i: previous frame quantized excitation */ - Word16 *pitch_fx, /* o: floating pitch values for each subframe */ - Word16 Qres ); - -void signalling_enc_fx( - Encoder_State *st_fx /* i : encoder state structure */ -); - -void transition_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ -); + void gain_enc_lbr_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 format */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ + ); + + void gain_enc_SQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 Q_xn /* i : xn and y1 scaling */ + ); + + void updt_tar_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 L /* i : subframe size */ + ); + + void updt_tar_HR_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 Qx, /* i : Scaling factor to adapt output to i */ + const Word16 L /* i : subframe size */ + ); + + Flag conv_fx( + const Word16 x[], /* i : i vector Q_new*/ + const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ + Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ + const Word16 L /* i : vector size */ + ); + + ivas_error ppp_voiced_encoder_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + SC_VBR_ENC_HANDLE hSC_VBR, + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 last_coder_type_raw, /* i : raw last_coder_type */ + const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ + Word16 *in_fx, /* i : residual signal */ + Word16 *out_fx, /* o : Quantized residual signal */ + Word16 delay_fx, /* i : open loop pitch */ + Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ + Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ + Word16 *exc_fx, /* i: previous frame quantized excitation */ + Word16 *pitch_fx, /* o: floating pitch values for each subframe */ + Word16 Qres ); + + void signalling_enc_fx( + Encoder_State *st_fx /* i : encoder state structure */ + ); + + void transition_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ + ); #ifndef CLEANUP_ACELP_ENC -void transition_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ -); + void transition_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ + ); #endif -void gain_enc_tc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); - -void gain_enc_tc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ - const Word16 Q_xn /* i : xn and y1 scaling */ -); - -Word16 gaus_encode_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ -); - -Word16 gaus_encode_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ -); - -void pre_proc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_frame, /* i : frame length */ - Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ - Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ - Word16 **inp, /* o : ptr. to inp. signal in the current frame */ - Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ - Word16 *Etot, /* o : total energy */ - Word32 *ener, /* o : residual energy from Levinson-Durbin */ + void gain_enc_tc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + const Word16 Q_xn /* i : xn and y1 scaling */ + ); + + void gain_enc_tc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ + const Word16 Q_xn /* i : xn and y1 scaling */ + ); + + Word16 gaus_encode_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ + ); + + Word16 gaus_encode_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ + ); + + void pre_proc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_frame, /* i : frame length */ + Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ + Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ + Word16 **inp, /* o : ptr. to inp. signal in the current frame */ + Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ + Word16 *Etot, /* o : total energy */ + Word32 *ener, /* o : residual energy from Levinson-Durbin */ #ifndef FIX_I4_OL_PITCH - Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ + Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ #endif - Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1], /* o : LP prediction errors */ - Word16 epsP_l[M + 1], /* o : LP prediction errors */ - Word32 epsP[M + 1], /* o : LP prediction errors */ - Word16 lsp_new[M], /* o : LSPs at the end of the frame */ - Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ - Word16 *vad_hover_flag, - Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ - Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ - CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ - Word16 *old_exc, /* i/o: static excitation memory */ - Word16 *hq_core_type, /* o : HQ core type */ - Word16 *Q_new, - Word16 *shift, - Word16 *Q_r ); - -void swb_bwe_enc_hr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *new_input_fx, /* i : i signal */ - Word16 new_input_fx_exp, /* i : Exponent of i signal */ - const Word16 input_frame, /* i : frame length */ - const Word16 unbits /* i : number of core unused bits */ -); - -/* o : Return index of quantization */ -Word16 gain_enc_gaus_fx( - Word32 *gain, /* i/o: Code gain to quantize Q16*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ -); - -void enc_pit_exc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *speech, /* i : Input speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - const Word16 Q_new, - const Word16 shift ); + Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ + Word16 epsP_h[M + 1], /* o : LP prediction errors */ + Word16 epsP_l[M + 1], /* o : LP prediction errors */ + Word32 epsP[M + 1], /* o : LP prediction errors */ + Word16 lsp_new[M], /* o : LSPs at the end of the frame */ + Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ + Word16 *vad_hover_flag, + Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ + Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ + CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ + Word16 *old_exc, /* i/o: static excitation memory */ + Word16 *hq_core_type, /* o : HQ core type */ + Word16 *Q_new, + Word16 *shift, + Word16 *Q_r ); + + void swb_bwe_enc_hr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *new_input_fx, /* i : i signal */ + Word16 new_input_fx_exp, /* i : Exponent of i signal */ + const Word16 input_frame, /* i : frame length */ + const Word16 unbits /* i : number of core unused bits */ + ); + + /* o : Return index of quantization */ + Word16 gain_enc_gaus_fx( + Word32 *gain, /* i/o: Code gain to quantize Q16*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ + ); + + void enc_pit_exc_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + const Word16 Q_new, + const Word16 shift ); #ifndef FIX_1904_HARM_GSC_ENC -void enc_pit_exc_ivas_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *speech, /* i : Input speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ); + void enc_pit_exc_ivas_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + Word16 Q_new, + Word16 shift ); #endif -/* o : bin where pitch contribution is significant */ -Word16 Pit_exc_contribution_len_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); + /* o : bin where pitch contribution is significant */ + Word16 Pit_exc_contribution_len_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); #ifndef FIX_1904_HARM_GSC_ENC -/* o : bin where pitch contribution is significant */ -Word16 Pit_exc_contribution_len_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); + /* o : bin where pitch contribution is significant */ + Word16 Pit_exc_contribution_len_ivas_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); #endif -Word16 pvq_core_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ -); - -Word16 pvq_core_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ -); -void core_switching_hq_prepare_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ - const Word16 *audio /*q_audio*/ ); - -void hq_lr_enc_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ -); - -void hq_lr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ -); - -void hq_hr_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ -); - -void hq_hr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ -); - -void reordernorm_fx( - const Word16 *ynrm, /* i : quantization indices for norms Q0 */ - const Word16 *normqlg2, /* i : quantized norms Q0 */ - Word16 *idxbuf, /* o : reordered quantization indices Q0 */ - Word16 *normbuf, /* o : reordered quantized norms Q0 */ - const Word16 nb_sfm /* i : number of bands Q0 */ -); - -void diffcod_fx( - const Word16 N, /* (i) number of sub-vectors Q0*/ - Word16 *y, /* (i/o) indices of quantized norms Q0*/ - Word16 *difidx /* (o) differential code Q0*/ -); - -/* o : Consumed bits Q0 */ -Word16 hq_classifier_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); - -/* o : Consumed bits Q0 */ -Word16 hq_classifier_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); - -void diff_envelope_coding_fx( - const Word16 is_transient, /* i : transient indicator Q0 */ - const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ - const Word16 start_norm, /* i : start of envelope coding Q0 */ - Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ - Word16 *normqlg2, /* i/o: quantized norms Q0 */ - Word16 *difidx /* o : differential code Q0 */ -); - -/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ -Word16 encode_envelope_indices_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ -); - -void hq_generic_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas /* o : bwe excitation class */ -); - -void normalizecoefs_fx( - Word32 *coefs, /* i : Input vector (Q12) */ - const Word16 *ynrm, /* i : quantization indices for norms */ - const Word16 num_bands, /* i : Number of bands */ - const Word16 *band_start, /* i : Start of bands */ - const Word16 *band_end, /* i : End of bands */ - Word16 *coefs_norm /* o : Normalized output vector (Q12) */ -); - -/* o : Consumed bits */ -Word16 hvq_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 brate, /* i : Total bit rate */ - const Word16 hvq_bits, /* i : HVQ bit budget */ - const Word16 Npeaks, /* i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - Word16 *noise_level, /* o : Quantized noise level */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q14 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ -); - -/* o : Consumed bits */ -Word16 hvq_enc_ivas_fx( - Encoder_State *st_fx, /*i/o: encoder state structure */ - const Word32 core_brate, /*i : Total bit rate */ - const Word16 hvq_bits, /*i : HVQ bit budget */ - const Word16 Npeaks, /*i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ - Word16 *noise_level, /* o : Quantized noise level Q15 */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q12 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ -); - -Word16 pvq_core_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ -); - -/* o : index of noise attenuation Q0 */ -Word16 noise_adjust_fx( - const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ - const Word16 qx, /* i : Q value of coeffs_norm */ - const Word16 *bitalloc, /* i : bit allocation Q0 */ - const Word16 *sfm_start, /* i : band start Q0 */ - const Word16 *sfm_end, /* i : band end Q0 */ - const Word16 core_sfm /* i : index of the end band for core Q0 */ -); - -ivas_error tcq_core_LR_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 inp_vector_fx[], /* x5 */ - const Word32 coefs_norm_fx[], /* Q12 */ - Word32 coefs_quant_fx[], /* Q12 */ - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *R_fx, /* Q16 */ - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - -ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector[], - const Word32 coefs_norm_fx[], - Word32 coefs_quant_fx[], - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *Rk_fx, - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - -/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ -Word16 encode_envelope_indices_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ -); - -void diffcod_lrmdct_fx( - const Word16 N, /* i : number of sub-vectors Q0*/ - const Word16 be_ref, /* i : band energy reference Q0*/ - Word16 *y, /* i/o: indices of quantized norms Q0*/ - Word16 *difidx, /* o : differential code Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ -); - -Word16 peak_vq_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 core_brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ -); - -Word16 peak_vq_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ -); - -void wb_vad_init_fx( - VAD_HANDLE hVAD /* i/o: VAD data handle */ -); - -void noise_est_init_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ -); - -void noise_est_init_ivas_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ -); - -void InitSWBencBuffer_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void InitSWBencBuffer_ivas_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -void ResetSHBbuffer_Enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ -); - -Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); - -Word16 E_ACELP_hh_corr( - Word16 *x /*Q11*/, - Word16 *y /*Qy*/, - Word16 L_subfr /*Q0*/, - Word16 bits /*Q0*/ -); - -void acelp_1t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[], /* o : filtered fixed codebook excitation */ - const Word16 L_subfr /* i : subframe length */ -); - -void acelp_2t32_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[] /* o : filtered fixed codebook excitation */ -); - -Word16 acelp_4t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 cn[], /* i : residual after long term prediction Q_new*/ - const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ - Word16 R[], /* i : autocorrelation values */ - const Word16 acelpautoc, /* i : autocorrealtion flag */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - Word16 y[], /* o : filtered fixed codebook excitation Q9*/ - Word16 nbbits, /* i : number of bits per codebook */ - const Word16 cmpl_flag, /* i : coomplexity reduction flag */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 element_mode ); - -ivas_error evs_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *data, /* i : input signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of input samples Q0*/ -); - -/* o: Qx y(n) */ -/* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ -Word16 noise_est_AR1_Qx( - Word16 x, /* i : Qx x(n) */ - Word16 y, /* i : Qx y(n-1) */ - Word16 alpha /* i : Q15 scaling of driving x(n) */ -); - -/*o : Qx y( n ) */ -Word32 noise_est_AR1_Qx_32( - Word32 x, /* i : Qx x(n) */ - Word32 y, /* i : Qx y(n-1) */ - Word32 alpha /* i : Q15 scaling of driving x(n) */ -); - -void FEC_lsf_estim_enc_fx( - Encoder_State *st_fx, /* i : Encoder static memory */ - Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ -); - -Word32 mslvq_cng_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w, /* i : weights for LSF quantization Q10*/ - Word16 *no_scales ); - -Word32 mslvq_cng_ivas_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w /* i : weights for LSF quantization Q10*/ -); - -void Unified_weighting_fx( - const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ - Word16 Q_ener, - const Word16 lsf_fx[], /* i : LSF vector x2.56 */ - Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ - const Word16 narrowBand, /* i : flag for Narrowband Q0*/ - const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ - const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ - const Word16 order /* i : LP order Q0*/ -); - -Word32 qlsf_ARSN_tcvq_Enc_16k_fx( - const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ - Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ - Word16 *indice, /* o : Indices */ - const Word16 *w_fx, /* i : LSF Weights Q10 */ - const Word16 nBits, /* i : number of bits */ - Word16 safety_net /* i : safety_net flag */ -); - -Word32 mslvq_fx( - Word16 *pTmp, /* i : M-dimensional i vector */ - Word16 *quant, /* o : quantized vector */ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - Word16 *w, /* i : weights for LSF quantization */ - Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ - Word16 mode_glb, /* i : LVQ coding mode */ - Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ - Word16 no_scales[][2] ); - -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ -Word16 multi_harm_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -); - -/* o : frame multi-harmonicity (1-harmonic, 0-not) */ -Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -); - -void pvq_encode_frame_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ -); - -void pvq_encode_frame_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ -); - -/*Qx o : interpolated value */ -Word16 Interpol_4( - Word16 *x, /*Qx i : i vector */ - Word16 frac /* i : fraction (-4..+3) */ -); - -void set_ppp_mode_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ - const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ - const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ - const Word16 localVAD_he /* i : HE-SAD flag without hangover */ -); - -void decision_matrix_enc_fx( - Encoder_State *st_fx, /* i : encoder state structure */ - Word16 *hq_core_type /* o : HQ core_fx type Q0*/ -); - -void pvq_encode_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ -); - -void pvq_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ -); - -void rc_enc_init_fx( - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - Word16 tot_bits /* i : Total bit budget Q0*/ -); - -void rc_enc_finish_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ -); - -void rc_enc_finish_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ - -); - -void rc_encode_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ -); - -void rc_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ -); - -void rc_enc_uniform_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ -); - -void rc_enc_uniform_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ -); - -void rc_enc_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ -); - -void rc_enc_bits_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ -); - -void re8_compute_base_index_fx( - const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ - const Word16 ka, /* i : Identifier of the absolute leader related to x */ - UWord16 *I /* o : index */ -); - -void tfaCalcEnv_fx( - const Word16 *shb_speech, - Word32 *enr ); - -/* o : pitch index */ -Word16 delta_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac, /* i : pitch fraction */ - const Word16 T0_min /* i : delta search min */ -); - -void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ - Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ - Word16 *imp_shape, /* o : adaptive codebook index Q0*/ - Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ - Word32 *gain_trans_fx, /* o : transition gain Q7*/ - Word16 Q_new /* i : Current scaling */ -); - -/* o : pitch index */ -Word16 abs_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac /* i : pitch fraction */ -); - -ivas_error ppp_quarter_encoder_fx( - Word16 *returnFlag, /* o : return value */ - DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ - Word16 prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ - const Word16 *curr_lpc_fx, /* i : LPCS */ - Word16 *lastLgainE_fx, /* i/o: last low band gain */ - Word16 *lastHgainE_fx, /* i/o: last high band gain */ - Word16 *lasterbE_fx, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ - Word16 *S_fx, /* i : sin table, Q15 */ - Word16 *C_fx, /* i : cos table, Q15 */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void index_lvq_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - -void index_lvq_ivas_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - const Word16 prediction_flag ); - -void copy_encoder_config_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ -); - -void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : i signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of i samples Q0*/ -); - -void writeLPCparam_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ -); - -Word16 cng_energy_ivas_fx( - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidh */ - const Word16 CNG_mode, /* i : mode for DTX configuration */ - const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ - const Word16 *exc, /* i : input signal */ - const Word16 len, /* i : vector length */ - const Word16 Q_new /* i : Input scaling */ -); - -void generate_comfort_noise_enc_ivas_fx( - Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ); - -void SynthesisSTFT_enc_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -ivas_error write_indices_ivas_fx( - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - UWord16 *bit_stream, /* i/o: output bitstream */ - UWord16 *num_bits /* i : number of indices written to output */ -); + Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ + ); + + Word16 pvq_core_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ + ); + void core_switching_hq_prepare_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ + const Word16 *audio /*q_audio*/ ); + + void hq_lr_enc_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ + ); + + void hq_lr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ + ); + + void hq_hr_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ + ); + + void hq_hr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ + ); + + void reordernorm_fx( + const Word16 *ynrm, /* i : quantization indices for norms Q0 */ + const Word16 *normqlg2, /* i : quantized norms Q0 */ + Word16 *idxbuf, /* o : reordered quantization indices Q0 */ + Word16 *normbuf, /* o : reordered quantized norms Q0 */ + const Word16 nb_sfm /* i : number of bands Q0 */ + ); + + void diffcod_fx( + const Word16 N, /* (i) number of sub-vectors Q0*/ + Word16 *y, /* (i/o) indices of quantized norms Q0*/ + Word16 *difidx /* (o) differential code Q0*/ + ); + + /* o : Consumed bits Q0 */ + Word16 hq_classifier_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ + ); + + /* o : Consumed bits Q0 */ + Word16 hq_classifier_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ + ); + + void diff_envelope_coding_fx( + const Word16 is_transient, /* i : transient indicator Q0 */ + const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ + const Word16 start_norm, /* i : start of envelope coding Q0 */ + Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ + Word16 *normqlg2, /* i/o: quantized norms Q0 */ + Word16 *difidx /* o : differential code Q0 */ + ); + + /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ + Word16 encode_envelope_indices_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ + ); + + void hq_generic_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas /* o : bwe excitation class */ + ); + + void normalizecoefs_fx( + Word32 *coefs, /* i : Input vector (Q12) */ + const Word16 *ynrm, /* i : quantization indices for norms */ + const Word16 num_bands, /* i : Number of bands */ + const Word16 *band_start, /* i : Start of bands */ + const Word16 *band_end, /* i : End of bands */ + Word16 *coefs_norm /* o : Normalized output vector (Q12) */ + ); + + /* o : Consumed bits */ + Word16 hvq_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 brate, /* i : Total bit rate */ + const Word16 hvq_bits, /* i : HVQ bit budget */ + const Word16 Npeaks, /* i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ + Word16 *noise_level, /* o : Quantized noise level */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q14 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ + ); + + /* o : Consumed bits */ + Word16 hvq_enc_ivas_fx( + Encoder_State *st_fx, /*i/o: encoder state structure */ + const Word32 core_brate, /*i : Total bit rate */ + const Word16 hvq_bits, /*i : HVQ bit budget */ + const Word16 Npeaks, /*i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ + Word16 *noise_level, /* o : Quantized noise level Q15 */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q12 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ + ); + + Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ + ); + + /* o : index of noise attenuation Q0 */ + Word16 noise_adjust_fx( + const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ + const Word16 qx, /* i : Q value of coeffs_norm */ + const Word16 *bitalloc, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : band start Q0 */ + const Word16 *sfm_end, /* i : band end Q0 */ + const Word16 core_sfm /* i : index of the end band for core Q0 */ + ); + + ivas_error tcq_core_LR_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 inp_vector_fx[], /* x5 */ + const Word32 coefs_norm_fx[], /* Q12 */ + Word32 coefs_quant_fx[], /* Q12 */ + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *R_fx, /* Q16 */ + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + + ivas_error tcq_core_LR_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word32 inp_vector[], + const Word32 coefs_norm_fx[], + Word32 coefs_quant_fx[], + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *Rk_fx, + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + + /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ + Word16 encode_envelope_indices_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ + ); + + void diffcod_lrmdct_fx( + const Word16 N, /* i : number of sub-vectors Q0*/ + const Word16 be_ref, /* i : band energy reference Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx, /* o : differential code Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ + ); + + Word16 peak_vq_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 core_brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ + ); + + Word16 peak_vq_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ + ); + + void wb_vad_init_fx( + VAD_HANDLE hVAD /* i/o: VAD data handle */ + ); + + void noise_est_init_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ + ); + + void noise_est_init_ivas_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ + ); + + void InitSWBencBuffer_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ + ); + + void InitSWBencBuffer_ivas_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ + ); + + void ResetSHBbuffer_Enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ + ); + + Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); + + Word16 E_ACELP_hh_corr( + Word16 *x /*Q11*/, + Word16 *y /*Qy*/, + Word16 L_subfr /*Q0*/, + Word16 bits /*Q0*/ + ); + + void acelp_1t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[], /* o : filtered fixed codebook excitation */ + const Word16 L_subfr /* i : subframe length */ + ); + + void acelp_2t32_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[] /* o : filtered fixed codebook excitation */ + ); + + Word16 acelp_4t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 cn[], /* i : residual after long term prediction Q_new*/ + const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ + Word16 R[], /* i : autocorrelation values */ + const Word16 acelpautoc, /* i : autocorrealtion flag */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + Word16 y[], /* o : filtered fixed codebook excitation Q9*/ + Word16 nbbits, /* i : number of bits per codebook */ + const Word16 cmpl_flag, /* i : coomplexity reduction flag */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 element_mode ); + + ivas_error evs_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *data, /* i : input signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of input samples Q0*/ + ); + + /* o: Qx y(n) */ + /* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ + Word16 noise_est_AR1_Qx( + Word16 x, /* i : Qx x(n) */ + Word16 y, /* i : Qx y(n-1) */ + Word16 alpha /* i : Q15 scaling of driving x(n) */ + ); + + /*o : Qx y( n ) */ + Word32 noise_est_AR1_Qx_32( + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /* i : Q15 scaling of driving x(n) */ + ); + + void FEC_lsf_estim_enc_fx( + Encoder_State *st_fx, /* i : Encoder static memory */ + Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ + ); + + Word32 mslvq_cng_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w, /* i : weights for LSF quantization Q10*/ + Word16 *no_scales ); + + Word32 mslvq_cng_ivas_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w /* i : weights for LSF quantization Q10*/ + ); + + void Unified_weighting_fx( + const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ + Word16 Q_ener, + const Word16 lsf_fx[], /* i : LSF vector x2.56 */ + Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ + const Word16 narrowBand, /* i : flag for Narrowband Q0*/ + const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 order /* i : LP order Q0*/ + ); + + Word32 qlsf_ARSN_tcvq_Enc_16k_fx( + const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ + Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ + Word16 *indice, /* o : Indices */ + const Word16 *w_fx, /* i : LSF Weights Q10 */ + const Word16 nBits, /* i : number of bits */ + Word16 safety_net /* i : safety_net flag */ + ); + + Word32 mslvq_fx( + Word16 *pTmp, /* i : M-dimensional i vector */ + Word16 *quant, /* o : quantized vector */ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + Word16 *w, /* i : weights for LSF quantization */ + Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ + Word16 mode_glb, /* i : LVQ coding mode */ + Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ + Word16 no_scales[][2] ); + + /* o : frame multi-harmonicity (1-harmonic, 0-not) */ + Word16 multi_harm_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ + ); + + /* o : frame multi-harmonicity (1-harmonic, 0-not) */ + Word16 multi_harm_ivas_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ + ); + + void pvq_encode_frame_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ + ); + + void pvq_encode_frame_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ + ); + + /*Qx o : interpolated value */ + Word16 Interpol_4( + Word16 *x, /*Qx i : i vector */ + Word16 frac /* i : fraction (-4..+3) */ + ); + + void set_ppp_mode_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ + const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ + const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ + const Word16 localVAD_he /* i : HE-SAD flag without hangover */ + ); + + void decision_matrix_enc_fx( + Encoder_State *st_fx, /* i : encoder state structure */ + Word16 *hq_core_type /* o : HQ core_fx type Q0*/ + ); + + void pvq_encode_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ + ); + + void pvq_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ + ); + + void rc_enc_init_fx( + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + Word16 tot_bits /* i : Total bit budget Q0*/ + ); + + void rc_enc_finish_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ + ); + + void rc_enc_finish_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ + + ); + + void rc_encode_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ + ); + + void rc_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ + ); + + void rc_enc_uniform_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ + ); + + void rc_enc_uniform_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ + ); + + void rc_enc_bits_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ + ); + + void rc_enc_bits_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ + ); + + void re8_compute_base_index_fx( + const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ + const Word16 ka, /* i : Identifier of the absolute leader related to x */ + UWord16 *I /* o : index */ + ); + + void tfaCalcEnv_fx( + const Word16 *shb_speech, + Word32 *enr ); + + /* o : pitch index */ + Word16 delta_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac, /* i : pitch fraction */ + const Word16 T0_min /* i : delta search min */ + ); + + void set_impulse_fx( + const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ + const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ + Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ + Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ + Word16 *imp_shape, /* o : adaptive codebook index Q0*/ + Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ + Word32 *gain_trans_fx, /* o : transition gain Q7*/ + Word16 Q_new /* i : Current scaling */ + ); + + /* o : pitch index */ + Word16 abs_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac /* i : pitch fraction */ + ); + + ivas_error ppp_quarter_encoder_fx( + Word16 *returnFlag, /* o : return value */ + DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ + DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ + Word16 prevCW_lag, /* i : previous lag */ + DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ + const Word16 *curr_lpc_fx, /* i : LPCS */ + Word16 *lastLgainE_fx, /* i/o: last low band gain */ + Word16 *lastHgainE_fx, /* i/o: last high band gain */ + Word16 *lasterbE_fx, /* i/o: last ERB vector */ + DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ + Word16 *S_fx, /* i : sin table, Q15 */ + Word16 *C_fx, /* i : cos table, Q15 */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + ); + + void index_lvq_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + + void index_lvq_ivas_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + const Word16 prediction_flag ); + + void copy_encoder_config_fx( + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ + ); + + void amr_wb_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_sp[], /* i : i signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of i samples Q0*/ + ); + + void writeLPCparam_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ + ); + + Word16 cng_energy_ivas_fx( + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidh */ + const Word16 CNG_mode, /* i : mode for DTX configuration */ + const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ + const Word16 *exc, /* i : input signal */ + const Word16 len, /* i : vector length */ + const Word16 Q_new /* i : Input scaling */ + ); + + void generate_comfort_noise_enc_ivas_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ); + + void SynthesisSTFT_enc_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + ivas_error write_indices_ivas_fx( + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + UWord16 *bit_stream, /* i/o: output bitstream */ + UWord16 *num_bits /* i : number of indices written to output */ + ); #endif -- GitLab From 3113ee2527e7cc96f44c04a4cd27d52b83d10dc9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 16:52:06 +0100 Subject: [PATCH 03/14] harmonize est_tilt_ivas_fx(), under CLEANUP_ACELP_ENC --- lib_com/est_tilt_fx.c | 9 ++++++++- lib_com/prot_fx.h | 7 +++++-- lib_dec/dec_gen_voic_fx.c | 10 ++++++++-- lib_dec/dec_pit_exc_fx.c | 10 +++++++++- lib_dec/dec_tran_fx.c | 10 ++++++++++ lib_dec/dec_uv_fx.c | 9 +++++++-- lib_dec/ivas_td_low_rate_dec_fx.c | 9 ++++++--- lib_enc/acelp_core_switch_enc_fx.c | 7 ++++++- lib_enc/enc_gen_voic_fx.c | 4 ++++ lib_enc/enc_pit_exc_fx.c | 10 +++++++--- lib_enc/enc_tran_fx.c | 8 +++++++- lib_enc/ivas_td_low_rate_enc_fx.c | 5 +++++ 12 files changed, 82 insertions(+), 16 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 4ad2a85a1..bbcc22e69 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -120,8 +120,11 @@ Word16 est_tilt_ivas_fx( const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr, /* i : Sub frame length */ + const Word16 L_subfr /* i : Sub frame length */ +#ifndef CLEANUP_ACELP_ENC + , const Word16 flag_tilt /* i : flag for special tilt */ +#endif ) { Word16 i, tmp, exp, ener1, exp1, ener2, exp2; @@ -161,6 +164,9 @@ Word16 est_tilt_ivas_fx( *voice_fac = exp; move16(); +#ifdef CLEANUP_ACELP_ENC + tilt_code = mac_r( 8192L /*0.25.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 8192 /*0.25.Q15*/ ); /*Q15 */ +#else IF( flag_tilt == 0 ) { /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */ @@ -180,6 +186,7 @@ Word16 est_tilt_ivas_fx( // tilt_code = (float)(0.28f + (*voice_fac + 1.0f) * 0.14f); tilt_code = mac_r( 13763L /*0.42.Q15*/ * 65536 /*1.Q16*/ - 0x8000 /*1.Q15*/, *voice_fac, 4588 /*0.14.Q15*/ ); /*Q15 */ } +#endif return tilt_code; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 90bba96d6..dc9c59896 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4851,8 +4851,11 @@ Word16 est_tilt_ivas_fx( const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr, /* i : Sub frame length */ - const Word16 flag_tilt /* i : flag for special tilt */ + const Word16 L_subfr /* i : Sub frame length */ +#ifndef CLEANUP_ACELP_ENC + , + const Word16 flag_tilt /* i : flag for special tilt */ +#endif ); /* o : tilt of the code */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f7640abe7..3a5bc119b 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -173,13 +173,14 @@ ivas_error decod_gen_voic_fx( pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } - // tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx); tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); /*--------------------------------------------------------------* * LP filtering of the adaptive excitation *--------------------------------------------------------------*/ + lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx ); + /*-----------------------------------------------------------------* * Transform-domain contribution decoding (active frames) *-----------------------------------------------------------------*/ @@ -215,12 +216,18 @@ ivas_error decod_gen_voic_fx( { gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); } + +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); // Q15 +#endif move16(); /*-----------------------------------------------------------------* * Transform domain contribution decoding *-----------------------------------------------------------------*/ + test(); IF( !st_fx->inactive_coder_type_flag && st_fx->coder_type == INACTIVE ) { @@ -368,7 +375,6 @@ ivas_error decod_gen_voic_fx( } /* FEC fast recovery */ - IF( do_WI_fx ) { /* shft_prev = L_EXC_MEM - rint_new_fx(st_fx->bfi_pitch_fx);*/ diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 645444e7d..fee0328ca 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -202,12 +202,15 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); +#endif move16(); } ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ { - /*inov_decode_fx(st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx);*/ inov_decode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, 0, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); /*--------------------------------------------------------------* @@ -217,7 +220,11 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); +#endif move16(); } ELSE @@ -250,6 +257,7 @@ void dec_pit_exc_fx( /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ + Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx, L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type ); diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index b00b445d7..294b67ff3 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -87,6 +87,7 @@ void decod_tran_fx( move16(); set16_fx( code_preQ_fx, 0, L_SUBFR ); // Q10 + /*----------------------------------------------------------------* * ACELP subframe loop *----------------------------------------------------------------*/ @@ -118,9 +119,11 @@ void decod_tran_fx( transition_dec_fx( st_fx, 0, L_frame_fx, i_subfr, tc_subfr_fx, &Jopt_flag, exc_fx, &T0, &T0_frac, &T0_min, &T0_max, &pt_pitch_fx, &position, bwe_exc_fx, &st_fx->Q_exc ); + /*-----------------------------------------------------------------* * Transform domain contribution decoding - active frames *-----------------------------------------------------------------*/ + IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { gain_code_fx = 0; @@ -176,13 +179,18 @@ void decod_tran_fx( { lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); +#endif move16(); } /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ + test(); test(); test(); @@ -219,6 +227,7 @@ void decod_tran_fx( /*-----------------------------------------------------------------* * Add the ACELP pre-quantizer contribution *-----------------------------------------------------------------*/ + IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { IF( ( st_fx->element_mode == EVS_MONO ) ) @@ -244,6 +253,7 @@ void decod_tran_fx( /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ + Word16 tmp_idx_2; tmp_idx_2 = 0; move16(); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index b5c10232c..f941af18c 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -5,6 +5,8 @@ #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ + + static void gain_dec_gacelp_uv_fx( Word16 index, /* i : Quantization index vector Q0 */ Word16 *code, /* i : algebraic code excitation Q9 */ @@ -90,19 +92,18 @@ void decod_unvoiced_fx( * Innovation decoding *--------------------------------------------------------------*/ - // inov_decode(st, st->core_brate, 0, L_FRAME, 1, i_subfr, p_Aq, st->tilt_code, *pt_pitch, code, L_SUBFR); inov_decode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_SUBFR ); /*-------------------------------------------------------* * Generate Gaussian excitation * *-------------------------------------------------------*/ - // gaus_L2_dec_flt(code2, st->tilt_code, p_Aq, FORMANT_SHARPENING_G1_FLT, &(st->seed_acelp)); gaus_L2_dec( code2_fx, st_fx->tilt_code_fx, p_Aq_fx, FORMANT_SHARPENING_G1, &( st_fx->seed_acelp ) ); /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ + Word16 tmp_idx_1; tmp_idx_1 = 0; move16(); @@ -115,7 +116,11 @@ void decod_unvoiced_fx( gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); +#else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); +#endif move16(); /* update LP filtered gains for the case of frame erasures */ diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 8c2893934..d7d3908a0 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -248,9 +248,6 @@ void decod_gen_2sbfr_fx( error = 0; move16(); - move16(); - move16(); - move16(); /*------------------------------------------------------------------* * ACELP subframe loop *------------------------------------------------------------------*/ @@ -276,6 +273,7 @@ void decod_gen_2sbfr_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ + IF( st->element_mode != EVS_MONO ) { pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -303,7 +301,12 @@ void decod_gen_2sbfr_fx( *--------------------------------------------------------------*/ gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); + +#ifdef CLEANUP_ACELP_ENC + st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ +#else st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */ +#endif move16(); /* update LP filtered gains for the case of frame erasures */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 977bc099b..62cefe5e6 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -436,7 +436,7 @@ static void encod_gen_voic_core_switch_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, - h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); + h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, core_bitrate, 0, L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, 0, -1, Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); @@ -671,8 +671,13 @@ static void encod_gen_voic_core_switch_ivas_fx( // hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift ); // Q_new or shift ?? ->Qexc +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */ +#endif move16(); + /*-----------------------------------------------------------------* * Construct adaptive part of the excitation *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 591c6e9bb..80c2e61d3 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -713,7 +713,11 @@ void encod_gen_voic_ivas_fx( Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ +#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 7cc932164..180d9d4d5 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -394,7 +394,7 @@ void enc_pit_exc_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, 0 ); + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); @@ -418,7 +418,7 @@ void enc_pit_exc_fx( { #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); @@ -429,7 +429,7 @@ void enc_pit_exc_fx( { #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); #else inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); @@ -458,7 +458,11 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ +#endif } ELSE #endif diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 639d34048..f0e9ff18e 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -598,7 +598,7 @@ Word16 encod_tran_ivas_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); + i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); @@ -644,7 +644,13 @@ Word16 encod_tran_ivas_fx( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); + +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + move16(); +#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 +#endif /*-----------------------------------------------------------------* * Update memory of the weighting filter diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 6773a8839..8c60c2a2c 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -352,7 +352,12 @@ void encod_gen_2sbfr( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ +#endif move16(); /*-----------------------------------------------------------------* -- GitLab From 1df39a6ba749fdede66c328c1de00b9b3e01829e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 17:12:46 +0100 Subject: [PATCH 04/14] harmonize est_tilt_ivas_fx(), under CLEANUP_ACELP_ENC --- lib_com/est_tilt_fx.c | 10 ++++++++-- lib_com/prot_fx.h | 10 ++++++++-- lib_dec/acelp_core_switch_dec_fx.c | 4 ++++ lib_dec/dec_amr_wb_fx.c | 5 +++++ lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/dec_pit_exc_fx.c | 4 ++-- lib_dec/dec_tran_fx.c | 17 ++++++++++------- lib_dec/dec_uv_fx.c | 2 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 +- lib_enc/acelp_core_switch_enc_fx.c | 4 ---- lib_enc/enc_pit_exc_fx.c | 9 +++++---- lib_enc/enc_tran_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- 13 files changed, 47 insertions(+), 26 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index bbcc22e69..71a82089a 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -33,6 +33,7 @@ /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ +#ifndef CLEANUP_ACELP_ENC Word16 est_tilt_fx( /* o : tilt of the code Q15 */ const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ @@ -111,19 +112,24 @@ Word16 est_tilt_fx( /* o : tilt of the code /* RETURN ARGUMENTS : */ /* _ (Word16) tolt_code : tilt of the code Q15 */ /*=======================================================================*/ +#endif /* o : tilt of the code Q15 */ +#ifdef CLEANUP_ACELP_ENC +Word16 est_tilt_fx( +#else Word16 est_tilt_ivas_fx( +#endif const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ const Word16 *code, /* i : algebraic excitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 L_subfr /* i : Sub frame length */ #ifndef CLEANUP_ACELP_ENC , - const Word16 flag_tilt /* i : flag for special tilt */ + const Word16 flag_tilt /* i : flag for special tilt */ #endif ) { diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index dc9c59896..0af0e093e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4840,9 +4840,15 @@ Word16 est_tilt_fx( const Word16 *code, /* i : algebraic exctitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ +#ifdef CLEANUP_ACELP_ENC + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ +#else + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ +#endif ); +#ifndef CLEANUP_ACELP_ENC /* o : tilt of the code Q15 */ Word16 est_tilt_ivas_fx( const Word16 *exc, /* i : adaptive excitation vector Qx */ @@ -4857,7 +4863,7 @@ Word16 est_tilt_ivas_fx( const Word16 flag_tilt /* i : flag for special tilt */ #endif ); - +#endif /* o : tilt of the code */ Word16 Est_tilt2( const Word16 *exc, /* i : adaptive excitation vector Qx */ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 2df489cc1..9a4c5536e 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -940,7 +940,11 @@ static void decod_gen_voic_core_switch_fx( /* _ (Word32*) gain_code : quantized codebook gain (Q16) */ /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */ /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */ +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/ +#else st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc ); /*Q15*/ +#endif move16(); /*----------------------------------------------------------------------* diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index c65162afc..2fad171fd 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -84,6 +84,7 @@ void decod_amr_wb_fx( *--------------------------------------------------------------*/ lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr, L_SUBFR, L_FRAME, lp_flag, exc_fx ); + /*--------------------------------------------------------------* * Innovation decoding *--------------------------------------------------------------*/ @@ -100,7 +101,11 @@ void decod_amr_wb_fx( /* update LP filtered gains for the case of frame erasures */ lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); +#else st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); +#endif move16(); Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_SUBFR, 0, diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 3a5bc119b..d1e4a564d 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -218,7 +218,7 @@ ivas_error decod_gen_voic_fx( } #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); // Q15 #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); // Q15 #endif diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index fee0328ca..067db4fcd 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -203,7 +203,7 @@ void dec_pit_exc_fx( gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); #endif @@ -221,7 +221,7 @@ void dec_pit_exc_fx( gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx ); #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); #endif diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 294b67ff3..d9dfd9505 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -119,7 +119,7 @@ void decod_tran_fx( transition_dec_fx( st_fx, 0, L_frame_fx, i_subfr, tc_subfr_fx, &Jopt_flag, exc_fx, &T0, &T0_frac, &T0_min, &T0_max, &pt_pitch_fx, &position, bwe_exc_fx, &st_fx->Q_exc ); - + /*-----------------------------------------------------------------* * Transform domain contribution decoding - active frames *-----------------------------------------------------------------*/ @@ -171,22 +171,25 @@ void decod_tran_fx( IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); - +#ifndef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); move16(); +#endif } ELSE { lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); - -#ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); -#else +#ifndef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); -#endif move16(); +#endif } +#ifdef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); + move16(); +#endif + /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index f941af18c..a0dd73994 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -117,7 +117,7 @@ void decod_unvoiced_fx( gain_dec_gacelp_uv_fx( index, code_fx, code2_fx, Es_pred_fx, L_SUBFR, &gain_pit_fx, &gain_code_fx, &gain_code2_fx, &( st_fx->past_gpit ), &norm_gain_code_fx, &gain_inov_fx ); #ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); #else st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); #endif diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index d7d3908a0..377160d06 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -303,7 +303,7 @@ void decod_gen_2sbfr_fx( gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); #ifdef CLEANUP_ACELP_ENC - st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ + st->tilt_code_fx = est_tilt_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR ); /* Q15 */ #else st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */ #endif diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 62cefe5e6..5e9dc4cd8 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -671,11 +671,7 @@ static void encod_gen_voic_core_switch_ivas_fx( // hLPDmem->tilt_code = Est_tilt2( exc + 0, gain_pit, code, gain_code, &voice_fac, shift ); // Q_new or shift ?? ->Qexc -#ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); /* Q15 */ -#else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + 0, gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); /* Q15 */ -#endif move16(); /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 180d9d4d5..7dd7d0e4b 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -453,22 +453,23 @@ void enc_pit_exc_fx( Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_sat( Lgcode ); + IF( use_fcb != 0 ) { +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ +#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ -#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ -#endif } ELSE #endif { hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ } +#endif move16(); } ELSE diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index f0e9ff18e..9a371b5a0 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -646,7 +646,7 @@ Word16 encod_tran_ivas_fx( gcode16 = round_fx_sat( Lgcode ); #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 move16(); #else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 8c60c2a2c..98a526b06 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -354,7 +354,7 @@ void encod_gen_2sbfr( gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ + hLPDmem->tilt_code = est_tilt_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ #else hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */ #endif -- GitLab From 63c48a8376c2f03a05eb3a5b34d1f65729f27012 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 17:30:45 +0100 Subject: [PATCH 05/14] clang-format --- lib_com/prot_fx.h | 4 +- lib_dec/dec_gen_voic_fx.c | 2 +- lib_enc/enc_amr_wb_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_uv_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 6 +- lib_enc/prot_fx_enc.h | 2430 ++++++++++++++--------------- 7 files changed, 1224 insertions(+), 1224 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0af0e093e..0396634e9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -4841,8 +4841,8 @@ Word16 est_tilt_fx( const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ #ifdef CLEANUP_ACELP_ENC - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #else const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ #endif diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index d1e4a564d..d92e66a94 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -180,7 +180,7 @@ ivas_error decod_gen_voic_fx( *--------------------------------------------------------------*/ lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx ); - + /*-----------------------------------------------------------------* * Transform-domain contribution decoding (active frames) *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index d3f0636ae..022483f82 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -176,7 +176,7 @@ void encod_amr_wb_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, - exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); + exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift, 0 ); #else inov_encode_fx( st, st->core_brate, 1, L_FRAME, st->last_L_frame, -1, -1, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits, L_SUBFR, shift ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 80c2e61d3..b7ceb81bc 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -672,7 +672,7 @@ void encod_gen_voic_ivas_fx( #ifdef CLEANUP_ACELP_ENC inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 86215f5b8..2b0bd02ba 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -374,7 +374,7 @@ void encod_unvoiced_ivas_fx( *----------------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 98a526b06..5290ecd22 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -332,7 +332,7 @@ void encod_gen_2sbfr( * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); + gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); IF( st->Opt_SC_VBR ) { @@ -350,8 +350,8 @@ void encod_gen_2sbfr( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #ifdef CLEANUP_ACELP_ENC hLPDmem->tilt_code = est_tilt_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR ); /* Q15 */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index f33abae3f..2792fbdcf 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3566,1236 +3566,1236 @@ Word16 inov_encode_fx( const Word16 shift, const Word16 Q_new ); - void gain_enc_mless_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 scaling */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ - ); - - void updt_IO_switch_enc_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 input_frame /* i : i frame length */ - ); - - void hf_cod_init_fx( - Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ - Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ - Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ - Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ - Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ - ); - - void analy_lp_AMR_WB_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 isp_new[], /* o : current frame ISPs Q15*/ - Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ - Word16 isf_new[], /* o : current frame ISPs Q15*/ - Word16 Top, /* i : open loop pitch lag Q0*/ - Word16 Tnc, /* i : open loop pitch gain Qx*/ - const Word16 Q_new, - Word16 *Q_r ); - - void encod_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - const Word16 speech[], /* i : i speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *syn, /* i/o: core synthesis st->Q_syn*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ - Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ - const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ - const Word16 shift, - const Word16 Q_new ); - - void re8_cod_fx( - Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ - UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ - Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ - ); - - void TBEreset_enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 last_core, /* i : last core */ - Word16 bandwidth /* i : bandwidth mode */ - ); - - void acelp_core_switch_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - const Word16 shift, - const Word16 Q_new ); +void gain_enc_mless_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 scaling */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ +); + +void updt_IO_switch_enc_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 input_frame /* i : i frame length */ +); + +void hf_cod_init_fx( + Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */ + Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */ + Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */ + Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */ + Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */ +); + +void analy_lp_AMR_WB_fx( + const Word16 speech[], /* i : pointer to the speech frame Q_new*/ + Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ + Word16 A[], /* o : A(z) filter coefficients Q14*/ + Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ + Word16 isp_new[], /* o : current frame ISPs Q15*/ + Word16 isp_old[], /* i/o: previous frame unquantized ISPs Q15*/ + Word16 isf_new[], /* o : current frame ISPs Q15*/ + Word16 Top, /* i : open loop pitch lag Q0*/ + Word16 Tnc, /* i : open loop pitch gain Qx*/ + const Word16 Q_new, + Word16 *Q_r ); + +void encod_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + const Word16 speech[], /* i : i speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *syn, /* i/o: core synthesis st->Q_syn*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *exc2, /* i/o: current enhanced excitation Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6*/ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain Q0*/ + const Word16 *speech16k_fx, /* i : i speech @16kHz Qx*/ + const Word16 shift, + const Word16 Q_new ); + +void re8_cod_fx( + Word16 x[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) Q0*/ + UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) Q0*/ + Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index Q0*/ +); + +void TBEreset_enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 last_core, /* i : last core */ + Word16 bandwidth /* i : bandwidth mode */ +); + +void acelp_core_switch_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + const Word16 shift, + const Word16 Q_new ); #ifndef CLEANUP_ACELP_ENC - void acelp_core_switch_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ - const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ - const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ - Word16 shift, - Word16 Q_new ); +void acelp_core_switch_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Q0 */ + const Word16 inp16k[], /* i : i signal @16 kHz Q0 */ + const Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12 */ + Word16 shift, + Word16 Q_new ); #endif - void gain_enc_amr_wb_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 Q_xn, /* i : xn and yy1 format */ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ - ); - - void hf_cod_fx( - const Word32 core_brate_fx, /* i : core bitrate */ - const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ - const Word16 Aq_fx[], /* i : quantized Aq */ - const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ - Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ - Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ - Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ - Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ - Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ - Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ - const Word16 dtxHangoverCount_fx, - Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ - Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ - Word16 Q_exc, - Word16 Q_syn ); - - void transf_cdbk_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ - ); +void gain_enc_amr_wb_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 Q_xn, /* i : xn and yy1 format */ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ +); + +void hf_cod_fx( + const Word32 core_brate_fx, /* i : core bitrate */ + const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ + const Word16 Aq_fx[], /* i : quantized Aq */ + const Word16 exc_fx[], /* i : excitation at 12.8 kHz */ + Word16 synth_fx[], /* i : 12.8kHz synthesis signal */ + Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */ + Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */ + Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */ + Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */ + Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */ + const Word16 dtxHangoverCount_fx, + Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */ + Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */ + Word16 Q_exc, + Word16 Q_syn ); + +void transf_cdbk_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ +); #ifndef CLEANUP_ACELP_ENC - void transf_cdbk_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - Word16 cn[], /* i/o: target vector in residual domain Q_new*/ - Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ - const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ - const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ - const Word16 h1[], /* i : weighted filter input response Q15*/ - Word16 xn[], /* i/o: target vector Q_new + shift -1*/ - Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ - Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ - const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ - const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ - Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ - const Word32 gain_code, /* i : innovative excitation gain Q16*/ - Word16 g_corr[], /* o : ACELP correlation values Q15*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ - Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ - Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ - Word16 *unbits, /* o : number of AVQ unused bits Q0*/ - const Word16 Q_new, /* i : Current frame scaling */ - const Word16 shift /* i : shifting applied to y1, xn,... */ - ); +void transf_cdbk_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + Word16 cn[], /* i/o: target vector in residual domain Q_new*/ + Word16 exc[], /* i/o: pointer to excitation signal frame Q_new*/ + const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/ + const Word16 Ap[], /* i : weighted LP filter coefficients Q12*/ + const Word16 h1[], /* i : weighted filter input response Q15*/ + Word16 xn[], /* i/o: target vector Q_new + shift -1*/ + Word16 xn2[], /* i/o: target vector for innovation search Q_new + shift -1*/ + Word16 y1[], /* i/o: zero-memory filtered adaptive excitation Q_new + shift -1*/ + const Word16 y2[], /* i : zero-memory filtered innovative excitation Q9*/ + const Word16 Es_pred, /* i : predicited scaled innovation energy Q8*/ + Word16 *gain_pit, /* i/o: adaptive excitation gain Q14*/ + const Word32 gain_code, /* i : innovative excitation gain Q16*/ + Word16 g_corr[], /* o : ACELP correlation values Q15*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0*/ + Word16 *gain_preQ, /* o : prequantizer excitation gain Q2*/ + Word16 code_preQ[], /* o : prequantizer excitation Q_AVQ_OUT_DEC*/ + Word16 *unbits, /* o : number of AVQ unused bits Q0*/ + const Word16 Q_new, /* i : Current frame scaling */ + const Word16 shift /* i : shifting applied to y1, xn,... */ +); #endif - void gain_enc_lbr_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 Q_xn, /* i : xn and y1 format */ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr, /* i : subframe length Q0*/ - const Word16 element_mode /* i : mode element Q0*/ - ); - - void gain_enc_SQ_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *xn, /* i : target vector Q_xn*/ - const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ - const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ - const Word16 *code, /* i : algebraic excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit, /* o : quantized pitch gain Q14*/ - Word32 *gain_code, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ - Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ - const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 Q_xn /* i : xn and y1 scaling */ - ); - - void updt_tar_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 L /* i : subframe size */ - ); - - void updt_tar_HR_fx( - const Word16 *x, /* i : old target (for pitch search) */ - Word16 *x2, /* o : new target (for codebook search) */ - const Word16 *y, /* i : filtered adaptive codebook vector */ - const Word16 gain, /* i : adaptive codebook gain */ - const Word16 Qx, /* i : Scaling factor to adapt output to i */ - const Word16 L /* i : subframe size */ - ); - - Flag conv_fx( - const Word16 x[], /* i : i vector Q_new*/ - const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ - Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ - const Word16 L /* i : vector size */ - ); - - ivas_error ppp_voiced_encoder_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - SC_VBR_ENC_HANDLE hSC_VBR, - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 last_coder_type_raw, /* i : raw last_coder_type */ - const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ - Word16 *in_fx, /* i : residual signal */ - Word16 *out_fx, /* o : Quantized residual signal */ - Word16 delay_fx, /* i : open loop pitch */ - Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ - Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ - Word16 *exc_fx, /* i: previous frame quantized excitation */ - Word16 *pitch_fx, /* o: floating pitch values for each subframe */ - Word16 Qres ); - - void signalling_enc_fx( - Encoder_State *st_fx /* i : encoder state structure */ - ); - - void transition_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ - ); +void gain_enc_lbr_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 Q_xn, /* i : xn and y1 format */ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ +); + +void gain_enc_SQ_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *xn, /* i : target vector Q_xn*/ + const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn*/ + const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/ + const Word16 *code, /* i : algebraic excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit, /* o : quantized pitch gain Q14*/ + Word32 *gain_code, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/ + Word16 *g_corr, /* i/o: correlations , ,, -2 and 2 Qx*/ + const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ + const Word16 Q_xn /* i : xn and y1 scaling */ +); + +void updt_tar_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 L /* i : subframe size */ +); + +void updt_tar_HR_fx( + const Word16 *x, /* i : old target (for pitch search) */ + Word16 *x2, /* o : new target (for codebook search) */ + const Word16 *y, /* i : filtered adaptive codebook vector */ + const Word16 gain, /* i : adaptive codebook gain */ + const Word16 Qx, /* i : Scaling factor to adapt output to i */ + const Word16 L /* i : subframe size */ +); + +Flag conv_fx( + const Word16 x[], /* i : i vector Q_new*/ + const Word16 h[], /* i : impulse response (or second i vector) Q(15)*/ + Word16 y[], /* o : output vetor (result of convolution) 12 bits*/ + const Word16 L /* i : vector size */ +); + +ivas_error ppp_voiced_encoder_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + SC_VBR_ENC_HANDLE hSC_VBR, + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 last_coder_type_raw, /* i : raw last_coder_type */ + const Word16 old_pitch_buf[], /* i : buffer of old subframe pitch values */ + Word16 *in_fx, /* i : residual signal */ + Word16 *out_fx, /* o : Quantized residual signal */ + Word16 delay_fx, /* i : open loop pitch */ + Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */ + Word16 *lpc2_fx, /* i : current frame de-emphasized LPC */ + Word16 *exc_fx, /* i: previous frame quantized excitation */ + Word16 *pitch_fx, /* o: floating pitch values for each subframe */ + Word16 Qres ); + +void signalling_enc_fx( + Encoder_State *st_fx /* i : encoder state structure */ +); + +void transition_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter i response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ +); #ifndef CLEANUP_ACELP_ENC - void transition_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *tc_subfr, /* i/o: TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *position, /* i/o: maximum of residual signal index */ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ - Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ - Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ - const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ - const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ - Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ - Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ - Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ - Word16 *g_corr_fx, /* o : ACELP correlation values */ - Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ - Word16 **pt_pitch_fx, /* o : floating pitch values */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - Word16 *unbits_ACELP, /* i/o: unused bits */ - Word16 Q_new, /* i : Current scaling */ - Word16 shift /* i : downscaling needs for 12 bits convolutions */ - ); +void transition_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *tc_subfr, /* i/o: TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *position, /* i/o: maximum of residual signal index */ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/ + Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/ + Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/ + const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/ + const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/ + Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/ + Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */ + Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/ + Word16 *g_corr_fx, /* o : ACELP correlation values */ + Word16 *clip_gain, /* i/o: adaptive gain clipping flag */ + Word16 **pt_pitch_fx, /* o : floating pitch values */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + Word16 *unbits_ACELP, /* i/o: unused bits */ + Word16 Q_new, /* i : Current scaling */ + Word16 shift /* i : downscaling needs for 12 bits convolutions */ +); #endif - void gain_enc_tc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - const Word16 Q_xn /* i : xn and y1 scaling */ - ); - - void gain_enc_tc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 gains_mode[], /* i : gain bits Q0*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 xn_fx[], /* i : target vector Q_xn*/ - const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ - Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : innovation gain Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ - const Word16 Q_xn /* i : xn and y1 scaling */ - ); - - Word16 gaus_encode_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ - ); - - Word16 gaus_encode_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 *h1, /* i : weighted filter input response Q14*/ - const Word16 *xn, /* i : target vector Q12*/ - Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ - Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ - Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ - Word16 *code, /* o : algebraic excitation Q9*/ - Word32 *gain_code, /* o : Code gain. Q16*/ - Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ - Word16 *gain_inov, /* o : innovation gain Q12*/ - Word16 *voice_fac, /* o : voicing factor Q15*/ - Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ - const Word16 Q_new, /* i : scaling factor */ - const Word16 shift, /* i : scaling factor */ - Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ - ); - - void pre_proc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_frame, /* i : frame length */ - Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ - Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ - Word16 **inp, /* o : ptr. to inp. signal in the current frame */ - Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ - Word16 *Etot, /* o : total energy */ - Word32 *ener, /* o : residual energy from Levinson-Durbin */ +void gain_enc_tc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + const Word16 Q_xn /* i : xn and y1 scaling */ +); + +void gain_enc_tc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 gains_mode[], /* i : gain bits Q0*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 xn_fx[], /* i : target vector Q_xn*/ + const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation Q_xn*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 Es_pred_fx, /* i : predicted scaled innovation energy Q8*/ + Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : innovation gain Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q6*/ + const Word16 Q_xn /* i : xn and y1 scaling */ +); + +Word16 gaus_encode_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ +); + +Word16 gaus_encode_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 *h1, /* i : weighted filter input response Q14*/ + const Word16 *xn, /* i : target vector Q12*/ + Word16 *exc, /* o : pointer to excitation signal frame Q_new*/ + Word16 *mem_w0, /* o : weighting filter denominator memory Q_new*/ + Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15*/ + Word16 *code, /* o : algebraic excitation Q9*/ + Word32 *gain_code, /* o : Code gain. Q16*/ + Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9*/ + Word16 *gain_inov, /* o : innovation gain Q12*/ + Word16 *voice_fac, /* o : voicing factor Q15*/ + Word16 *gain_pit, /* o : adaptive excitation gain Q14*/ + const Word16 Q_new, /* i : scaling factor */ + const Word16 shift, /* i : scaling factor */ + Word32 *norm_gain_code /* o : normalized innovative cb. gain Q16*/ +); + +void pre_proc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_frame, /* i : frame length */ + Word16 old_inp_12k8[], /* i/o: buffer of old i signal */ + Word16 old_inp_16k[], /* i/o: buffer of old i signal @ 16kHz */ + Word16 **inp, /* o : ptr. to inp. signal in the current frame */ + Word32 fr_bands[2 * NB_BANDS], /* o : energy in frequency bands */ + Word16 *Etot, /* o : total energy */ + Word32 *ener, /* o : residual energy from Levinson-Durbin */ #ifndef FIX_I4_OL_PITCH - Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ + Word16 pitch_orig[3], /* o : open-loop pitch values for quantization */ #endif - Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - Word16 epsP_h[M + 1], /* o : LP prediction errors */ - Word16 epsP_l[M + 1], /* o : LP prediction errors */ - Word32 epsP[M + 1], /* o : LP prediction errors */ - Word16 lsp_new[M], /* o : LSPs at the end of the frame */ - Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ - Word16 *vad_hover_flag, - Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ - Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ - CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ - Word16 *old_exc, /* i/o: static excitation memory */ - Word16 *hq_core_type, /* o : HQ core type */ - Word16 *Q_new, - Word16 *shift, - Word16 *Q_r ); - - void swb_bwe_enc_hr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *new_input_fx, /* i : i signal */ - Word16 new_input_fx_exp, /* i : Exponent of i signal */ - const Word16 input_frame, /* i : frame length */ - const Word16 unbits /* i : number of core unused bits */ - ); - - /* o : Return index of quantization */ - Word16 gain_enc_gaus_fx( - Word32 *gain, /* i/o: Code gain to quantize Q16*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ - ); - - void enc_pit_exc_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *speech, /* i : Input speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - const Word16 Q_new, - const Word16 shift ); + Word16 A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ + Word16 epsP_h[M + 1], /* o : LP prediction errors */ + Word16 epsP_l[M + 1], /* o : LP prediction errors */ + Word32 epsP[M + 1], /* o : LP prediction errors */ + Word16 lsp_new[M], /* o : LSPs at the end of the frame */ + Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */ + Word16 *vad_hover_flag, + Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */ + Word16 *new_inp_resamp16k, /* o : new i signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */ + CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */ + Word16 *old_exc, /* i/o: static excitation memory */ + Word16 *hq_core_type, /* o : HQ core type */ + Word16 *Q_new, + Word16 *shift, + Word16 *Q_r ); + +void swb_bwe_enc_hr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *new_input_fx, /* i : i signal */ + Word16 new_input_fx_exp, /* i : Exponent of i signal */ + const Word16 input_frame, /* i : frame length */ + const Word16 unbits /* i : number of core unused bits */ +); + +/* o : Return index of quantization */ +Word16 gain_enc_gaus_fx( + Word32 *gain, /* i/o: Code gain to quantize Q16*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ +); + +void enc_pit_exc_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + const Word16 Q_new, + const Word16 shift ); #ifndef FIX_1904_HARM_GSC_ENC - void enc_pit_exc_ivas_fx( - Encoder_State *st_fx, /* i/o: State structure */ - const Word16 *speech, /* i : Input speech Q_new-1*/ - const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *T0, /* i/o: close loop integer pitch Q0*/ - Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ - Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *gpit, /* o : pitch mean gpit Q15*/ - Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 Q_new, - Word16 shift ); +void enc_pit_exc_ivas_fx( + Encoder_State *st_fx, /* i/o: State structure */ + const Word16 *speech, /* i : Input speech Q_new-1*/ + const Word16 Aw[], /* i : weighted A(z) unquantized for subframes Q12*/ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *T0, /* i/o: close loop integer pitch Q0*/ + Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part Q0*/ + Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *gpit, /* o : pitch mean gpit Q15*/ + Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + Word16 Q_new, + Word16 shift ); #endif - /* o : bin where pitch contribution is significant */ - Word16 Pit_exc_contribution_len_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); +/* o : bin where pitch contribution is significant */ +Word16 Pit_exc_contribution_len_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); #ifndef FIX_1904_HARM_GSC_ENC - /* o : bin where pitch contribution is significant */ - Word16 Pit_exc_contribution_len_ivas_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); +/* o : bin where pitch contribution is significant */ +Word16 Pit_exc_contribution_len_ivas_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); #endif - Word16 pvq_core_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ - ); - - Word16 pvq_core_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ - ); - void core_switching_hq_prepare_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ - const Word16 *audio /*q_audio*/ ); - - void hq_lr_enc_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ - ); - - void hq_lr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: : encoder state structure */ - Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ - const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ - Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ - const Word16 is_transient_fx /* i : Q0 : transient flag */ - ); - - void hq_hr_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ - ); - - void hq_hr_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure fx */ - Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ - const Word16 length, /* i : length of spectrum Q0 */ - Word16 *num_bits, /* i : number of available bits Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ - ); - - void reordernorm_fx( - const Word16 *ynrm, /* i : quantization indices for norms Q0 */ - const Word16 *normqlg2, /* i : quantized norms Q0 */ - Word16 *idxbuf, /* o : reordered quantization indices Q0 */ - Word16 *normbuf, /* o : reordered quantized norms Q0 */ - const Word16 nb_sfm /* i : number of bands Q0 */ - ); - - void diffcod_fx( - const Word16 N, /* (i) number of sub-vectors Q0*/ - Word16 *y, /* (i/o) indices of quantized norms Q0*/ - Word16 *difidx /* (o) differential code Q0*/ - ); - - /* o : Consumed bits Q0 */ - Word16 hq_classifier_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ - ); - - /* o : Consumed bits Q0 */ - Word16 hq_classifier_enc_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ - ); - - void diff_envelope_coding_fx( - const Word16 is_transient, /* i : transient indicator Q0 */ - const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ - const Word16 start_norm, /* i : start of envelope coding Q0 */ - Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ - Word16 *normqlg2, /* i/o: quantized norms Q0 */ - Word16 *difidx /* o : differential code Q0 */ - ); - - /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ - Word16 encode_envelope_indices_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ - ); - - void hq_generic_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas /* o : bwe excitation class */ - ); - - void normalizecoefs_fx( - Word32 *coefs, /* i : Input vector (Q12) */ - const Word16 *ynrm, /* i : quantization indices for norms */ - const Word16 num_bands, /* i : Number of bands */ - const Word16 *band_start, /* i : Start of bands */ - const Word16 *band_end, /* i : End of bands */ - Word16 *coefs_norm /* o : Normalized output vector (Q12) */ - ); - - /* o : Consumed bits */ - Word16 hvq_enc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 brate, /* i : Total bit rate */ - const Word16 hvq_bits, /* i : HVQ bit budget */ - const Word16 Npeaks, /* i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - Word16 *noise_level, /* o : Quantized noise level */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q14 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ - ); - - /* o : Consumed bits */ - Word16 hvq_enc_ivas_fx( - Encoder_State *st_fx, /*i/o: encoder state structure */ - const Word32 core_brate, /*i : Total bit rate */ - const Word16 hvq_bits, /*i : HVQ bit budget */ - const Word16 Npeaks, /*i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ - Word16 *noise_level, /* o : Quantized noise level Q15 */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q12 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ - ); - - Word16 pvq_core_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ - Word16 coefs_quant[], /* o : quantized coefficients */ - Word16 *Q_coefs, - const Word16 bits_tot, /* i : total number of bits */ - const Word16 nb_sfm, /* i : number of bands */ - const Word16 *sfm_start, /* i : Subband start coefficient */ - const Word16 *sfm_end, /* i : Subband end coefficient */ - const Word16 *sfmsize, /* i : subband width */ - Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *Rs, /* i/o: Integer bit allocation */ - Word16 *npulses, /* o : number of pulses */ - Word16 *maxpulse, /* i : maximum pulse per band */ - const Word16 core /* i : number of bands */ - ); - - /* o : index of noise attenuation Q0 */ - Word16 noise_adjust_fx( - const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ - const Word16 qx, /* i : Q value of coeffs_norm */ - const Word16 *bitalloc, /* i : bit allocation Q0 */ - const Word16 *sfm_start, /* i : band start Q0 */ - const Word16 *sfm_end, /* i : band end Q0 */ - const Word16 core_sfm /* i : index of the end band for core Q0 */ - ); - - ivas_error tcq_core_LR_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 inp_vector_fx[], /* x5 */ - const Word32 coefs_norm_fx[], /* Q12 */ - Word32 coefs_quant_fx[], /* Q12 */ - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *R_fx, /* Q16 */ - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - - ivas_error tcq_core_LR_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word32 inp_vector[], - const Word32 coefs_norm_fx[], - Word32 coefs_quant_fx[], - const Word16 bit_budget, /* number of bits */ - const Word16 BANDS, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word32 *Rk_fx, - Word16 *npulses, - Word16 *k_sort, - const Word16 *p2a_flags, - const Word16 p2a_bands, - const Word16 *last_bitalloc, - const Word16 input_frame, - const Word16 adjustFlag, - const Word16 is_transient ); - - /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ - Word16 encode_envelope_indices_fx( - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ - ); - - void diffcod_lrmdct_fx( - const Word16 N, /* i : number of sub-vectors Q0*/ - const Word16 be_ref, /* i : band energy reference Q0*/ - Word16 *y, /* i/o: indices of quantized norms Q0*/ - Word16 *difidx, /* o : differential code Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ - ); - - Word16 peak_vq_enc_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 core_brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ - ); - - Word16 peak_vq_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 *coefs, /* i : Input coefficient vector Q12 */ - Word32 *coefs_out, /* o : Quantized output vector Q12 */ - const Word32 brate, /* i : Core bitrate */ - const Word16 num_bits, /* i : Number of bits for HVQ */ - const Word16 vq_peaks, /* i : Number of identified peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *vq_peak_idx, /* i : Peak index vector */ - Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ - ); - - void wb_vad_init_fx( - VAD_HANDLE hVAD /* i/o: VAD data handle */ - ); - - void noise_est_init_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ - ); - - void noise_est_init_ivas_fx( - NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ - ); - - void InitSWBencBuffer_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ - ); - - void InitSWBencBuffer_ivas_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ - ); - - void ResetSHBbuffer_Enc_fx( - TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ - ); - - Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); - - Word16 E_ACELP_hh_corr( - Word16 *x /*Q11*/, - Word16 *y /*Qy*/, - Word16 L_subfr /*Q0*/, - Word16 bits /*Q0*/ - ); - - void acelp_1t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[], /* o : filtered fixed codebook excitation */ - const Word16 L_subfr /* i : subframe length */ - ); - - void acelp_2t32_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 h[], /* i : impulse response of weighted synthesis filter */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - Word16 y[] /* o : filtered fixed codebook excitation */ - ); - - Word16 acelp_4t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 dn[], /* i : corr. between target and h[]. */ - const Word16 cn[], /* i : residual after long term prediction Q_new*/ - const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ - Word16 R[], /* i : autocorrelation values */ - const Word16 acelpautoc, /* i : autocorrealtion flag */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - Word16 y[], /* o : filtered fixed codebook excitation Q9*/ - Word16 nbbits, /* i : number of bits per codebook */ - const Word16 cmpl_flag, /* i : coomplexity reduction flag */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 element_mode ); - - ivas_error evs_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *data, /* i : input signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of input samples Q0*/ - ); - - /* o: Qx y(n) */ - /* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ - Word16 noise_est_AR1_Qx( - Word16 x, /* i : Qx x(n) */ - Word16 y, /* i : Qx y(n-1) */ - Word16 alpha /* i : Q15 scaling of driving x(n) */ - ); - - /*o : Qx y( n ) */ - Word32 noise_est_AR1_Qx_32( - Word32 x, /* i : Qx x(n) */ - Word32 y, /* i : Qx y(n-1) */ - Word32 alpha /* i : Q15 scaling of driving x(n) */ - ); - - void FEC_lsf_estim_enc_fx( - Encoder_State *st_fx, /* i : Encoder static memory */ - Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ - ); - - Word32 mslvq_cng_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w, /* i : weights for LSF quantization Q10*/ - Word16 *no_scales ); - - Word32 mslvq_cng_ivas_fx( - Word16 idx_cv, /* i : index of cv from previous stage */ - Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ - Word16 *quant, /* o : quantized vector x2.56*/ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - const Word16 *w /* i : weights for LSF quantization Q10*/ - ); - - void Unified_weighting_fx( - const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ - Word16 Q_ener, - const Word16 lsf_fx[], /* i : LSF vector x2.56 */ - Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ - const Word16 narrowBand, /* i : flag for Narrowband Q0*/ - const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ - const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ - const Word16 order /* i : LP order Q0*/ - ); - - Word32 qlsf_ARSN_tcvq_Enc_16k_fx( - const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ - Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ - Word16 *indice, /* o : Indices */ - const Word16 *w_fx, /* i : LSF Weights Q10 */ - const Word16 nBits, /* i : number of bits */ - Word16 safety_net /* i : safety_net flag */ - ); - - Word32 mslvq_fx( - Word16 *pTmp, /* i : M-dimensional i vector */ - Word16 *quant, /* o : quantized vector */ - Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ - Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ - Word16 *idx_scale, /* o : scale index for each subvector */ - Word16 *w, /* i : weights for LSF quantization */ - Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ - Word16 mode_glb, /* i : LVQ coding mode */ - Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ - Word16 no_scales[][2] ); - - /* o : frame multi-harmonicity (1-harmonic, 0-not) */ - Word16 multi_harm_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ - ); - - /* o : frame multi-harmonicity (1-harmonic, 0-not) */ - Word16 multi_harm_ivas_fx( - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ - ); - - void pvq_encode_frame_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ - ); - - void pvq_encode_frame_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *coefs_norm, /* i : normalized coefficients to encode */ - Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *gopt, /* o : optimal shape gains */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band Q3 */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ - ); - - /*Qx o : interpolated value */ - Word16 Interpol_4( - Word16 *x, /*Qx i : i vector */ - Word16 frac /* i : fraction (-4..+3) */ - ); - - void set_ppp_mode_fx( - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ - const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ - const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ - const Word16 localVAD_he /* i : HE-SAD flag without hangover */ - ); - - void decision_matrix_enc_fx( - Encoder_State *st_fx, /* i : encoder state structure */ - Word16 *hq_core_type /* o : HQ core_fx type Q0*/ - ); - - void pvq_encode_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ - ); - - void pvq_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ - Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ - Word16 *xq, /* o : quantized vector Q15 */ - Word32 *L_xq, /* o : quantized vector Q31 */ - const Word16 pulses, /* i : number of allocated pulses */ - const Word16 dim, /* i : Length of vector */ - const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ - ); - - void rc_enc_init_fx( - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - Word16 tot_bits /* i : Total bit budget Q0*/ - ); - - void rc_enc_finish_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ - ); - - void rc_enc_finish_ivas_fx( - BSTR_ENC_HANDLE hBstr, - PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ - - ); - - void rc_encode_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ - ); - - void rc_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ - UWord32 sym_freq, /* i : Symbol probability Q0*/ - UWord32 tot /* i : Total cumulative frequency Q0*/ - ); - - void rc_enc_uniform_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ - ); - - void rc_enc_uniform_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - UWord32 tot /* i : Maximum value Q0*/ - ); - - void rc_enc_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ - ); - - void rc_enc_bits_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ - UWord32 value, /* i : Value to encode Q0*/ - Word16 bits /* i : Number of bits used Q0*/ - ); - - void re8_compute_base_index_fx( - const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ - const Word16 ka, /* i : Identifier of the absolute leader related to x */ - UWord16 *I /* o : index */ - ); - - void tfaCalcEnv_fx( - const Word16 *shb_speech, - Word32 *enr ); - - /* o : pitch index */ - Word16 delta_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac, /* i : pitch fraction */ - const Word16 T0_min /* i : delta search min */ - ); - - void set_impulse_fx( - const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ - const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ - Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ - Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ - Word16 *imp_shape, /* o : adaptive codebook index Q0*/ - Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ - Word32 *gain_trans_fx, /* o : transition gain Q7*/ - Word16 Q_new /* i : Current scaling */ - ); - - /* o : pitch index */ - Word16 abs_pit_enc_fx( - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac /* i : pitch fraction */ - ); - - ivas_error ppp_quarter_encoder_fx( - Word16 *returnFlag, /* o : return value */ - DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ - DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ - Word16 prevCW_lag, /* i : previous lag */ - DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ - const Word16 *curr_lpc_fx, /* i : LPCS */ - Word16 *lastLgainE_fx, /* i/o: last low band gain */ - Word16 *lastHgainE_fx, /* i/o: last high band gain */ - Word16 *lasterbE_fx, /* i/o: last ERB vector */ - DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ - Word16 *S_fx, /* i : sin table, Q15 */ - Word16 *C_fx, /* i : cos table, Q15 */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ - ); - - void index_lvq_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - - void index_lvq_ivas_fx( - Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ - Word16 *idx_lead, /* i : leader class index for each subvector */ - Word16 *idx_scale, /* i : scale index for each subvector */ - Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ - Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ - const Word16 prediction_flag ); - - void copy_encoder_config_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ - ); - - void amr_wb_enc_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 input_sp[], /* i : i signal Q0*/ - Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ - const Word16 n_samples /* i : number of i samples Q0*/ - ); - - void writeLPCparam_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ - ); - - Word16 cng_energy_ivas_fx( - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidh */ - const Word16 CNG_mode, /* i : mode for DTX configuration */ - const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ - const Word16 *exc, /* i : input signal */ - const Word16 len, /* i : vector length */ - const Word16 Q_new /* i : Input scaling */ - ); - - void generate_comfort_noise_enc_ivas_fx( - Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ); - - void SynthesisSTFT_enc_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - ivas_error write_indices_ivas_fx( - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - UWord16 *bit_stream, /* i/o: output bitstream */ - UWord16 *num_bits /* i : number of indices written to output */ - ); +Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ +); + +Word16 pvq_core_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ +); +void core_switching_hq_prepare_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */ + const Word16 *audio /*q_audio*/ ); + +void hq_lr_enc_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ +); + +void hq_lr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: : encoder state structure */ + Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */ + const Word16 inner_frame_fx, /* i : Q0 : inner frame length */ + Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */ + const Word16 is_transient_fx /* i : Q0 : transient flag */ +); + +void hq_hr_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ +); + +void hq_hr_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure fx */ + Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ + const Word16 length, /* i : length of spectrum Q0 */ + Word16 *num_bits, /* i : number of available bits Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0 */ +); + +void reordernorm_fx( + const Word16 *ynrm, /* i : quantization indices for norms Q0 */ + const Word16 *normqlg2, /* i : quantized norms Q0 */ + Word16 *idxbuf, /* o : reordered quantization indices Q0 */ + Word16 *normbuf, /* o : reordered quantized norms Q0 */ + const Word16 nb_sfm /* i : number of bands Q0 */ +); + +void diffcod_fx( + const Word16 N, /* (i) number of sub-vectors Q0*/ + Word16 *y, /* (i/o) indices of quantized norms Q0*/ + Word16 *difidx /* (o) differential code Q0*/ +); + +/* o : Consumed bits Q0 */ +Word16 hq_classifier_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +/* o : Consumed bits Q0 */ +Word16 hq_classifier_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +void diff_envelope_coding_fx( + const Word16 is_transient, /* i : transient indicator Q0 */ + const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ + const Word16 start_norm, /* i : start of envelope coding Q0 */ + Word16 *ynrm, /* i/o: quantization indices for norms Q0 */ + Word16 *normqlg2, /* i/o: quantized norms Q0 */ + Word16 *difidx /* o : differential code Q0 */ +); + +/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ +Word16 encode_envelope_indices_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ +); + +void hq_generic_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas /* o : bwe excitation class */ +); + +void normalizecoefs_fx( + Word32 *coefs, /* i : Input vector (Q12) */ + const Word16 *ynrm, /* i : quantization indices for norms */ + const Word16 num_bands, /* i : Number of bands */ + const Word16 *band_start, /* i : Start of bands */ + const Word16 *band_end, /* i : End of bands */ + Word16 *coefs_norm /* o : Normalized output vector (Q12) */ +); + +/* o : Consumed bits */ +Word16 hvq_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 brate, /* i : Total bit rate */ + const Word16 hvq_bits, /* i : HVQ bit budget */ + const Word16 Npeaks, /* i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ + Word16 *noise_level, /* o : Quantized noise level */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q14 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ +); + +/* o : Consumed bits */ +Word16 hvq_enc_ivas_fx( + Encoder_State *st_fx, /*i/o: encoder state structure */ + const Word32 core_brate, /*i : Total bit rate */ + const Word16 hvq_bits, /*i : HVQ bit budget */ + const Word16 Npeaks, /*i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ + Word16 *noise_level, /* o : Quantized noise level Q15 */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q12 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ +); + +Word16 pvq_core_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ + Word16 coefs_quant[], /* o : quantized coefficients */ + Word16 *Q_coefs, + const Word16 bits_tot, /* i : total number of bits */ + const Word16 nb_sfm, /* i : number of bands */ + const Word16 *sfm_start, /* i : Subband start coefficient */ + const Word16 *sfm_end, /* i : Subband end coefficient */ + const Word16 *sfmsize, /* i : subband width */ + Word16 *R, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *Rs, /* i/o: Integer bit allocation */ + Word16 *npulses, /* o : number of pulses */ + Word16 *maxpulse, /* i : maximum pulse per band */ + const Word16 core /* i : number of bands */ +); + +/* o : index of noise attenuation Q0 */ +Word16 noise_adjust_fx( + const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ + const Word16 qx, /* i : Q value of coeffs_norm */ + const Word16 *bitalloc, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : band start Q0 */ + const Word16 *sfm_end, /* i : band end Q0 */ + const Word16 core_sfm /* i : index of the end band for core Q0 */ +); + +ivas_error tcq_core_LR_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 inp_vector_fx[], /* x5 */ + const Word32 coefs_norm_fx[], /* Q12 */ + Word32 coefs_quant_fx[], /* Q12 */ + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *R_fx, /* Q16 */ + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + +ivas_error tcq_core_LR_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word32 inp_vector[], + const Word32 coefs_norm_fx[], + Word32 coefs_quant_fx[], + const Word16 bit_budget, /* number of bits */ + const Word16 BANDS, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word32 *Rk_fx, + Word16 *npulses, + Word16 *k_sort, + const Word16 *p2a_flags, + const Word16 p2a_bands, + const Word16 *last_bitalloc, + const Word16 input_frame, + const Word16 adjustFlag, + const Word16 is_transient ); + +/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ +Word16 encode_envelope_indices_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ +); + +void diffcod_lrmdct_fx( + const Word16 N, /* i : number of sub-vectors Q0*/ + const Word16 be_ref, /* i : band energy reference Q0*/ + Word16 *y, /* i/o: indices of quantized norms Q0*/ + Word16 *difidx, /* o : differential code Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ +); + +Word16 peak_vq_enc_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 core_brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ +); + +Word16 peak_vq_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 *coefs, /* i : Input coefficient vector Q12 */ + Word32 *coefs_out, /* o : Quantized output vector Q12 */ + const Word32 brate, /* i : Core bitrate */ + const Word16 num_bits, /* i : Number of bits for HVQ */ + const Word16 vq_peaks, /* i : Number of identified peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *vq_peak_idx, /* i : Peak index vector */ + Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ +); + +void wb_vad_init_fx( + VAD_HANDLE hVAD /* i/o: VAD data handle */ +); + +void noise_est_init_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ +); + +void noise_est_init_ivas_fx( + NOISE_EST_HANDLE hNoiseEst /* i/o: Noise estimation handle */ +); + +void InitSWBencBuffer_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ +); + +void InitSWBencBuffer_ivas_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ +); + +void ResetSHBbuffer_Enc_fx( + TD_BWE_ENC_HANDLE hBWE_TD /* i/o: TD BWE data handle */ +); + +Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); + +Word16 E_ACELP_hh_corr( + Word16 *x /*Q11*/, + Word16 *y /*Qy*/, + Word16 L_subfr /*Q0*/, + Word16 bits /*Q0*/ +); + +void acelp_1t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[], /* o : filtered fixed codebook excitation */ + const Word16 L_subfr /* i : subframe length */ +); + +void acelp_2t32_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 h[], /* i : impulse response of weighted synthesis filter */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + Word16 y[] /* o : filtered fixed codebook excitation */ +); + +Word16 acelp_4t64_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 dn[], /* i : corr. between target and h[]. */ + const Word16 cn[], /* i : residual after long term prediction Q_new*/ + const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/ + Word16 R[], /* i : autocorrelation values */ + const Word16 acelpautoc, /* i : autocorrealtion flag */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + Word16 y[], /* o : filtered fixed codebook excitation Q9*/ + Word16 nbbits, /* i : number of bits per codebook */ + const Word16 cmpl_flag, /* i : coomplexity reduction flag */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 element_mode ); + +ivas_error evs_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *data, /* i : input signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of input samples Q0*/ +); + +/* o: Qx y(n) */ +/* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ +Word16 noise_est_AR1_Qx( + Word16 x, /* i : Qx x(n) */ + Word16 y, /* i : Qx y(n-1) */ + Word16 alpha /* i : Q15 scaling of driving x(n) */ +); + +/*o : Qx y( n ) */ +Word32 noise_est_AR1_Qx_32( + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /* i : Q15 scaling of driving x(n) */ +); + +void FEC_lsf_estim_enc_fx( + Encoder_State *st_fx, /* i : Encoder static memory */ + Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ +); + +Word32 mslvq_cng_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w, /* i : weights for LSF quantization Q10*/ + Word16 *no_scales ); + +Word32 mslvq_cng_ivas_fx( + Word16 idx_cv, /* i : index of cv from previous stage */ + Word16 *pTmp, /* i : 16 dimensional i vector x2.56*/ + Word16 *quant, /* o : quantized vector x2.56*/ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + const Word16 *w /* i : weights for LSF quantization Q10*/ +); + +void Unified_weighting_fx( + const Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */ + Word16 Q_ener, + const Word16 lsf_fx[], /* i : LSF vector x2.56 */ + Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */ + const Word16 narrowBand, /* i : flag for Narrowband Q0*/ + const Word16 unvoiced, /* i : flag for Unvoiced frame Q0*/ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 order /* i : LP order Q0*/ +); + +Word32 qlsf_ARSN_tcvq_Enc_16k_fx( + const Word16 *x_fx, /* i : Vector to be encoded x2.65 */ + Word16 *y_fx, /* o : Quantized LSF vector x2.65 */ + Word16 *indice, /* o : Indices */ + const Word16 *w_fx, /* i : LSF Weights Q10 */ + const Word16 nBits, /* i : number of bits */ + Word16 safety_net /* i : safety_net flag */ +); + +Word32 mslvq_fx( + Word16 *pTmp, /* i : M-dimensional i vector */ + Word16 *quant, /* o : quantized vector */ + Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */ + Word16 *idx_lead, /* o : leader index for each 8-dim subvector */ + Word16 *idx_scale, /* o : scale index for each subvector */ + Word16 *w, /* i : weights for LSF quantization */ + Word16 mode, /* i : number indicating the coding type (V/UV/G...) */ + Word16 mode_glb, /* i : LVQ coding mode */ + Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive ) */ + Word16 no_scales[][2] ); + +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +Word16 multi_harm_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ +); + +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +Word16 multi_harm_ivas_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ +); + +void pvq_encode_frame_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ +); + +void pvq_encode_frame_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *coefs_norm, /* i : normalized coefficients to encode */ + Word16 Q_coefs, /* i : Q-point of coefs_norm[] */ + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *gopt, /* o : optimal shape gains */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band Q3 */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ +); + +/*Qx o : interpolated value */ +Word16 Interpol_4( + Word16 *x, /*Qx i : i vector */ + Word16 frac /* i : fraction (-4..+3) */ +); + +void set_ppp_mode_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */ + const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */ + const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */ + const Word16 localVAD_he /* i : HE-SAD flag without hangover */ +); + +void decision_matrix_enc_fx( + Encoder_State *st_fx, /* i : encoder state structure */ + Word16 *hq_core_type /* o : HQ core_fx type Q0*/ +); + +void pvq_encode_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ +); + +void pvq_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + const Word16 *x, /* i : vector to quantize Q15-3=>Q12 */ + Word16 *y, /* o : raw pulses (non-scaled short) Q0 */ + Word16 *xq, /* o : quantized vector Q15 */ + Word32 *L_xq, /* o : quantized vector Q31 */ + const Word16 pulses, /* i : number of allocated pulses */ + const Word16 dim, /* i : Length of vector */ + const Word16 neg_gain /* i : Gain use - negative gain in Q15 0 ..1 */ +); + +void rc_enc_init_fx( + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + Word16 tot_bits /* i : Total bit budget Q0*/ +); + +void rc_enc_finish_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ +); + +void rc_enc_finish_ivas_fx( + BSTR_ENC_HANDLE hBstr, + PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ + +); + +void rc_encode_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ +); + +void rc_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 cum_freq, /* i : Cumulative frequency up to symbol Q0*/ + UWord32 sym_freq, /* i : Symbol probability Q0*/ + UWord32 tot /* i : Total cumulative frequency Q0*/ +); + +void rc_enc_uniform_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ +); + +void rc_enc_uniform_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + UWord32 tot /* i : Maximum value Q0*/ +); + +void rc_enc_bits_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ +); + +void rc_enc_bits_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ + UWord32 value, /* i : Value to encode Q0*/ + Word16 bits /* i : Number of bits used Q0*/ +); + +void re8_compute_base_index_fx( + const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ + const Word16 ka, /* i : Identifier of the absolute leader related to x */ + UWord16 *I /* o : index */ +); + +void tfaCalcEnv_fx( + const Word16 *shb_speech, + Word32 *enr ); + +/* o : pitch index */ +Word16 delta_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac, /* i : pitch fraction */ + const Word16 T0_min /* i : delta search min */ +); + +void set_impulse_fx( + const Word16 xn_fx[], /* i : target signal Q_new-1+shift*/ + const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter Q(14+shift)*/ + Word16 exc_fx[], /* o : adaptive codebook excitation Q_new*/ + Word16 yy1_fx[], /* o : filtered adaptive codebook excitation Q_new*/ + Word16 *imp_shape, /* o : adaptive codebook index Q0*/ + Word16 *imp_pos, /* o : position of the glottal impulse center index Q0*/ + Word32 *gain_trans_fx, /* o : transition gain Q7*/ + Word16 Q_new /* i : Current scaling */ +); + +/* o : pitch index */ +Word16 abs_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac /* i : pitch fraction */ +); + +ivas_error ppp_quarter_encoder_fx( + Word16 *returnFlag, /* o : return value */ + DTFS_STRUCTURE *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */ + DTFS_STRUCTURE *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */ + Word16 prevCW_lag, /* i : previous lag */ + DTFS_STRUCTURE vCURRCW_NQ_FX, /* i : Unquantized DTFS */ + const Word16 *curr_lpc_fx, /* i : LPCS */ + Word16 *lastLgainE_fx, /* i/o: last low band gain */ + Word16 *lastHgainE_fx, /* i/o: last high band gain */ + Word16 *lasterbE_fx, /* i/o: last ERB vector */ + DTFS_STRUCTURE PREV_CW_E_FX, /* i : past DTFS */ + Word16 *S_fx, /* i : sin table, Q15 */ + Word16 *C_fx, /* i : cos table, Q15 */ + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +); + +void index_lvq_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + +void index_lvq_ivas_fx( + Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/ + Word16 *idx_lead, /* i : leader class index for each subvector */ + Word16 *idx_scale, /* i : scale index for each subvector */ + Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */ + Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */ + const Word16 prediction_flag ); + +void copy_encoder_config_fx( + Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ + Encoder_State *st, /* o : encoder state structure */ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ +); + +void amr_wb_enc_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 input_sp[], /* i : i signal Q0*/ + Word32 *mem_hp20_in_fx, /* i/o: hp20 filter memory Qx*/ + const Word16 n_samples /* i : number of i samples Q0*/ +); + +void writeLPCparam_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ +); + +Word16 cng_energy_ivas_fx( + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidh */ + const Word16 CNG_mode, /* i : mode for DTX configuration */ + const Word16 CNG_att, /* i : attenuation factor for CNG Q7 */ + const Word16 *exc, /* i : input signal */ + const Word16 len, /* i : vector length */ + const Word16 Q_new /* i : Input scaling */ +); + +void generate_comfort_noise_enc_ivas_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ); + +void SynthesisSTFT_enc_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +ivas_error write_indices_ivas_fx( + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + UWord16 *bit_stream, /* i/o: output bitstream */ + UWord16 *num_bits /* i : number of indices written to output */ +); #endif -- GitLab From a0501b1d2400927c129fbad118cfc268760800e6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 18:43:33 +0100 Subject: [PATCH 06/14] harmonize encod_unvoiced_fx(), under CLEANUP_ACELP_ENC --- lib_enc/acelp_core_enc_fx.c | 21 ++++++++++- lib_enc/enc_uv_fx.c | 69 +++++++++++++++++++++++++++++-------- lib_enc/prot_fx_enc.h | 4 +-- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index b21bc566b..716313065 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -95,12 +95,17 @@ ivas_error acelp_core_enc_fx( ivas_error error; error = IVAS_ERR_OK; + +#ifdef CLEANUP_ACELP_ENC + (void) hStereoTD; +#else test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->core_brate, SID_2k40 ) ) { /* Core was ACELP because of DTX in MDCT-Stereo, but SID encoding for that is done in separate function */ return error; } +#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -196,6 +201,7 @@ ivas_error acelp_core_enc_fx( move16(); } +#ifndef CLEANUP_ACELP_ENC /* TD stereo */ test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) @@ -206,21 +212,25 @@ ivas_error acelp_core_enc_fx( tdm_Pri_pitch_buf = hStereoTD->tdm_Pri_pitch_buf_fx; } ELSE +#endif { tdm_lp_reuse_flag = 0; tdm_low_rate_mode = 0; move16(); move16(); +#ifndef CLEANUP_ACELP_ENC if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode ) { tdm_low_rate_mode = 1; move16(); } +#endif tdm_Pitch_reuse_flag = 0; tdm_Pri_pitch_buf = NULL; move16(); move16(); } + /*-----------------------------------------------------------------* * ACELP@12k8 / ACELP@16k switching *-----------------------------------------------------------------*/ @@ -551,21 +561,26 @@ ivas_error acelp_core_enc_fx( E_UTIL_deemph2( sub( Q_new, 1 ), syn1_fx, st_fx->preemph_fac, st_fx->L_frame, &hLPDmem->syn[M] ); Copy( syn1_fx + st_fx->L_frame - M - 1, hLPDmem->syn, M + 1 ); // Q_syn +#ifndef CLEANUP_ACELP_ENC test(); IF( st_fx->element_mode > EVS_MONO && st_fx->hTcxEnc != NULL ) { Copy( syn1_fx + st_fx->L_frame / 2, st_fx->hTcxEnc->Txnq, st_fx->L_frame / 2 ); // Q_syn } - +#endif /*--------------------------------------------------------------------------------------* * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + IF( NE_16( nelp_mode, 1 ) ) +#else test(); test(); test(); test(); IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#endif { L_epsP[0] = L_Comp( epsP_h_fx[2], epsP_l_fx[2] ); move32(); @@ -1335,7 +1350,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ +#ifdef CLEANUP_ACELP_ENC + encod_unvoiced_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#else encod_unvoiced_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, uc_two_stage_flag, res_fx, syn_fx, &tmp_noise_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); +#endif } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 2b0bd02ba..3b81f4f5d 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -16,7 +16,7 @@ * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ - +#ifndef CLEANUP_ACELP_ENC void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ @@ -247,22 +247,26 @@ void encod_unvoiced_fx( return; } +#endif - +#ifdef CLEANUP_ACELP_ENC +void encod_unvoiced_fx( +#else void encod_unvoiced_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ - const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ + const Word16 *Aq_fx, /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* o : core synthesis Q_new*/ + Word16 *syn_fx, /* o : core synthesis Q_new-1 (EVS) / Qnew*/ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ) { @@ -280,7 +284,7 @@ void encod_unvoiced_ivas_fx( Word16 y1[L_SUBFR]; /* Filtered adaptive excitation */ Word16 code2[L_SUBFR]; /* Gaussian excitation */ Word16 y22[L_SUBFR]; /* Filtered Gaussian excitation */ - // Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; + Word16 prm_t[2 * NPRM_DIV], *prm = prm_t; const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector */ Word32 norm_gain_code_fx; ACELP_config *acelp_cfg; @@ -329,12 +333,25 @@ void encod_unvoiced_ivas_fx( i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + + /*Copy_Scale_sig(h1_fx, h2_fx, L_SUBFR, -2);*/ + Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + } + ELSE +#endif + { + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - q_h1 = sub( 14, norm_s( h1_fx[0] ) ); - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); - Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); + } /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift @@ -366,16 +383,31 @@ void encod_unvoiced_ivas_fx( *-----------------------------------------------------------------*/ Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn ); + *pt_pitch_fx = L_SUBFR << 6; move16(); +#ifdef CLEANUP_ACELP_ENC + if ( st_fx->element_mode == EVS_MONO ) + { + *pt_pitch_fx = L_SUBFR; + move16(); + } +#endif /*----------------------------------------------------------------------* * Encode the algebraic innovation * *----------------------------------------------------------------------*/ #ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); + IF( st_fx->element_mode == EVS_MONO ) + { + E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate ); + } + ELSE + { + inov_encode_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, + gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); + } #else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, @@ -394,7 +426,16 @@ void encod_unvoiced_ivas_fx( move16(); assert( gain_pit_fx == 0 ); - gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + gauss_L2_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); + } + ELSE +#endif + { + gauss_L2_ivas_fx( h1_fx, code2, y2_fx, y22, &gain_code2, &g_corr, gain_pit_fx, hLPDmem->tilt_code, p_Aq_fx, acelp_cfg->formant_enh_num, &( st_fx->seed_acelp ), shift ); + } /*----------------------------------------------------------* * - Compute the fixed codebook gain * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 2792fbdcf..bfc2228b9 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2010,7 +2010,7 @@ void encod_unvoiced_fx( Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ); - +#ifndef CLEANUP_ACELP_ENC void encod_unvoiced_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ @@ -2027,7 +2027,7 @@ void encod_unvoiced_ivas_fx( Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ const Word16 Q_new, const Word16 shift ); - +#endif void enc_acelp_tcx_main_fx( const Word16 new_samples[], /* i : new samples Q15*/ Encoder_State *st, /* i/o: encoder state structure */ -- GitLab From 762921911564a020ab74bea1bf9680c3b5f5a0a0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 19:00:23 +0100 Subject: [PATCH 07/14] harmonize lp_gain_updt_fx(), under CLEANUP_ACELP_ENC --- lib_com/prot_fx.h | 8 +++++++- lib_dec/core_switching_dec_fx.c | 1 - lib_dec/dec_amr_wb_fx.c | 4 ++++ lib_dec/dec_gen_voic_fx.c | 4 ++++ lib_dec/dec_pit_exc_fx.c | 4 ++++ lib_dec/dec_tran_fx.c | 4 ++++ lib_dec/dec_uv_fx.c | 4 ++++ lib_dec/gain_dec_fx.c | 20 +++++++++++++++++--- lib_dec/gaus_dec_fx.c | 4 ++++ lib_dec/ivas_td_low_rate_dec_fx.c | 5 +++++ 10 files changed, 53 insertions(+), 5 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0396634e9..04007faf3 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6855,6 +6855,7 @@ void gain_dec_lbr_fx( const Word16 L_subfr /* i : subfr lenght */ ); +#ifndef CLEANUP_ACELP_ENC void lp_gain_updt_fx( const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ @@ -6863,8 +6864,13 @@ void lp_gain_updt_fx( Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ const Word16 L_frame /* i : length of the frame */ ); - +#endif +#ifdef CLEANUP_ACELP_ENC +void lp_gain_updt_fx( + const Word16 element_mode, /* i : element mode */ +#else void lp_gain_updt_ivas_fx( +#endif const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 8bab0d061..d1040cb80 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1302,7 +1302,6 @@ ivas_error core_switching_post_dec_ivas_fx( test(); IF( st_fx->core == ACELP_CORE && st_fx->bfi && hHQ_core != NULL && !st_fx->con_tcx ) { - /*needed to be converted to fixed curretnly using evs implementation not in line*/ if ( ( error = acelp_core_switch_dec_bfi_ivas_fx( st_fx, hHQ_core->fer_samples_fx, st_fx->coder_type ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 2fad171fd..2a977033d 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -99,7 +99,11 @@ void decod_amr_wb_fx( gain_dec_amr_wb_fx( st_fx, st_fx->core_brate, &gain_pit_fx, &L_gain_code_fx, hAmrwb_IO->past_qua_en_fx, &gain_inov_fx, code_fx, &L_norm_gain_code_fx ); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( EVS_MONO, i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#else lp_gain_updt_fx( i_subfr, gain_pit_fx, L_norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#endif #ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, L_gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index d92e66a94..f08c5e767 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -235,6 +235,9 @@ ivas_error decod_gen_voic_fx( } /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); +#else IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); @@ -243,6 +246,7 @@ ivas_error decod_gen_voic_fx( { lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); } +#endif /*----------------------------------------------------------------------* * Find the total excitation diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 067db4fcd..41fcb64c7 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -426,7 +426,11 @@ void dec_pit_exc_fx( move16(); pt_gain++; +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); +#else lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); +#endif } } diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index d9dfd9505..f2764e6e3 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -168,6 +168,9 @@ void decod_tran_fx( } /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); +#else IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); @@ -184,6 +187,7 @@ void decod_tran_fx( move16(); #endif } +#endif #ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index a0dd73994..9ced61d68 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -124,6 +124,9 @@ void decod_unvoiced_fx( move16(); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); +#else IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); @@ -132,6 +135,7 @@ void decod_unvoiced_fx( { lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); } +#endif /*-------------------------------------------------------* * - Find the total excitation. * diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 0848104af..fffead087 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -989,8 +989,7 @@ void gain_dec_lbr_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*=======================================================================*/ - - +#ifndef CLEANUP_ACELP_ENC void lp_gain_updt_fx( const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ @@ -1101,9 +1100,14 @@ void lp_gain_updt_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*=======================================================================*/ +#endif - +#ifdef CLEANUP_ACELP_ENC +void lp_gain_updt_fx( + const Word16 element_mode, /* i : element mode */ +#else void lp_gain_updt_ivas_fx( +#endif const Word16 i_subfr, /* i : subframe number Q0 */ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ @@ -1117,7 +1121,12 @@ void lp_gain_updt_ivas_fx( tmp = extract_h( L_shl_sat( norm_gain_code, 3 ) ); /*(16+3)-16 -> Q3*/ /* To handle extremely low values */ test(); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( element_mode != EVS_MONO && norm_gain_code != 0 && tmp == 0 ) +#else if ( norm_gain_code != 0 && tmp == 0 ) +#endif { tmp = 1; move16(); @@ -1195,7 +1204,12 @@ void lp_gain_updt_ivas_fx( /* To handle extremely low values */ test(); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( element_mode != EVS_MONO && tmp != 0 && *lp_gainc == 0 ) +#else if ( tmp != 0 && *lp_gainc == 0 ) +#endif { *lp_gainc = 1; move16(); diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index d49ecb5b7..456a7a902 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -87,6 +87,9 @@ void gaus_dec_fx( move32(); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st_fx->element_mode, i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ +#else IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ @@ -95,6 +98,7 @@ void gaus_dec_fx( { lp_gain_updt_ivas_fx( i_subfr, 0, *L_norm_gain_code, lp_gainp, lp_gainc, L_FRAME ); /* supposes that gain_dec_gaus() is used for ACELP@12k8 only */ } +#endif /*------------------------------------------------------------------------------------------* * Updates diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 377160d06..d897b116e 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -310,8 +310,13 @@ void decod_gen_2sbfr_fx( move16(); /* update LP filtered gains for the case of frame erasures */ +#ifdef CLEANUP_ACELP_ENC + lp_gain_updt_fx( st->element_mode, i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); + lp_gain_updt_fx( st->element_mode, add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); +#else lp_gain_updt_ivas_fx( i_subfr, gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); lp_gain_updt_ivas_fx( add( i_subfr, L_SUBFR ), gain_pit, norm_gain_code, &st->lp_gainp_fx, &st->lp_gainc_fx, L_frame ); +#endif /*----------------------------------------------------------------------* * Find the total excitation -- GitLab From 602321e1cb77a9de597acfb25cc7b3b4e9f8ecb7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 19:21:22 +0100 Subject: [PATCH 08/14] fix --- lib_enc/enc_pit_exc_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 7dd7d0e4b..b40bab692 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -456,20 +456,20 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { -#ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ -#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { +#ifdef CLEANUP_ACELP_ENC + hLPDmem->tilt_code = est_tilt_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr ); /* Q15 */ +#else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ +#endif } ELSE #endif { hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ } -#endif move16(); } ELSE -- GitLab From 374d8c89505fe72ea3850b2133429cd290896da2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 20:50:37 +0100 Subject: [PATCH 09/14] harmonize tbe_celp_exc(), under CLEANUP_ACELP_ENC --- lib_com/prot_fx.h | 16951 ++++++++++++++-------------- lib_com/swb_tbe_com_fx.c | 49 +- lib_dec/dec_ace_fx.c | 4 + lib_dec/dec_gen_voic_fx.c | 5 + lib_dec/ivas_td_low_rate_dec_fx.c | 4 + lib_enc/cod_ace_fx.c | 4 + lib_enc/enc_gen_voic_fx.c | 9 +- lib_enc/ivas_td_low_rate_enc_fx.c | 4 + 8 files changed, 8549 insertions(+), 8481 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 04007faf3..f78f12025 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2910,6 +2910,7 @@ Word16 tbe_celp_exc_offset( const Word16 L_frame /* i : frame lenght */ ); +#ifndef CLEANUP_ACELP_ENC void tbe_celp_exc( const Word16 L_frame_fx, /* i : Frame lenght */ const Word16 i_subfr_fx, /* i : sub frame */ @@ -2918,8 +2919,12 @@ void tbe_celp_exc( Word16 *error_fx, /* i/o: Error */ Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */ ); - +#endif +#ifdef CLEANUP_ACELP_ENC +void tbe_celp_exc( +#else void tbe_celp_exc_ivas( +#endif const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 L_frame_fx, /* i : Frame lenght */ @@ -2932,2163 +2937,2195 @@ void tbe_celp_exc_ivas( const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ ); -void flip_and_downmix_generic_fx( - Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); - -void Calc_rc0_h( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ -); - -void Calc_rc0_h_ivas_enc_fx( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ -); - -void PostShortTerm_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ -); - -void PostShortTerm_ivas_enc_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ -); - -void PostShortTerm_ivas_dec_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ -); - -void flip_spectrum_and_decimby4_fx( - const Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : vector length */ - Word16 mem1[], /* i/o : memory */ - Word16 mem2[], /* i/o : memory */ - const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ -); - -void GenShapedWBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb exctiation */ - const Word16 *lpc_shb, /* i : lpc coefficients */ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - Word32 *mem_csfilt, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ - Word16 *state_lpc_syn, /* i/o : memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_bwe_exc, - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor */ - const Word16 signal_type, - const Word16 igf_flag ); - -void GenWBSynth_fx( - const Word16 *input_synspeech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_16k, /* o : output highband compnent */ - Word16 *state_lsyn_filt_shb1, /* i/o: memory */ - Word16 *state_lsyn_filt_shb2 /* i/o: memory */ -); - -void GenShapedSHBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi ); - -void GenShapedSHBExcitation_ivas_enc_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); - -void GenShapedSHBExcitation_ivas_dec_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ -); - -void GenSHBSynth_fx( - const Word16 *shb_target_speech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP Frame length */ - Word16 *syn_dm_phase ); - -void GenSHBSynth_fx32( - const Word32 *input_synspeech, /* i : input synthesized speech */ - Word32 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP frame length */ - Word16 *syn_dm_phase ); - -void ScaleShapedSHB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o: synthesized shb signal */ - Word16 *overlap, /* i/o: buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - Word16 *Q_bwe_exc, - Word16 *Qx, - Word16 n_mem3, - Word16 prev_Q_bwe_syn2 ); - -void ScaleShapedSHB_fx32( - const Word16 length, /* i : SHB overlap length */ - Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ - Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ - const Word16 *subgain_fx, /* i : subframe gain Q15 */ - const Word32 frame_gain_fx, /* i : frame gain */ - const Word16 *win_fx, /* i : window Q15 */ - const Word16 *subwin_fx, /* i : subframes window Q15 */ - Word16 *Q_inp, - Word16 *Q_new ); - -void ScaleShapedWB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o : synthesized shb signal */ - Word16 *overlap, /* i/o : buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - const Word16 Q_bwe_exc, - Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ - Word16 *Qx, /* o : newly computed Q factor for synSHB */ - Word16 prev_Qx, /* i : prev_Qx for memory scaling */ - Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ -); - -void non_linearity_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ -); - -void non_linearity_ivas_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ -); - -void interp_code_5over2_fx( - const Word16 inp_code[], /* i : i vector */ - Word16 interp_code[], /* o : output vector */ - const Word16 inp_length /* i : length of i vector */ -); - -void interp_code_4over2_fx( - const Word16 inp_code_fx[], /* i : i vector Qx */ - Word16 interp_code_fx[], /* o : output vector Qx */ - const Word16 inp_length /* i : length of i vector */ -); - -void wb_tbe_extras_reset_synth_fx( - Word16 state_lsyn_filt_shb[], - Word16 state_lsyn_filt_dwn_shb[], - Word16 state_32and48k_WB_upsample[], - Word16 state_resamp_HB[] ); - -void elliptic_bpf_48k_generic_fx( - const Word16 element_mode, - Word16 IsUpsampled3, - Word16 input_fx[], /* i : input signal Q_input_fx*/ - Word16 *Q_input_fx, - Word16 output_fx[], /* o : output signal */ - Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ - Word16 memory_fx_Q[], - const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ -); - -void synthesise_fb_high_band_fx( - const Word16 excitation_in[], /* i : full band excitation */ - Word16 Q_fb_exc, - Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ - const Word32 fb_exc_energy, /* i : full band excitation energy */ - const Word16 ratio, /* i : energy ratio */ - const Word16 L_frame, /* i : ACELP frame length */ - const Word16 bfi, /* i : fec flag */ - Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ - Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ - Word16 bpf_memory_Q[], - Word16 Qout, - Word16 element_mode ); - -void prep_tbe_exc_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - const Word16 T0, /* i : integer pitch variables Q0 */ - const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -/*! r: Formant filter strength [0,1] */ -Word16 swb_formant_fac_fx( - const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ - Word16 *tilt_mem /* i/o: Tilt smoothing memory */ -); - -void wb_tbe_extras_reset_fx( - Word16 mem_genSHBexc_filt_down_wb2[], - Word16 mem_genSHBexc_filt_down_wb3[] ); - -Word16 get_tbe_bits_fx( - const Word32 total_brate, /* o : TBE bit consumption per frame */ - const Word16 bwidth, /* i : overall bitrate */ - const Word16 rf_mode /* i : bandwidht mode */ -); - -UWord32 intLimCDivPos_fx( - UWord32 NUM, /* Qx */ - Word16 DEN /* Q0 */ -); - -Word16 shrtCDivSignedApprox( - const Word16 num, /* Q0 */ - const Word16 den /* Q0 */ -); - -void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy Q0*/ - const Word16 R, /* i : right vector energy Q0*/ - Word16 *Density /* o : quantizer density Q0*/ -); - -void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, /* Q0 */ - Word16 *diracs /* Q0 */ -); - -void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ - const Word16 dsm, /* i : Conservative rounding flag Q0*/ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index Q0*/ -); - -void QuantaPerDsDirac_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ - const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ - Word16 *Quanta /* i : Quanta Q0*/ -); - -void conservativeL1Norm_fx( - const Word16 L, /* i : Length of vector segment Q0*/ - const Word16 Qvec, /* i : Assigned number of quanta Q0*/ - const Word16 Fcons, /* i : Conservative rounding flag Q0*/ - const Word16 Qavail, /* i : Input quanta remaining Q0*/ - const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ - const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ - Word16 *Dvec, /* o : actual number of diracs Q0*/ - Word16 *Qspare, /* o : Output quanta remaining Q0*/ - Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ - Word16 *Dspecplus /* o : Output number of diracs Q0*/ -); - -void bandBitsAdjustment_fx( - const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ - const UWord32 INTrc, /* i : Range coder state Q0*/ - const Word16 Bavail, /* i : Available number of quanta Q3*/ - const Word16 Nbands, /* i : Number of bands Q0*/ - const Word16 D, /* i : Remaining number of bands to encode Q0*/ - const Word16 L, /* i : Size of current band Q0*/ - const Word16 Bband, /* i : Quanta allocation for current band Q0*/ - const Word16 Breserv, /* i : Quanta reservoir Q0*/ - Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ - Word16 *Brem, /* o : Quanta remaining Q0*/ - Word16 *Breservplus /* o : Quanta pool size Q0*/ -); - -void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density Q0*/ - const Word16 indexphi, /* i : decoded index from AR dec Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ -); - -void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density Q0*/ - const Word16 phiQ14uq, /* i : angle Q14*/ - Word16 *indexphi, /* o : index Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ -); - -void NearOppSplitAdjustment_fx( - const Word16 qband, /* i : quanta for current band Q0*/ - const Word16 qzero, /* i : range coder finalization quanta Q0*/ - const Word16 Qac, /* i : range coder current quanta Q0*/ - const UWord32 INTac, /* i : range coder state Q0*/ - const Word16 qglobal, /* i : quanta input Q0*/ - const Word16 FlagCons, /* i : conservative rounding flag Q0*/ - const Word16 Np, /* i : number of parts Q0*/ - const Word16 Nhead, /* i : first part Q0*/ - const Word16 Ntail, /* i : remaining parts Q0*/ - const Word16 Nnear, /* i : length of near component Q0*/ - const Word16 Nopp, /* i : length of opposite component Q0*/ - Word16 oppRQ3, /* i : ratio Q0*/ - Word16 *qnear, /* o : quantized near Q0*/ - Word16 *qopp, /* o : quantized opposite Q0*/ - Word16 *qglobalupd /* o : quanta remaining Q0*/ -); - -void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 *band_start, /* i : Sub band start indices Q0 */ - const Word16 *band_end, /* i : Sub band end indices Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gains, /* i : Band gain vector Q12 */ - Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ -); - -void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ -); - -void srt_vec_ind16_fx( - const Word16 *linear, /* linear input Q3*/ - Word16 *srt, /* sorted output Q3*/ - Word16 *I, /* index for sorted output Q0*/ - Word16 length /* Q0 */ -); - -/* o: Angle between 0 and PI/2 radian (Q14) */ -Word16 atan2_fx( - const Word32 y, /* i : near side (Argument must be positive) (Q15) */ - const Word32 x /* i : opposite side (Q15) */ -); - -/* o: Number of bits needed Q0*/ -Word16 rc_get_bits2_fx( - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ -); - -void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits Q0*/ - UWord32 INTrc, /* i : Range coder state Q0*/ - Word16 *FBits /* i : Fractional finalization bits Q0*/ -); - -ivas_error DTFS_new_fx( - DTFS_STRUCTURE **dtfs_out ); - -void DTFS_copy_fx( - DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ - DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ -); - -void DTFS_sub_fx( - DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ - DTFS_STRUCTURE X1, /* i: DTFS i 1 */ - DTFS_STRUCTURE X2 /* i: DTFS i 2 */ -); - -Word16 DTFS_alignment_full_fx( - DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ - DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ - Word16 ph_offset_fx, /* i : resolution */ - Word16 *S_fx, - Word16 *C_fx, - Word16 FR_flag ); - -void DTFS_phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - -void Q2phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - -void DTFS_zeroPadd_fx( - Word16 N_fx, - DTFS_STRUCTURE *X_fx ); - -void DTFS_to_fs_fx( - const Word16 *x, /* i : time domain signal */ - Word16 N, /* i : Length of i vector */ - DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ - const Word16 Fs, /* i : sampling rate */ - const Word16 FR_flag, /* i : FR flag */ - Word16 *S_fx, - Word16 *C_fx ); - -void DTFS_zeroFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - -void DTFS_poleFilter_fx_9( - DTFS_STRUCTURE *X_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - -void DTFS_adjustLag_fx( - DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ - Word16 N_fx /* i : Target lag */ -); - -Word32 DTFS_getEngy_fx( - DTFS_STRUCTURE *X_fx ); - -Word32 DTFS_getEngy_P2A_fx( - DTFS_STRUCTURE *X_fx ); - -void DTFS_car2pol_fx( - DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ -); - -Word32 DTFS_setEngyHarm_fx( - Word16 f1_fx, /* i : lower band freq of i to control energy */ - Word16 f2_fx, /* i : upper band freq of i to control energy */ - Word16 g1_fx, /* i : lower band freq of output to control energy */ - Word16 g2_fx, /* i : upper band freq of output to control energy */ - Word32 en2_fx, /* i : Target Energy to set the DTFS to */ - Word16 Qen2_fx, /* i : Input Q format for en2 */ - Word16 *Qa_fx, /* i : Output Q format for x->a */ - DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ -); - -void DTFS_to_erb_fx( - const DTFS_STRUCTURE X_fx, /* i : DTFS i */ - Word16 *out_fx /* o : ERB output */ -); - -void erb_slot_fx( - Word16 lag_fx, /* i : i lag */ - Word16 *out_fx, /* o : ERB slots */ - Word16 *mfreq_fx, /* i : ERB frequencies */ - Word16 num_erb_fx /* i : number of ERBs */ -); - -void DTFS_erb_inv_fx( - Word16 *in_fx, /* i : ERB inpt */ - Word16 *slot_fx, /* i : ERB slots filled based on lag */ - Word16 *mfreq_fx, /* i : erb frequence edges */ - DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ - Word16 num_erb_fx /* i : Number of ERB bands */ -); - -void erb_add_fx( - Word16 *curr_erb_fx, /* i/o: current ERB */ - Word16 l_fx, /* i : current lag */ - const Word16 *prev_erb_fx, /* i : previous ERB */ - Word16 pl_fx, /* i : previous lag */ - const Word16 *index_fx, /* i : ERB index */ - Word16 num_erb_fx /* i : number of ERBs */ -); - -void quant_target_fx( - DTFS_STRUCTURE *X_fx, - const Word16 *curr_lpc, - Word16 *w, - Word16 *target, - Word16 *sin_tab, - Word16 *cos_tab ); - -ivas_error WIsyn_fx( - DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ - DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ - const Word16 *curr_lpc_fx, /* i : LPC */ - Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ - Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ - const Word16 N, /* i : Number of output samples to generate */ - const Word16 FR_flag, /* i : called for post-smoothing in FR */ - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2 ); - -Word16 ppp_extract_pitch_period_fx( - const Word16 *in, /* i : i residual */ - Word16 *out, /* o : output residual */ - Word16 l, /* i : lag */ - Word16 *out_of_bound, /* o : out of bound flag */ - Word16 Qres ); - -void DTFS_peaktoaverage_fx( - DTFS_STRUCTURE X_fx, /* i : DTFS */ - Word32 *pos_fx, /* o : positive peak to ave */ - Word16 *Qpos, /* o : positive peak to ave Q format */ - Word32 *neg_fx, /* o : negative peak to ave */ - Word16 *Qneg /* o : negative peak to ave Q format */ -); - -void rshiftHarmBand_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband_fx, - Word16 hband_fx, - Word16 shift_fx ); - -void GetSinCosTab_fx( - Word16 L, - Word16 *sinTab, - Word16 *cosTab ); - -void r_fft_4_fx( - Word16 *farray_ptr_fx, - Word16 size, - Word16 stage, - Word16 isign ); - -void copy_phase_fx( - DTFS_STRUCTURE *X1_fx, - DTFS_STRUCTURE X2_fx, - DTFS_STRUCTURE *retX_fx ); - -Word32 getSpEngyFromResAmp_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband, - Word16 hband, - const Word16 *curr_lpc, - Word16 *sin_tab, - Word16 *cos_tab ); - -void DTFS_poleFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - -void poleFilter_setup_fx( - const Word16 *LPC, - Word16 N, - DTFS_STRUCTURE X_fx, - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - -Word32 DTFS_getEngy_band_wb_fx( - DTFS_STRUCTURE X_fx, - Word16 lband, - Word16 hband ); - -void InitTnsConfiguration( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void InitTnsConfiguration_ivas_fx( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void ApplyTnsFilter( - STnsConfig const *pTnsConfig, - STnsData const *pTnsData, - Word32 spectrum[], - const Word8 fIsAnalysis ); - -Word16 ITF_Detect_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); - -Word16 ITF_Detect_ivas_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); - -void ITF_Apply_fx( - Word32 spectrum[], - Word16 startLine, - Word16 stopLine, - const Word16 *A, - Word16 Q_A, - Word16 curr_order ); - -void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); - -Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - -Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - -Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); - -Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); - -Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - -Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - -Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - -void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); - -Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); - -Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); - -Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); - -Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); - -Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); - -Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); - -Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); - -void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); - -void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); - -void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); - -void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); - -void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); - -void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); -void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); - -void ResetTnsData( STnsData *pTnsData ); - -void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); - -/*========================================================================================================/ -gp_clips_fx.c -/========================================================================================================*/ - -void init_gp_clip_fx( - Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ -); - -Word16 gp_clip_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 coder_type, /* i : type of coder Q0*/ - const Word16 xn[], /* i : target vector Q_new*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Q_new /* i : scaling factor */ -); - -void gp_clip_test_isf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ -); - -void gp_clip_test_gain_pit_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ - Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ -); - -Word16 Mode2_gp_clip_fx( - const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 coder_type, /* i : type of coder Q0 */ - const Word16 xn[], /* i : target vector Q_xn */ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ - /* mem[0]: Q0 */ - /* mem[1]: 1Q14 */ - /* mem[2]: 8Q7 */ - /* mem[3]: Q0 (integer) */ - /* mem[4]: Q14 */ - /* mem[5]: Q14 */ - const Word16 L_subfr, /* Q0 */ - const Word16 Q_xn /* i : scaling factor of vector xn[] */ -); - -void gp_clip_test_lsf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 m /* i : dimension of lsf Q0*/ -); - -void gp_clip_test_lsf_ivas_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ -); - -/*========================================================================================================/ -nelp_enc_fx.c -/========================================================================================================*/ - -void quantize_uvg_fx( - Word16 *G, - Word16 *iG1, - Word16 *iG2, - Word16 *quantG, - Word16 bandwidth ); - -void nelp_encoder_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - -void nelp_encoder_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - -void swb_bwe_enc_lr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -); - -void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ -); - -void isf_enc_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *isf_new, /* i/o: quantized ISF vector */ - Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ - Word16 *Aq /* o : quantized A(z) for 4 subframes */ -); - -Word16 detect_transient_fx( - const Word16 *in_fx, /*Q_new */ - const Word16 L, /*Q0*/ - Word16 Q_new, - Encoder_State *st_fx ); - -Word16 tcxGetNoiseFillingTilt( - const Word16 A[], - const Word16 lpcorder, - const Word16 L_frame, - const Word16 mode, - Word16 *noiseTiltFactor ); - -void tcxFormantEnhancement( - Word16 xn_buf[], - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - -void tcxFormantEnhancement_with_shift( - Word16 xn_buf[], - Word16 *xn_buf_e, - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - -void tcxInvertWindowGrouping( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word32 xn_buf[], - Word32 spectrum[], - const Word16 L_frame, - const Word8 fUseTns, - const Word16 last_core, - const Word16 index, - const Word16 frame_cnt, - const Word16 bfi ); - -void permute_fx( - Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ - const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ -); - -void init_lvq_fx( - Word32 offset_scale1[][MAX_NO_SCALES + 1], - Word32 offset_scale2[][MAX_NO_SCALES + 1], - Word32 offset_scale1_p[][MAX_NO_SCALES + 1], - Word32 offset_scale2_p[][MAX_NO_SCALES + 1], - Word16 no_scales[][2], - Word16 no_scales_p[][2] ); - -Word16 deindex_lvq_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ - Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, /* i : offset for first subvector */ - Word32 *p_offset_scale2, /* i : offset for the second subvector */ - Word16 *p_no_scales ); - -Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ -); - -Word16 deindex_lvq_cng_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q9*/ - Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - -Word16 deindex_lvq_cng_ivas_fx( - Word16 *index, /* i: index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o: decoded codevector Q9 */ - Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ - Word16 no_bits /* i: number of bits for lattice */ -); - -Word16 lsp_convert_poly_fx( - Word16 w[], /* i/o: LSP or ISP parameters */ - const Word16 L_frame, /* i : flag for up or down conversion */ - const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ -); - -void CNG_exc_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 L_frame, /* i : length of the frame */ - Word32 *Enew, /* i/o: decoded SID energy Q6 */ - Word16 *seed, /* i/o: random generator seed */ - Word16 exc[], /* o : current non-enhanced excitation Q_new */ - Word16 exc2[], /* o : current enhanced excitation Q_new */ - Word32 *lp_ener, /* i/o: LP filtered E */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ - Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - Word16 bwe_exc[], /* o : excitation for SWB TBE */ - const Word16 allow_cn_step, /* i : allow CN step */ - Word16 *last_allow_cn_step, /* i/o: last allow step */ - const Word16 OldQ_exc, /* i : Old excitation scaling */ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 num_ho, /* i : number of selected hangover frames */ - Word32 q_env[], - Word32 *lp_env, - Word32 *old_env, - Word16 *exc_mem, - Word16 *exc_mem1, - Word16 *sid_bw, - Word16 *cng_ener_seed1, - Word16 exc3[], - Word16 Opt_AMR_WB, - const Word16 element_mode /* i : IVAS Element mode */ -); - -void cng_params_postupd_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ -); - -void cng_params_postupd_ivas_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ -); - -void cng_params_upd_fx( - const Word16 lsp_new[], /* i : LSP parameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ -); - -void cng_params_upd_ivas_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate, /* i : Last active bit rate Q0 */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ -); - -Word16 get_cng_mode( - const Word32 last_active_brate /* i : last active bitrate */ -); - -/*! r: codec mode */ -Word16 get_codec_mode( - const Word32 total_brate /* i : total bitrate */ -); - -Word16 getTcxonly( - const Word32 total_brate /* i : total bitrate */ -); - -Word16 getTcxonly_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ -); - -Word16 getCtxHm( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_flag /* i : flag to signal the RF mode */ -); - -Word16 getResq( - const Word32 total_brate /* i : total bitrate */ -); - -Word16 getTnsAllowed( - const Word32 total_brate, /* i : total bitrate */ - const Word16 igf, /* i : flag indicating IGF activity*/ - const Word16 element_mode /* i : IVAS element mode */ -); - -Word16 getRestrictedMode( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ -); - -Word16 getMdctWindowLength_fx( - const Word16 fscale ); - -Word16 sr2fscale_fx( - const Word32 sr_core /* i : internal sampling rate */ -); - -Word32 getCoreSamplerateMode2( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ -); - -Word16 getTcxBandwidth( - const Word16 bandwidth ); - -Word16 getIgfPresent_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -Word16 getCnaPresent_fx( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth /* i : audio bandwidth */ -); - -Word16 getTcxLtp( - const Word32 sr_core /* i : internal sampling rate */ -); - -Word16 initPitchLagParameters( - const Word32 sr_core, - Word16 *pit_min, - Word16 *pit_fr1, - Word16 *pit_fr1b, - Word16 *pit_fr2, - Word16 *pit_max ); - -Word16 getNumTcxCodedLines( - const Word16 bwidth ); - -Word16 getTcxLpcShapedAri( - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const Word16 element_mode /* i : IVAS element mode */ -); - -void mdct_window_sine( - PWord16 *window, /* Qx */ - Word16 n /* Q0 */ -); - -void mdct_window_sine_IVAS_updated( - PWord16 *window, /* Qx */ - const Word32 Fs, /* Q0 */ - const Word16 n, /* Q0 */ - const Word16 window_type, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void mdct_window_aldo( - Word16 *window1, /* Q15 */ - PWord16 *window1_trunc, /* Q15 */ - PWord16 *window2, /* Q15 */ - Word16 n /* Q0 */ -); - -Word16 getInvFrameLen( - const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ - -void tcx_get_windows( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const Word16 left_mode, /* i: overlap mode of left window half */ - const Word16 right_mode, /* i: overlap mode of right window half */ - Word16 *left_overlap, /* o: left overlap length */ - const PWord16 **left_win, /* o: left overlap window */ - Word16 *right_overlap, /* o: right overlap length */ - const PWord16 **right_win, /* o: right overlap window */ - const Word8 fullband /* i: fullband flag */ -); - -void WindowSignal( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 offset, /* i : left folding point offset relative to the i signal pointer */ - const Word16 left_overlap_mode, /* i : overlap mode of left window half */ - Word16 right_overlap_mode, /* i : overlap mode of right window half */ - Word16 *left_overlap_length, /* o : TCX window left overlap length */ - Word16 *right_overlap_length, /* o : TCX window right overlap length */ - const Word16 in[], /* i : i signal */ - Word16 *L_frame, /* i/o: frame length */ - Word16 out[], /* o : output windowed signal */ - const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const Word8 fullband /* i : fullband flag */ -); - -void tcx_windowing_synthesis_current_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 left_rect, /* i: left part is rectangular */ - const Word16 left_mode, /* i: overlap mode of left window half */ - Word16 *acelp_zir, /* i: acelp ZIR */ - const Word16 *old_syn, - const Word16 *syn_overl, - const Word16 *A_zir, - const PWord16 *window_trans, - Word16 acelp_zir_len, - const Word16 acelp_mem_len, - const Word16 last_core_bfi, /* i : last core */ - const Word8 last_is_cng, - const Word16 fullbandScale ); - -void tcx_windowing_synthesis_past_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ -); - -void lpc2mdct( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 *mdct_gains, - Word16 *mdct_gains_exp, - Word16 *mdct_inv_gains, - Word16 *mdct_inv_gains_exp, - const Word16 length, - const Word16 noInverse ); - -void lpc2mdct_2( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 mdct_gains_fx[], - Word16 mdct_gains_e[], - Word16 mdct_inv_gains_fx[], - Word16 mdct_inv_gains_e[], - const Word16 length ); - -void mdct_shaping( - Word32 x[], - const Word16 lg, - const Word16 gains[], - const Word16 gains_exp[] ); - -void mdct_shaping_16( - const Word16 x[], - const Word16 lg, - const Word16 lg_total, - const Word16 gains[], - const Word16 gains_exp[], - Word16 gains_max_exp, - Word32 y[] ); - -void mdct_noiseShaping_ivas_fx( - Word32 x_fx[], - Word16 *x_e, - const Word16 lg, - const Word16 gains_fx[], - const Word16 gains_exp[] ); - -void mdct_noiseShaping_interp( - Word32 x[], - const Word16 lg, - Word16 gains[], - Word16 gains_exp[] ); - -void PsychAdaptLowFreqDeemph( - Word32 x[], - const Word16 lpcGains[], - const Word16 lpcGains_e[], - Word16 lf_deemph_factors[] ); - -void AdaptLowFreqDeemph( - Word32 x[], - Word16 x_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], - Word16 lpcGains_e[], - const Word16 lg, - Word16 lf_deemph_factors[] ); - -void tcx_noise_filling( - Word32 *Q, - Word16 Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ -); - -void tcx_noise_filling_with_shift( - Word32 *Q, - Word16 *Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ -); - -void InitTnsConfigs( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void InitTnsConfigs_ivas_fx( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - -void SetAllowTnsOnWhite( - STnsConfig tnsConfig[2][2], - const Word8 allowTnsOnWhite ); - -void SetTnsConfig( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const Word16 isTCX20, - const Word16 isAfterACELP ); - -void tcx_get_gain( - Word32 *x, /* i: spectrum 1 */ - Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 */ - Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length */ - Word16 *gain, /* o: gain */ - Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) */ - Word16 *en_y_e /* o: energy of y exponent (optional) */ -); - -void init_TCX_config( - TCX_CONFIG_HANDLE hTcxCfg, - Word16 L_frame, - Word16 fscale, - Word16 L_frameTCX, - Word16 fscaleFB ); - -void resetTecDec_Fx( - TEC_DEC_HANDLE hTecDec ); - -void resetTecEnc_Fx( - TEC_ENC_HANDLE hTECEnc, - Word16 flag ); - -void calcGainTemp_TBE_Fx( - Word32 **pCldfbRealSrc_Fx, - Word32 **pCldfbImagSrc_Fx, - Word16 cldfb_exp, - Word16 *loBuffer_Fx, - const Word16 startPos, /*!< Start position of the current envelope. */ - const Word16 stopPos, /*!< Stop position of the current envelope. */ - const Word16 lowSubband, /* lowSubband */ - Word16 *pGainTemp_m, - Word16 *pGainTemp_e, - const Word16 code ); - -Word16 procTecTfa_TBE_Fx( - Word16 *hb_synth_Fx, - Word16 hb_synth_fx_exp, - Word16 *gain_m, - Word16 *gain_e, - Word16 flat_flag, - Word16 last_core, - Word16 l_subfr, - Word16 code ); - -void calcHiEnvLoBuff_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - const Word16 nSfb, /*!< Number of scalefactors. */ - Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 pCldfbPow_FixScale ); - -void calcLoEnvCheckCorrHiLo_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, - Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 *corrFlag /*int* corrFlag*/ -); - -void tecEnc_TBE_fx( - Word16 *corrFlag, - const Word16 *voicing, - const Word16 coder_type ); - -void set_TEC_TFA_code_fx( - const Word16 corrFlag, - Word16 *tec_flag, - Word16 *tfa_flag ); - -void TCX_MDCT( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void TCX_MDST( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void TCX_MDCT_Inverse( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qy */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ -); - -void TCX_MDST_Inverse_fx( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r /* Q0 */ -); - -void TCX_MDXT_Inverse_fx( - const Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const UWord16 kernel_type /* Q0 */ -); - -void edct_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ -); - -void edct_ivas_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ - Word16 *q /* i : Q value of input signal */ -); - -void edst_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ -); - -void edct_16fx( - const Word16 *x, /* i : i signal Qx */ - Word16 *y, /* o : output transform Qx */ - Word16 length, /* i : length */ - Word16 bh, /* bit-headroom */ - const Word16 element_mode ); - -void iedct_short_fx( - const Word32 *in, /* i : i vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 segment_length /* i : length */ -); - -void edxt_fx( - const Word32 *x, /* i : input signal */ - Word32 *y, /* o : output transform */ - const Word16 length, /* i : length */ - const UWord16 kernelType, /* i : kernel type (0 - 3) */ - const UWord16 synthesis /* i : nonzero for inverse */ -); - -void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); -void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); -void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); - -void DoRTFTn_fx( - Word32 *x, /* i/o : real part of i and output data */ - Word32 *y, /* i/o : imaginary part of i and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ -); - -void DoRTFT480_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT320_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT160_fx( - Word32 x[], /* i/o: real part of input and output data */ - Word32 y[] /* i/o: imaginary part of input and output data */ -); - -void DoRTFT128_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT120_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT80_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT40_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -void DoRTFT20_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ -); - -Word16 RFFTN_fx( - Word32 *data, - const Word16 *sine_table, - const Word16 len, - const Word16 sign ); - -void DoFFT_fx( - Word32 *re2, - Word32 *im2, - const Word16 length ); - -void fft_fx( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - const Word16 length, /* i : length of fft */ - const Word16 s /* i : sign */ -); - -void rfft_fx( - Word32 *x, /* i/o: values */ - const Word16 *w, /* i : window */ - const Word16 length, /* i : length of fft */ - const Word16 isign /* i : sign */ -); - -void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ -); - - -Word16 find_guarded_bits_fx( const Word32 n ); + void flip_and_downmix_generic_fx( + Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ + ); + + void Calc_rc0_h( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ + ); + + void Calc_rc0_h_ivas_enc_fx( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ + ); + + void PostShortTerm_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ + ); + + void PostShortTerm_ivas_enc_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ + ); + + void PostShortTerm_ivas_dec_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ + ); + + void flip_spectrum_and_decimby4_fx( + const Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : vector length */ + Word16 mem1[], /* i/o : memory */ + Word16 mem2[], /* i/o : memory */ + const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ + ); + + void GenShapedWBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb exctiation */ + const Word16 *lpc_shb, /* i : lpc coefficients */ + Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ + Word32 *mem_csfilt, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ + Word16 *state_lpc_syn, /* i/o : memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_bwe_exc, + Word16 bwe_seed[], /* i/o : random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor */ + const Word16 signal_type, + const Word16 igf_flag ); + + void GenWBSynth_fx( + const Word16 *input_synspeech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_16k, /* o : output highband compnent */ + Word16 *state_lsyn_filt_shb1, /* i/o: memory */ + Word16 *state_lsyn_filt_shb2 /* i/o: memory */ + ); + + void GenShapedSHBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi ); + + void GenShapedSHBExcitation_ivas_enc_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 Q_EnvSHBres_4k, + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ + ); + + void GenShapedSHBExcitation_ivas_dec_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, /* i : previous frame was concealed */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ + ); + + void GenSHBSynth_fx( + const Word16 *shb_target_speech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP Frame length */ + Word16 *syn_dm_phase ); + + void GenSHBSynth_fx32( + const Word32 *input_synspeech, /* i : input synthesized speech */ + Word32 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP frame length */ + Word16 *syn_dm_phase ); + + void ScaleShapedSHB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o: synthesized shb signal */ + Word16 *overlap, /* i/o: buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + Word16 *Q_bwe_exc, + Word16 *Qx, + Word16 n_mem3, + Word16 prev_Q_bwe_syn2 ); + + void ScaleShapedSHB_fx32( + const Word16 length, /* i : SHB overlap length */ + Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ + Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ + const Word16 *subgain_fx, /* i : subframe gain Q15 */ + const Word32 frame_gain_fx, /* i : frame gain */ + const Word16 *win_fx, /* i : window Q15 */ + const Word16 *subwin_fx, /* i : subframes window Q15 */ + Word16 *Q_inp, + Word16 *Q_new ); + + void ScaleShapedWB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o : synthesized shb signal */ + Word16 *overlap, /* i/o : buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + const Word16 Q_bwe_exc, + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ + Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ + ); + + void non_linearity_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ + ); + + void non_linearity_ivas_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ + ); + + void interp_code_5over2_fx( + const Word16 inp_code[], /* i : i vector */ + Word16 interp_code[], /* o : output vector */ + const Word16 inp_length /* i : length of i vector */ + ); + + void interp_code_4over2_fx( + const Word16 inp_code_fx[], /* i : i vector Qx */ + Word16 interp_code_fx[], /* o : output vector Qx */ + const Word16 inp_length /* i : length of i vector */ + ); + + void wb_tbe_extras_reset_synth_fx( + Word16 state_lsyn_filt_shb[], + Word16 state_lsyn_filt_dwn_shb[], + Word16 state_32and48k_WB_upsample[], + Word16 state_resamp_HB[] ); + + void elliptic_bpf_48k_generic_fx( + const Word16 element_mode, + Word16 IsUpsampled3, + Word16 input_fx[], /* i : input signal Q_input_fx*/ + Word16 *Q_input_fx, + Word16 output_fx[], /* o : output signal */ + Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ + Word16 memory_fx_Q[], + const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ + ); + + void synthesise_fb_high_band_fx( + const Word16 excitation_in[], /* i : full band excitation */ + Word16 Q_fb_exc, + Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ + const Word32 fb_exc_energy, /* i : full band excitation energy */ + const Word16 ratio, /* i : energy ratio */ + const Word16 L_frame, /* i : ACELP frame length */ + const Word16 bfi, /* i : fec flag */ + Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ + Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ + Word16 bpf_memory_Q[], + Word16 Qout, + Word16 element_mode ); + + void prep_tbe_exc_fx( + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : subframe index */ + const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ + const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 voice_fac_fx, /* i : voicing factor Q15*/ + Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ + Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ + const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ + const Word16 code_preQ_fx[], /* i : prequantizer excitation */ + const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ + const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ + const Word16 T0, /* i : integer pitch variables Q0 */ + const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ + const Word16 coder_type, /* i : coding type */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ + ); + + /*! r: Formant filter strength [0,1] */ + Word16 swb_formant_fac_fx( + const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ + Word16 *tilt_mem /* i/o: Tilt smoothing memory */ + ); + + void wb_tbe_extras_reset_fx( + Word16 mem_genSHBexc_filt_down_wb2[], + Word16 mem_genSHBexc_filt_down_wb3[] ); + + Word16 get_tbe_bits_fx( + const Word32 total_brate, /* o : TBE bit consumption per frame */ + const Word16 bwidth, /* i : overall bitrate */ + const Word16 rf_mode /* i : bandwidht mode */ + ); + + UWord32 intLimCDivPos_fx( + UWord32 NUM, /* Qx */ + Word16 DEN /* Q0 */ + ); + + Word16 shrtCDivSignedApprox( + const Word16 num, /* Q0 */ + const Word16 den /* Q0 */ + ); + + void obtainEnergyQuantizerDensity_fx( + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ + ); + + void dsDirac2Dirac_fx( + const Word16 dsDiracIndex, /* Q0 */ + Word16 *diracs /* Q0 */ + ); + + void dsDiracPerQuanta_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ + ); + + void QuantaPerDsDirac_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ + const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ + Word16 *Quanta /* i : Quanta Q0*/ + ); + + void conservativeL1Norm_fx( + const Word16 L, /* i : Length of vector segment Q0*/ + const Word16 Qvec, /* i : Assigned number of quanta Q0*/ + const Word16 Fcons, /* i : Conservative rounding flag Q0*/ + const Word16 Qavail, /* i : Input quanta remaining Q0*/ + const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ + const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ + Word16 *Dvec, /* o : actual number of diracs Q0*/ + Word16 *Qspare, /* o : Output quanta remaining Q0*/ + Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ + Word16 *Dspecplus /* o : Output number of diracs Q0*/ + ); + + void bandBitsAdjustment_fx( + const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ + const UWord32 INTrc, /* i : Range coder state Q0*/ + const Word16 Bavail, /* i : Available number of quanta Q3*/ + const Word16 Nbands, /* i : Number of bands Q0*/ + const Word16 D, /* i : Remaining number of bands to encode Q0*/ + const Word16 L, /* i : Size of current band Q0*/ + const Word16 Bband, /* i : Quanta allocation for current band Q0*/ + const Word16 Breserv, /* i : Quanta reservoir Q0*/ + Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ + Word16 *Brem, /* o : Quanta remaining Q0*/ + Word16 *Breservplus /* o : Quanta pool size Q0*/ + ); + + void densityAngle2RmsProjDec_fx( + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ + ); + + void densityAngle2RmsProjEnc_fx( + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ + ); + + void NearOppSplitAdjustment_fx( + const Word16 qband, /* i : quanta for current band Q0*/ + const Word16 qzero, /* i : range coder finalization quanta Q0*/ + const Word16 Qac, /* i : range coder current quanta Q0*/ + const UWord32 INTac, /* i : range coder state Q0*/ + const Word16 qglobal, /* i : quanta input Q0*/ + const Word16 FlagCons, /* i : conservative rounding flag Q0*/ + const Word16 Np, /* i : number of parts Q0*/ + const Word16 Nhead, /* i : first part Q0*/ + const Word16 Ntail, /* i : remaining parts Q0*/ + const Word16 Nnear, /* i : length of near component Q0*/ + const Word16 Nopp, /* i : length of opposite component Q0*/ + Word16 oppRQ3, /* i : ratio Q0*/ + Word16 *qnear, /* o : quantized near Q0*/ + Word16 *qopp, /* o : quantized opposite Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ + ); + + void apply_gain_fx( + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 *band_start, /* i : Sub band start indices Q0 */ + const Word16 *band_end, /* i : Sub band end indices Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gains, /* i : Band gain vector Q12 */ + Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ + ); + + void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ + ); + + void srt_vec_ind16_fx( + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ + Word16 length /* Q0 */ + ); + + /* o: Angle between 0 and PI/2 radian (Q14) */ + Word16 atan2_fx( + const Word32 y, /* i : near side (Argument must be positive) (Q15) */ + const Word32 x /* i : opposite side (Q15) */ + ); + + /* o: Number of bits needed Q0*/ + Word16 rc_get_bits2_fx( + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ + ); + + void rangeCoderFinalizationFBits_fx( + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ + ); + + ivas_error DTFS_new_fx( + DTFS_STRUCTURE **dtfs_out ); + + void DTFS_copy_fx( + DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ + DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ + ); + + void DTFS_sub_fx( + DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ + DTFS_STRUCTURE X1, /* i: DTFS i 1 */ + DTFS_STRUCTURE X2 /* i: DTFS i 2 */ + ); + + Word16 DTFS_alignment_full_fx( + DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ + DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ + Word16 ph_offset_fx, /* i : resolution */ + Word16 *S_fx, + Word16 *C_fx, + Word16 FR_flag ); + + void DTFS_phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + + void Q2phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + + void DTFS_zeroPadd_fx( + Word16 N_fx, + DTFS_STRUCTURE *X_fx ); + + void DTFS_to_fs_fx( + const Word16 *x, /* i : time domain signal */ + Word16 N, /* i : Length of i vector */ + DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ + const Word16 Fs, /* i : sampling rate */ + const Word16 FR_flag, /* i : FR flag */ + Word16 *S_fx, + Word16 *C_fx ); + + void DTFS_zeroFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + + void DTFS_poleFilter_fx_9( + DTFS_STRUCTURE *X_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + + void DTFS_adjustLag_fx( + DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ + Word16 N_fx /* i : Target lag */ + ); + + Word32 DTFS_getEngy_fx( + DTFS_STRUCTURE *X_fx ); + + Word32 DTFS_getEngy_P2A_fx( + DTFS_STRUCTURE *X_fx ); + + void DTFS_car2pol_fx( + DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ + ); + + Word32 DTFS_setEngyHarm_fx( + Word16 f1_fx, /* i : lower band freq of i to control energy */ + Word16 f2_fx, /* i : upper band freq of i to control energy */ + Word16 g1_fx, /* i : lower band freq of output to control energy */ + Word16 g2_fx, /* i : upper band freq of output to control energy */ + Word32 en2_fx, /* i : Target Energy to set the DTFS to */ + Word16 Qen2_fx, /* i : Input Q format for en2 */ + Word16 *Qa_fx, /* i : Output Q format for x->a */ + DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ + ); + + void DTFS_to_erb_fx( + const DTFS_STRUCTURE X_fx, /* i : DTFS i */ + Word16 *out_fx /* o : ERB output */ + ); + + void erb_slot_fx( + Word16 lag_fx, /* i : i lag */ + Word16 *out_fx, /* o : ERB slots */ + Word16 *mfreq_fx, /* i : ERB frequencies */ + Word16 num_erb_fx /* i : number of ERBs */ + ); + + void DTFS_erb_inv_fx( + Word16 *in_fx, /* i : ERB inpt */ + Word16 *slot_fx, /* i : ERB slots filled based on lag */ + Word16 *mfreq_fx, /* i : erb frequence edges */ + DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ + Word16 num_erb_fx /* i : Number of ERB bands */ + ); + + void erb_add_fx( + Word16 *curr_erb_fx, /* i/o: current ERB */ + Word16 l_fx, /* i : current lag */ + const Word16 *prev_erb_fx, /* i : previous ERB */ + Word16 pl_fx, /* i : previous lag */ + const Word16 *index_fx, /* i : ERB index */ + Word16 num_erb_fx /* i : number of ERBs */ + ); + + void quant_target_fx( + DTFS_STRUCTURE *X_fx, + const Word16 *curr_lpc, + Word16 *w, + Word16 *target, + Word16 *sin_tab, + Word16 *cos_tab ); + + ivas_error WIsyn_fx( + DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ + DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ + const Word16 *curr_lpc_fx, /* i : LPC */ + Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ + Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ + const Word16 N, /* i : Number of output samples to generate */ + const Word16 FR_flag, /* i : called for post-smoothing in FR */ + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2 ); + + Word16 ppp_extract_pitch_period_fx( + const Word16 *in, /* i : i residual */ + Word16 *out, /* o : output residual */ + Word16 l, /* i : lag */ + Word16 *out_of_bound, /* o : out of bound flag */ + Word16 Qres ); + + void DTFS_peaktoaverage_fx( + DTFS_STRUCTURE X_fx, /* i : DTFS */ + Word32 *pos_fx, /* o : positive peak to ave */ + Word16 *Qpos, /* o : positive peak to ave Q format */ + Word32 *neg_fx, /* o : negative peak to ave */ + Word16 *Qneg /* o : negative peak to ave Q format */ + ); + + void rshiftHarmBand_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband_fx, + Word16 hband_fx, + Word16 shift_fx ); + + void GetSinCosTab_fx( + Word16 L, + Word16 *sinTab, + Word16 *cosTab ); + + void r_fft_4_fx( + Word16 *farray_ptr_fx, + Word16 size, + Word16 stage, + Word16 isign ); + + void copy_phase_fx( + DTFS_STRUCTURE *X1_fx, + DTFS_STRUCTURE X2_fx, + DTFS_STRUCTURE *retX_fx ); + + Word32 getSpEngyFromResAmp_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband, + Word16 hband, + const Word16 *curr_lpc, + Word16 *sin_tab, + Word16 *cos_tab ); + + void DTFS_poleFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + + void poleFilter_setup_fx( + const Word16 *LPC, + Word16 N, + DTFS_STRUCTURE X_fx, + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + + Word32 DTFS_getEngy_band_wb_fx( + DTFS_STRUCTURE X_fx, + Word16 lband, + Word16 hband ); + + void InitTnsConfiguration( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void InitTnsConfiguration_ivas_fx( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void ApplyTnsFilter( + STnsConfig const *pTnsConfig, + STnsData const *pTnsData, + Word32 spectrum[], + const Word8 fIsAnalysis ); + + Word16 ITF_Detect_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + + Word16 ITF_Detect_ivas_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); -Word16 L_norm_arr( const Word32 *arr, Word16 size ); -Word16 norm_arr( Word16 *arr, Word16 size ); -Word16 W_norm_arr( Word64 *arr, Word16 size ); - -Word16 get_min_scalefactor( Word32 x, Word32 y ); - -Flag is_zero_arr( Word32 *arr, Word16 size ); -Flag is_zero_arr16( Word16 *arr, Word16 size ); -Flag is_zero_arr64( Word64 *arr, Word16 size ); - -void edct2_fx_ivas( - const Word16 n, - const Word16 isgn, - Word32 *in, - Word32 *a, - const Word16 *ip, - const Word16 *w ); - -void edct2_fx( - Word16 n, - Word16 isgn, - Word16 *in, - Word32 *a, - Word16 *q, - const Word16 *ip, - const Word16 *w ); - -void DoRTFT160_16fx( - Word16 x[], /* i/o : real part of i and output data */ - Word16 y[] /* i/o : imaginary part of i and output data */ -); - -void DoRTFT320_16fx( - Word16 *x, /* i/o : real part of i and output data */ - Word16 *y /* i/o : imaginary part of i and output data */ -); - -void DoRTFT128_16fx( - Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ - Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ -); - -void fft3_fx( - const Word16[], - Word16[], - const Word16 ); - -void ifft3_fx( - const Word16[], - Word16[], - const Word16 ); - -void fft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); -void ifft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); - -void r_fft_fx_lc( - const Word16 *phs_tbl, /* i : Table of phase */ - const Word16 SIZE, /* i : Size of the FFT */ - const Word16 SIZE2, /* i : Size / 2 */ - const Word16 NUM_STAGE, /* i : Number of stage */ - const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - const Word16 isign /* i : 1=fft, otherwize it's ifft */ -); - -void cldfbAnalysis_fx( - HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ - Word32 **cldfbReal, /*!< Pointer to real subband slots */ - Word32 **cldfbImag, /*!< Pointer to imag subband slots */ - CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - const Word16 *timeIn, /*!< Time signal */ - const Word16 timeIn_e, /*!< Time signal */ - const Word16 nTimeSlots, /*!< Time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ -); - -void cldfbSynthesis_fx( - HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ - Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ - Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ - const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - Word16 *timeOut, /*!< Time signal */ - const Word16 timeOut_e, /*!< Target exponent for output signal */ - const Word16 nTimeSlots, /*!< number of time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ -); - -void configureCldfb( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -ivas_error openCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ - const Word16 type, /* i : analysis or synthesis */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void resampleCldfb( - HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 frameSize, /*!< FrameSize */ - const Word8 firstFrame ); - -Word16 AnalysisPostSpectrumScaling_Fx( - HANDLE_CLDFB_FILTER_BANK cldfbBank, - Word32 **rSubband32, - Word32 **iSubband32, - Word16 **rSubband16, - Word16 **iSubband16, - Word16 *cldfbScale ); - -void analysisCldfbEncoder_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *timeIn, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - -void GetEnergyCldfb( - Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTECEnc ); - -void deleteCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ - -ivas_error cldfb_save_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - -void cldfb_restore_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - -void cldfb_reset_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - -void BITS_ALLOC_init_config_acelp( - const Word32 bit_rate, - const Word16 narrowBand, - const Word16 nb_subfr, - ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ -); - -Word16 BITS_ALLOC_config_acelp( - const Word16 bits_frame, /*i: remaining bit budget for the frame */ - const Word16 coder_type, /*i: coder type */ - ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ - const Word16 narrowband, - const Word16 nb_subfr ); - -Word16 set_ACELP_flag( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate per channel */ - const Word16 idchan, /* i : Channel id */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 cng_type /* i : CNG type */ -); - -void syn_12k8_fx( - Word16 L_frame, - const Word16 *Aq, /* i : LP filter coefficients Q12 */ - const Word16 *exc, /* i : i signal Q_exc */ - Word16 *synth, /* o : output signal Q_syn */ - Word16 *mem, /* i/o: initial filter states Q_syn */ - const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ - /* 1 --> update of memory */ - const Word16 Q_exc, /* i : Excitation scaling Q0 */ - const Word16 Q_syn /* i : Synthesis scaling Q0 */ -); - -/* o : tilt of the code Q15 */ -Word16 est_tilt_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ + void ITF_Apply_fx( + Word32 spectrum[], + Word16 startLine, + Word16 stopLine, + const Word16 *A, + Word16 Q_A, + Word16 curr_order ); + + void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); + + Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + + Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + + Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); + + Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); + + Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + + Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + + Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + + void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); + + Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); + + Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); + + Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); + + Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); + + Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); + + Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); + + Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); + + void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); + + void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); + + void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); + + void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); + + void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); + + void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); + void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); + + void ResetTnsData( STnsData *pTnsData ); + + void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); + + /*========================================================================================================/ + gp_clips_fx.c + /========================================================================================================*/ + + void init_gp_clip_fx( + Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + ); + + Word16 gp_clip_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 coder_type, /* i : type of coder Q0*/ + const Word16 xn[], /* i : target vector Q_new*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Q_new /* i : scaling factor */ + ); + + void gp_clip_test_isf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ + ); + + void gp_clip_test_gain_pit_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ + Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ + ); + + Word16 Mode2_gp_clip_fx( + const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 coder_type, /* i : type of coder Q0 */ + const Word16 xn[], /* i : target vector Q_xn */ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ + /* mem[0]: Q0 */ + /* mem[1]: 1Q14 */ + /* mem[2]: 8Q7 */ + /* mem[3]: Q0 (integer) */ + /* mem[4]: Q14 */ + /* mem[5]: Q14 */ + const Word16 L_subfr, /* Q0 */ + const Word16 Q_xn /* i : scaling factor of vector xn[] */ + ); + + void gp_clip_test_lsf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 m /* i : dimension of lsf Q0*/ + ); + + void gp_clip_test_lsf_ivas_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ + ); + + /*========================================================================================================/ + nelp_enc_fx.c + /========================================================================================================*/ + + void quantize_uvg_fx( + Word16 *G, + Word16 *iG1, + Word16 *iG2, + Word16 *quantG, + Word16 bandwidth ); + + void nelp_encoder_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + + void nelp_encoder_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + + void swb_bwe_enc_lr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ + ); + + void swb_bwe_enc_lr_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ + ); + + void isf_enc_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + Word16 *isf_new, /* i/o: quantized ISF vector */ + Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ + Word16 *Aq /* o : quantized A(z) for 4 subframes */ + ); + + Word16 detect_transient_fx( + const Word16 *in_fx, /*Q_new */ + const Word16 L, /*Q0*/ + Word16 Q_new, + Encoder_State *st_fx ); + + Word16 tcxGetNoiseFillingTilt( + const Word16 A[], + const Word16 lpcorder, + const Word16 L_frame, + const Word16 mode, + Word16 *noiseTiltFactor ); + + void tcxFormantEnhancement( + Word16 xn_buf[], + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + + void tcxFormantEnhancement_with_shift( + Word16 xn_buf[], + Word16 *xn_buf_e, + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + + void tcxInvertWindowGrouping( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word32 xn_buf[], + Word32 spectrum[], + const Word16 L_frame, + const Word8 fUseTns, + const Word16 last_core, + const Word16 index, + const Word16 frame_cnt, + const Word16 bfi ); + + void permute_fx( + Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ + const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ + ); + + void init_lvq_fx( + Word32 offset_scale1[][MAX_NO_SCALES + 1], + Word32 offset_scale2[][MAX_NO_SCALES + 1], + Word32 offset_scale1_p[][MAX_NO_SCALES + 1], + Word32 offset_scale2_p[][MAX_NO_SCALES + 1], + Word16 no_scales[][2], + Word16 no_scales_p[][2] ); + + Word16 deindex_lvq_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ + Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : offset for first subvector */ + Word32 *p_offset_scale2, /* i : offset for the second subvector */ + Word16 *p_no_scales ); + + Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ + ); + + Word16 deindex_lvq_cng_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q9*/ + Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + + Word16 deindex_lvq_cng_ivas_fx( + Word16 *index, /* i: index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o: decoded codevector Q9 */ + Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ + Word16 no_bits /* i: number of bits for lattice */ + ); + + Word16 lsp_convert_poly_fx( + Word16 w[], /* i/o: LSP or ISP parameters */ + const Word16 L_frame, /* i : flag for up or down conversion */ + const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ + ); + + void CNG_exc_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 L_frame, /* i : length of the frame */ + Word32 *Enew, /* i/o: decoded SID energy Q6 */ + Word16 *seed, /* i/o: random generator seed */ + Word16 exc[], /* o : current non-enhanced excitation Q_new */ + Word16 exc2[], /* o : current enhanced excitation Q_new */ + Word32 *lp_ener, /* i/o: LP filtered E */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ + Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ + Word16 bwe_exc[], /* o : excitation for SWB TBE */ + const Word16 allow_cn_step, /* i : allow CN step */ + Word16 *last_allow_cn_step, /* i/o: last allow step */ + const Word16 OldQ_exc, /* i : Old excitation scaling */ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 num_ho, /* i : number of selected hangover frames */ + Word32 q_env[], + Word32 *lp_env, + Word32 *old_env, + Word16 *exc_mem, + Word16 *exc_mem1, + Word16 *sid_bw, + Word16 *cng_ener_seed1, + Word16 exc3[], + Word16 Opt_AMR_WB, + const Word16 element_mode /* i : IVAS Element mode */ + ); + + void cng_params_postupd_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[] /* i/o: Envelope buffer */ + ); + + void cng_params_postupd_ivas_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ + ); + + void cng_params_upd_fx( + const Word16 lsp_new[], /* i : LSP parameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate /* i : Last active bit rate Q0 */ + ); + + void cng_params_upd_ivas_fx( + const Word16 lsp_new[], /* i : LSP aprameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate, /* i : Last active bit rate Q0 */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ + ); + + Word16 get_cng_mode( + const Word32 last_active_brate /* i : last active bitrate */ + ); + + /*! r: codec mode */ + Word16 get_codec_mode( + const Word32 total_brate /* i : total bitrate */ + ); + + Word16 getTcxonly( + const Word32 total_brate /* i : total bitrate */ + ); + + Word16 getTcxonly_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ + ); + + Word16 getCtxHm( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_flag /* i : flag to signal the RF mode */ + ); + + Word16 getResq( + const Word32 total_brate /* i : total bitrate */ + ); + + Word16 getTnsAllowed( + const Word32 total_brate, /* i : total bitrate */ + const Word16 igf, /* i : flag indicating IGF activity*/ + const Word16 element_mode /* i : IVAS element mode */ + ); + + Word16 getRestrictedMode( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ + ); + + Word16 getMdctWindowLength_fx( + const Word16 fscale ); + + Word16 sr2fscale_fx( + const Word32 sr_core /* i : internal sampling rate */ + ); + + Word32 getCoreSamplerateMode2( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ + ); + + Word16 getTcxBandwidth( + const Word16 bandwidth ); + + Word16 getIgfPresent_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + Word16 getCnaPresent_fx( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth /* i : audio bandwidth */ + ); + + Word16 getTcxLtp( + const Word32 sr_core /* i : internal sampling rate */ + ); + + Word16 initPitchLagParameters( + const Word32 sr_core, + Word16 *pit_min, + Word16 *pit_fr1, + Word16 *pit_fr1b, + Word16 *pit_fr2, + Word16 *pit_max ); + + Word16 getNumTcxCodedLines( + const Word16 bwidth ); + + Word16 getTcxLpcShapedAri( + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const Word16 element_mode /* i : IVAS element mode */ + ); + + void mdct_window_sine( + PWord16 *window, /* Qx */ + Word16 n /* Q0 */ + ); + + void mdct_window_sine_IVAS_updated( + PWord16 *window, /* Qx */ + const Word32 Fs, /* Q0 */ + const Word16 n, /* Q0 */ + const Word16 window_type, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void mdct_window_aldo( + Word16 *window1, /* Q15 */ + PWord16 *window1_trunc, /* Q15 */ + PWord16 *window2, /* Q15 */ + Word16 n /* Q0 */ + ); + + Word16 getInvFrameLen( + const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ + + void tcx_get_windows( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ + const Word16 left_mode, /* i: overlap mode of left window half */ + const Word16 right_mode, /* i: overlap mode of right window half */ + Word16 *left_overlap, /* o: left overlap length */ + const PWord16 **left_win, /* o: left overlap window */ + Word16 *right_overlap, /* o: right overlap length */ + const PWord16 **right_win, /* o: right overlap window */ + const Word8 fullband /* i: fullband flag */ + ); + + void WindowSignal( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 offset, /* i : left folding point offset relative to the i signal pointer */ + const Word16 left_overlap_mode, /* i : overlap mode of left window half */ + Word16 right_overlap_mode, /* i : overlap mode of right window half */ + Word16 *left_overlap_length, /* o : TCX window left overlap length */ + Word16 *right_overlap_length, /* o : TCX window right overlap length */ + const Word16 in[], /* i : i signal */ + Word16 *L_frame, /* i/o: frame length */ + Word16 out[], /* o : output windowed signal */ + const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ + const Word8 fullband /* i : fullband flag */ + ); + + void tcx_windowing_synthesis_current_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 left_rect, /* i: left part is rectangular */ + const Word16 left_mode, /* i: overlap mode of left window half */ + Word16 *acelp_zir, /* i: acelp ZIR */ + const Word16 *old_syn, + const Word16 *syn_overl, + const Word16 *A_zir, + const PWord16 *window_trans, + Word16 acelp_zir_len, + const Word16 acelp_mem_len, + const Word16 last_core_bfi, /* i : last core */ + const Word8 last_is_cng, + const Word16 fullbandScale ); + + void tcx_windowing_synthesis_past_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ + ); + + void lpc2mdct( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 *mdct_gains, + Word16 *mdct_gains_exp, + Word16 *mdct_inv_gains, + Word16 *mdct_inv_gains_exp, + const Word16 length, + const Word16 noInverse ); + + void lpc2mdct_2( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 mdct_gains_fx[], + Word16 mdct_gains_e[], + Word16 mdct_inv_gains_fx[], + Word16 mdct_inv_gains_e[], + const Word16 length ); + + void mdct_shaping( + Word32 x[], + const Word16 lg, + const Word16 gains[], + const Word16 gains_exp[] ); + + void mdct_shaping_16( + const Word16 x[], + const Word16 lg, + const Word16 lg_total, + const Word16 gains[], + const Word16 gains_exp[], + Word16 gains_max_exp, + Word32 y[] ); + + void mdct_noiseShaping_ivas_fx( + Word32 x_fx[], + Word16 *x_e, + const Word16 lg, + const Word16 gains_fx[], + const Word16 gains_exp[] ); + + void mdct_noiseShaping_interp( + Word32 x[], + const Word16 lg, + Word16 gains[], + Word16 gains_exp[] ); + + void PsychAdaptLowFreqDeemph( + Word32 x[], + const Word16 lpcGains[], + const Word16 lpcGains_e[], + Word16 lf_deemph_factors[] ); + + void AdaptLowFreqDeemph( + Word32 x[], + Word16 x_e, + Word16 tcx_lpc_shaped_ari, + Word16 lpcGains[], + Word16 lpcGains_e[], + const Word16 lg, + Word16 lf_deemph_factors[] ); + + void tcx_noise_filling( + Word32 *Q, + Word16 Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ + ); + + void tcx_noise_filling_with_shift( + Word32 *Q, + Word16 *Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ + ); + + void InitTnsConfigs( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void InitTnsConfigs_ivas_fx( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + + void SetAllowTnsOnWhite( + STnsConfig tnsConfig[2][2], + const Word8 allowTnsOnWhite ); + + void SetTnsConfig( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + const Word16 isTCX20, + const Word16 isAfterACELP ); + + void tcx_get_gain( + Word32 *x, /* i: spectrum 1 */ + Word16 x_e, /* i: spectrum 1 exponent */ + Word32 *y, /* i: spectrum 2 */ + Word16 y_e, /* i: spectrum 2 exponent */ + Word16 n, /* i: length */ + Word16 *gain, /* o: gain */ + Word16 *gain_e, /* o: gain exponent */ + Word32 *en_y, /* o: energy of y (optional) */ + Word16 *en_y_e /* o: energy of y exponent (optional) */ + ); + + void init_TCX_config( + TCX_CONFIG_HANDLE hTcxCfg, + Word16 L_frame, + Word16 fscale, + Word16 L_frameTCX, + Word16 fscaleFB ); + + void resetTecDec_Fx( + TEC_DEC_HANDLE hTecDec ); + + void resetTecEnc_Fx( + TEC_ENC_HANDLE hTECEnc, + Word16 flag ); + + void calcGainTemp_TBE_Fx( + Word32 **pCldfbRealSrc_Fx, + Word32 **pCldfbImagSrc_Fx, + Word16 cldfb_exp, + Word16 *loBuffer_Fx, + const Word16 startPos, /*!< Start position of the current envelope. */ + const Word16 stopPos, /*!< Stop position of the current envelope. */ + const Word16 lowSubband, /* lowSubband */ + Word16 *pGainTemp_m, + Word16 *pGainTemp_e, + const Word16 code ); + + Word16 procTecTfa_TBE_Fx( + Word16 *hb_synth_Fx, + Word16 hb_synth_fx_exp, + Word16 *gain_m, + Word16 *gain_e, + Word16 flat_flag, + Word16 last_core, + Word16 l_subfr, + Word16 code ); + + void calcHiEnvLoBuff_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + const Word16 nSfb, /*!< Number of scalefactors. */ + Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 pCldfbPow_FixScale ); + + void calcLoEnvCheckCorrHiLo_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, + Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 *corrFlag /*int* corrFlag*/ + ); + + void tecEnc_TBE_fx( + Word16 *corrFlag, + const Word16 *voicing, + const Word16 coder_type ); + + void set_TEC_TFA_code_fx( + const Word16 corrFlag, + Word16 *tec_flag, + Word16 *tfa_flag ); + + void TCX_MDCT( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void TCX_MDST( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void TCX_MDCT_Inverse( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ + ); + + void TCX_MDST_Inverse_fx( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r /* Q0 */ + ); + + void TCX_MDXT_Inverse_fx( + const Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type /* Q0 */ + ); + + void edct_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ + ); + + void edct_ivas_fx( + const Word32 *x, /* i : input signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length Q0*/ + Word16 *q /* i : Q value of input signal */ + ); + + void edst_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ + ); + + void edct_16fx( + const Word16 *x, /* i : i signal Qx */ + Word16 *y, /* o : output transform Qx */ + Word16 length, /* i : length */ + Word16 bh, /* bit-headroom */ + const Word16 element_mode ); + + void iedct_short_fx( + const Word32 *in, /* i : i vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 segment_length /* i : length */ + ); + + void edxt_fx( + const Word32 *x, /* i : input signal */ + Word32 *y, /* o : output transform */ + const Word16 length, /* i : length */ + const UWord16 kernelType, /* i : kernel type (0 - 3) */ + const UWord16 synthesis /* i : nonzero for inverse */ + ); + + void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); + void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); + void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); + + void DoRTFTn_fx( + Word32 *x, /* i/o : real part of i and output data */ + Word32 *y, /* i/o : imaginary part of i and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ + ); + + void DoRTFT480_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT320_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT160_fx( + Word32 x[], /* i/o: real part of input and output data */ + Word32 y[] /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT128_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT120_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT80_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT40_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + void DoRTFT20_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ + ); + + Word16 RFFTN_fx( + Word32 *data, + const Word16 *sine_table, + const Word16 len, + const Word16 sign ); + + void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const Word16 length ); + + void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 length, /* i : length of fft */ + const Word16 s /* i : sign */ + ); + + void rfft_fx( + Word32 *x, /* i/o: values */ + const Word16 *w, /* i : window */ + const Word16 length, /* i : length of fft */ + const Word16 isign /* i : sign */ + ); + + void DoRTFTn_fx_ivas( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ + ); + + + Word16 find_guarded_bits_fx( const Word32 n ); + + Word16 L_norm_arr( const Word32 *arr, Word16 size ); + Word16 norm_arr( Word16 *arr, Word16 size ); + Word16 W_norm_arr( Word64 *arr, Word16 size ); + + Word16 get_min_scalefactor( Word32 x, Word32 y ); + + Flag is_zero_arr( Word32 *arr, Word16 size ); + Flag is_zero_arr16( Word16 *arr, Word16 size ); + Flag is_zero_arr64( Word64 *arr, Word16 size ); + + void edct2_fx_ivas( + const Word16 n, + const Word16 isgn, + Word32 *in, + Word32 *a, + const Word16 *ip, + const Word16 *w ); + + void edct2_fx( + Word16 n, + Word16 isgn, + Word16 *in, + Word32 *a, + Word16 *q, + const Word16 *ip, + const Word16 *w ); + + void DoRTFT160_16fx( + Word16 x[], /* i/o : real part of i and output data */ + Word16 y[] /* i/o : imaginary part of i and output data */ + ); + + void DoRTFT320_16fx( + Word16 *x, /* i/o : real part of i and output data */ + Word16 *y /* i/o : imaginary part of i and output data */ + ); + + void DoRTFT128_16fx( + Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ + Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ + ); + + void fft3_fx( + const Word16[], + Word16[], + const Word16 ); + + void ifft3_fx( + const Word16[], + Word16[], + const Word16 ); + + void fft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); + void ifft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); + + void r_fft_fx_lc( + const Word16 *phs_tbl, /* i : Table of phase */ + const Word16 SIZE, /* i : Size of the FFT */ + const Word16 SIZE2, /* i : Size / 2 */ + const Word16 NUM_STAGE, /* i : Number of stage */ + const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + const Word16 isign /* i : 1=fft, otherwize it's ifft */ + ); + + void cldfbAnalysis_fx( + HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ + Word32 **cldfbReal, /*!< Pointer to real subband slots */ + Word32 **cldfbImag, /*!< Pointer to imag subband slots */ + CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + const Word16 *timeIn, /*!< Time signal */ + const Word16 timeIn_e, /*!< Time signal */ + const Word16 nTimeSlots, /*!< Time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ + ); + + void cldfbSynthesis_fx( + HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ + Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ + Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ + const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + Word16 *timeOut, /*!< Time signal */ + const Word16 timeOut_e, /*!< Target exponent for output signal */ + const Word16 nTimeSlots, /*!< number of time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ + ); + + void configureCldfb( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ + const Word32 sampling_rate /* i : sampling rate */ + ); + + ivas_error openCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ + const Word16 type, /* i : analysis or synthesis */ + const Word32 sampling_rate /* i : sampling rate */ + ); + + void resampleCldfb( + HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frameSize, /*!< FrameSize */ + const Word8 firstFrame ); + + Word16 AnalysisPostSpectrumScaling_Fx( + HANDLE_CLDFB_FILTER_BANK cldfbBank, + Word32 **rSubband32, + Word32 **iSubband32, + Word16 **rSubband16, + Word16 **iSubband16, + Word16 *cldfbScale ); + + void analysisCldfbEncoder_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *timeIn, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + + void GetEnergyCldfb( + Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTECEnc ); + + void deleteCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ + + ivas_error cldfb_save_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + + void cldfb_restore_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + + void cldfb_reset_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + + void BITS_ALLOC_init_config_acelp( + const Word32 bit_rate, + const Word16 narrowBand, + const Word16 nb_subfr, + ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ + ); + + Word16 BITS_ALLOC_config_acelp( + const Word16 bits_frame, /*i: remaining bit budget for the frame */ + const Word16 coder_type, /*i: coder type */ + ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ + const Word16 narrowband, + const Word16 nb_subfr ); + + Word16 set_ACELP_flag( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate per channel */ + const Word16 idchan, /* i : Channel id */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 cng_type /* i : CNG type */ + ); + + void syn_12k8_fx( + Word16 L_frame, + const Word16 *Aq, /* i : LP filter coefficients Q12 */ + const Word16 *exc, /* i : i signal Q_exc */ + Word16 *synth, /* o : output signal Q_syn */ + Word16 *mem, /* i/o: initial filter states Q_syn */ + const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ + /* 1 --> update of memory */ + const Word16 Q_exc, /* i : Excitation scaling Q0 */ + const Word16 Q_syn /* i : Synthesis scaling Q0 */ + ); + + /* o : tilt of the code Q15 */ + Word16 est_tilt_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ #ifdef CLEANUP_ACELP_ENC - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #else - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ #endif -); + ); #ifndef CLEANUP_ACELP_ENC -/* o : tilt of the code Q15 */ -Word16 est_tilt_ivas_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + /* o : tilt of the code Q15 */ + Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #ifndef CLEANUP_ACELP_ENC - , - const Word16 flag_tilt /* i : flag for special tilt */ + , + const Word16 flag_tilt /* i : flag for special tilt */ #endif -); + ); #endif -/* o : tilt of the code */ -Word16 Est_tilt2( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ -); - -void E_UTIL_voice_factor( - Word16 *exc, /* i : pointer to the excitation frame Q_new */ - Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* i : innovative codebook Q9 */ - Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ - Word16 *tilt_code, /* o : tilt factor Q15 */ - Word16 L_subfr, /* i : subframe length */ - Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ - Word16 Q_new, /* i : excitation buffer format */ - Word16 shift /* i : scaling to get 12bit */ -); - -void sinq_fx( - const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ - const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ - const Word16 N, /* i : size of output */ - Word16 x[] /* o : output vector Q15*/ -); - -void window_ola_fx( - Word32 *ImdctOut, - Word16 *auOut, - Word16 *Q_sig, - Word16 *OldauOut, - Word16 *Q_old, - const Word16 L, - const Word16 right_mode, - const Word16 left_mode, - const Word16 old_bfi, - const Word16 oldHqVoicing, - Word16 *oldgapsynth ); - -void core_switching_OLA_fx( - Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ - const Word16 last_L_frame, /* i : last L_frame lengthture */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ - Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ - Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ - const Word16 output_frame, /* i : output frame length */ - const Word16 bwidth, /* i : output bandwidth */ - Word16 *Qsynth, - Word16 *Qsubfr ); - -void window_ola_ext_fx( - const Word32 *ImdstOut, /* i : input */ - Word32 *auOut, /* o : output audio */ - Word32 *OldauOut, /* i/o: audio from previous frame */ - const Word16 L, /* i : length */ - const Word16 right_mode, - const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const UWord16 kernel_type /* i : transform kernel type */ -); - -void cb_shape_fx( - const Word16 preemphFlag, /* i : flag for pre-emphasis */ - const Word16 pitchFlag, /* i : flag for pitch sharpening */ - const Word16 scramblingFlag, /* i : flag for phase scrambling */ - const Word16 sharpFlag, /* i : flag for formant sharpening */ - const Word16 formantTiltFlag, /* i : flag for formant tilt */ - const Word16 g1, /* i : formant sharpening numerator weighting */ - const Word16 g2, /* i : formant sharpening denominator weighting */ - const Word16 *p_Aq, /* i : LP filter coefficients */ - Word16 *code, /* i/o: signal to shape */ - const Word16 tilt_code, /* i : tilt of code */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ - const Word16 shift, - const Word16 L_subfr /* i : subframe lenght */ -); - -void longadd( - UWord16 a[], /* i/o: vector of the length lena */ - const UWord16 b[], /* i/o: vector of the length lenb */ - const Word16 lena, /* i/o: length of vector a[] */ - const Word16 lenb /* i/o: length of vector b[] */ -); - -void longshiftright( - UWord16 a[], /* i : vector of the length lena */ - const Word16 b, /* i : number of bit positions to shift right */ - UWord16 d[], /* o : vector of the length lend */ - Word16 lena, /* i : length of vector a[] */ - const Word16 lend /* i : length of vector d[] */ -); - -void longshiftleft( - const UWord16 a[], /* i : vector of the length len */ - const Word16 b, /* i : number of bit positions to shift left */ - UWord16 d[], /* o : vector of the length len */ - const Word16 len /* i : length of vector a[] and d[] */ -); - -void longshr( - UWord32 a[], - Word16 bits, - Word16 len ); - -void bands_and_bit_alloc_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : i signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -void fine_gain_pred_fx( - const Word16 *sfm_start, /* i : Sub band start indices */ - const Word16 *sfm_end, /* i : Sub band end indices */ - const Word16 *sfm_size, /* i : Sub band bandwidths */ - const Word16 *i_sort, /* i : Energy sorting indices */ - const Word16 *K, /* i : Number of pulses per band */ - const Word16 *maxpulse, /* i : Maximum pulse per band */ - const Word16 *R, /* i : Bits per sub band Q3 */ - const Word16 num_sfm, /* i : Number of sub bands */ - Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ - Word16 *y, /* i/o: Quantized vector (int) */ - Word16 *fg_pred, /* o : Predicted fine gains Q12 */ - const Word16 core /* i : Core */ -); - -void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ -); - -void get_max_pulses_fx( - const Word16 *band_start, /* i : Sub band start indices */ - const Word16 *band_end, /* i : Sub band end indices */ - const Word16 *k_sort, /* i : Indices for sorting by energy */ - const Word16 *npulses, /* i : Pulses per sub band */ - const Word16 BANDS, /* i : Number of bands */ - Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ - Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ -); - -void fine_gain_dec_fx( - Decoder_State *st, - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ -); - -/* o : Number of assigned gain bits */ -Word16 assign_gain_bits_fx( - const Word16 core, /* i : HQ core */ - const Word16 BANDS, /* i : Number of bands */ - const Word16 *band_width, /* i : Sub band bandwidth */ - Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *gain_bits_array, /* o : Assigned gain bits */ - Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ -); - -void freq_dnw_scaling_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 coder_type, /* i : coder type */ - const Word16 noise_lev, /* i : Noise level */ - const Word32 core_brate, /* i : Core bitrate */ - Word16 fy_norm[], /* i/o: Frequency quantized parameter */ - Word16 Qx, /* Q format of fy_norm*/ - const Word16 L_frame /* i : frame length */ -); + /* o : tilt of the code */ + Word16 Est_tilt2( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ + ); + + void E_UTIL_voice_factor( + Word16 *exc, /* i : pointer to the excitation frame Q_new */ + Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* i : innovative codebook Q9 */ + Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ + Word16 *tilt_code, /* o : tilt factor Q15 */ + Word16 L_subfr, /* i : subframe length */ + Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ + Word16 Q_new, /* i : excitation buffer format */ + Word16 shift /* i : scaling to get 12bit */ + ); + + void sinq_fx( + const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ + const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ + const Word16 N, /* i : size of output */ + Word16 x[] /* o : output vector Q15*/ + ); + + void window_ola_fx( + Word32 *ImdctOut, + Word16 *auOut, + Word16 *Q_sig, + Word16 *OldauOut, + Word16 *Q_old, + const Word16 L, + const Word16 right_mode, + const Word16 left_mode, + const Word16 old_bfi, + const Word16 oldHqVoicing, + Word16 *oldgapsynth ); + + void core_switching_OLA_fx( + Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ + const Word16 last_L_frame, /* i : last L_frame lengthture */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ + Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ + Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ + const Word16 output_frame, /* i : output frame length */ + const Word16 bwidth, /* i : output bandwidth */ + Word16 *Qsynth, + Word16 *Qsubfr ); + + void window_ola_ext_fx( + const Word32 *ImdstOut, /* i : input */ + Word32 *auOut, /* o : output audio */ + Word32 *OldauOut, /* i/o: audio from previous frame */ + const Word16 L, /* i : length */ + const Word16 right_mode, + const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const UWord16 kernel_type /* i : transform kernel type */ + ); + + void cb_shape_fx( + const Word16 preemphFlag, /* i : flag for pre-emphasis */ + const Word16 pitchFlag, /* i : flag for pitch sharpening */ + const Word16 scramblingFlag, /* i : flag for phase scrambling */ + const Word16 sharpFlag, /* i : flag for formant sharpening */ + const Word16 formantTiltFlag, /* i : flag for formant tilt */ + const Word16 g1, /* i : formant sharpening numerator weighting */ + const Word16 g2, /* i : formant sharpening denominator weighting */ + const Word16 *p_Aq, /* i : LP filter coefficients */ + Word16 *code, /* i/o: signal to shape */ + const Word16 tilt_code, /* i : tilt of code */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ + const Word16 shift, + const Word16 L_subfr /* i : subframe lenght */ + ); + + void longadd( + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ + ); + + void longshiftright( + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ + ); + + void longshiftleft( + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ + ); + + void longshr( + UWord32 a[], + Word16 bits, + Word16 len ); + + void bands_and_bit_alloc_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : i signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); + + void fine_gain_pred_fx( + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + const Word16 *sfm_size, /* i : Sub band bandwidths */ + const Word16 *i_sort, /* i : Energy sorting indices */ + const Word16 *K, /* i : Number of pulses per band */ + const Word16 *maxpulse, /* i : Maximum pulse per band */ + const Word16 *R, /* i : Bits per sub band Q3 */ + const Word16 num_sfm, /* i : Number of sub bands */ + Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ + Word16 *y, /* i/o: Quantized vector (int) */ + Word16 *fg_pred, /* o : Predicted fine gains Q12 */ + const Word16 core /* i : Core */ + ); + + void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ + ); + + void get_max_pulses_fx( + const Word16 *band_start, /* i : Sub band start indices */ + const Word16 *band_end, /* i : Sub band end indices */ + const Word16 *k_sort, /* i : Indices for sorting by energy */ + const Word16 *npulses, /* i : Pulses per sub band */ + const Word16 BANDS, /* i : Number of bands */ + Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ + Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ + ); + + void fine_gain_dec_fx( + Decoder_State *st, + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ + ); + + /* o : Number of assigned gain bits */ + Word16 assign_gain_bits_fx( + const Word16 core, /* i : HQ core */ + const Word16 BANDS, /* i : Number of bands */ + const Word16 *band_width, /* i : Sub band bandwidth */ + Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *gain_bits_array, /* o : Assigned gain bits */ + Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ + ); + + void freq_dnw_scaling_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 coder_type, /* i : coder type */ + const Word16 noise_lev, /* i : Noise level */ + const Word32 core_brate, /* i : Core bitrate */ + Word16 fy_norm[], /* i/o: Frequency quantized parameter */ + Word16 Qx, /* Q format of fy_norm*/ + const Word16 L_frame /* i : frame length */ + ); #ifndef FIX_1904_HARM_GSC_ENC + void highband_exc_dct_in_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 *mfreq_bindiv, /* i : bin per bands tables */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 Diff_len, /* i : number of bin before cut-off frequency */ + Word16 noise_lev, /* i : pulses dynamic */ + Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 *exc_diffQ, /* i : frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ + Word16 nb_subfr, /* i : Number of subframe considered */ + Word16 *exc_dct_in, /* o : dct of residual signal */ + Word16 last_coder_type, /* i : coding type of last frame */ + Word16 *bitallocation_band, /* i : bit allocation flag of each band */ + const Word16 *lsf_new, /* i : LSFs at the end of the frame */ + Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ + Word16 *last_ener, /* i : frequency energy of last frame */ + Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ + Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ + Word16 bfi, /* i : bad frame indicator */ + const Word16 coder_type, /* i : coder type */ + Word16 bwidth, + Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ + Word16 Qexc_diffQ, + Word16 Q_exc, + const Word16 GSC_noisy_speech, + Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); + void highband_exc_dct_in_ivas_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 *mfreq_bindiv, /* i : bin per bands tables */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 Diff_len, /* i : number of bin before cut-off frequency */ + Word16 noise_lev, /* i : pulses dynamic */ + Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 *exc_diffQ, /* i : frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ + Word16 nb_subfr, /* i : Number of subframe considered */ + Word16 *exc_dct_in, /* o : dct of residual signal */ + Word16 last_coder_type, /* i : coding type of last frame */ + Word16 *bitallocation_band, /* i : bit allocation flag of each band */ + const Word16 *lsf_new, /* i : LSFs at the end of the frame */ + Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ + Word16 *last_ener, /* i : frequency energy of last frame */ + Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ + Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ + Word16 bfi, /* i : bad frame indicator */ + const Word16 coder_type, /* i : coder type */ + Word16 bwidth, + Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ + Word16 Qexc_diffQ, + Word16 *Q_exc, + const Word16 GSC_noisy_speech, + Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); +#else void highband_exc_dct_in_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 *mfreq_bindiv, /* i : bin per bands tables */ - Word16 last_bin, /* i : last bin of bit allocation */ - Word16 Diff_len, /* i : number of bin before cut-off frequency */ - Word16 noise_lev, /* i : pulses dynamic */ - Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - Word16 *exc_diffQ, /* i : frequency coefficients of per band */ - Word16 *seed_tcx, /* i : Seed for noise */ - Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ - Word16 nb_subfr, /* i : Number of subframe considered */ - Word16 *exc_dct_in, /* o : dct of residual signal */ - Word16 last_coder_type, /* i : coding type of last frame */ - Word16 *bitallocation_band, /* i : bit allocation flag of each band */ - const Word16 *lsf_new, /* i : LSFs at the end of the frame */ - Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ - Word16 *last_ener, /* i : frequency energy of last frame */ - Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ - Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ - Word16 bfi, /* i : bad frame indicator */ - const Word16 coder_type, /* i : coder type */ - Word16 bwidth, - Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ - Word16 Qexc_diffQ, - Word16 Q_exc, - const Word16 GSC_noisy_speech, - Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); -void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ Word16 last_bin, /* i : last bin of bit allocation */ @@ -5119,5612 +5156,5580 @@ void highband_exc_dct_in_ivas_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); +#endif + + void lsf_dec_bfi( + const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ + Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ + const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ + Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ + const Word16 lsfBase[], /* i : base for differential lsf coding */ + Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ + const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ + Word16 L_frame, + const Word16 last_good, /*!< i : last good received frame */ + const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ + const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ + Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ + Word16 *lsf_cng, /* Q2.56 */ + Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ + const Word16 Last_GSC_pit_band_idx, + const Word16 Opt_AMR_WB, /* i : IO flag */ + const Word8 tcxonly, + const short bwidth /* i: coded bandwidth */ + ); + + Word16 const *PlcGetLsfBase( + Word16 const lpcQuantization, + Word16 const narrowBand, + Word32 const sr_core ); + + /* Create an instance of type FD_CNG */ + ivas_error createFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + + void initFdCngCom( + HANDLE_FD_CNG_COM hFdCngCom, + Word16 scale ); + + /* Delete the instance of type FD_CNG */ + void deleteFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + + /* Initialize the spectral partitioning */ + void initPartitions( + const Word16 *part_in, + const Word16 npart_in, + const Word16 startBand, + const Word16 stopBand, + Word16 *part_out, + Word16 *npart_out, + Word16 *midband, + Word16 *psize, + Word16 *psize_norm, + Word16 *psize_norm_exp, + Word16 *psize_inv, + const Word16 stopBandFR ); + + /* Noise estimation using Minimum Statistics (MS) */ + void compress_range( + Word32 *in, + Word16 in_exp, + Word16 *out, + const Word16 len ); + + void expand_range( + Word16 *in, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + + void expand_range_fx( + Word32 *in, // Q25 + Word32 *out, // exp:out_exp + Word16 *out_exp, + const Word16 len ); + + void expand_range_var_exp( + Word16 *in, + Word16 in_exp, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + + void minimum_statistics( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ + Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ + ); + + void minimum_statistics_fx( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ + Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 enc_dec, /* i : encoder/decoder indicator */ + const Word16 element_mode /* i : IVAS element mode type */ + ); + + /* Apply bitrate-dependant scale */ + void apply_scale( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ + ); + + Word16 apply_scale_ind( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ + ); + void apply_scale_ivas_fx( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize, /* i : Size of scale table */ + Word16 *index ); + + /* Compute the power for each partition */ + void bandcombinepow( + const Word32 *bandpow, /* i : Power for each band */ + const Word16 exp_bandpow, /* i : exponent of bandpow */ + const Word16 nband, /* i : Number of bands */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + const Word16 *psize_inv, /* i : Inverse partition sizes */ + Word32 *partpow, /* o : Power for each partition */ + Word16 *exp_partpow ); + + /* Scale partitions (with smoothing) */ + void scalebands( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + + void scalebands_fx( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + + /* STFT analysis filterbank */ + void AnalysisSTFT( + const Word16 *timeDomainInput, /* i : pointer to time signal */ + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + void AnalysisSTFT_fx( + const Word16 *timeDomainInput, + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + /* STFT synthesis filterbank */ + void SynthesisSTFT( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void SynthesisSTFT_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + Word32 sign_l( + const Word32 x /* i : input value of x */ + ); + + void ivas_updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word32 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ + ); + + /* Random generator with Gaussian distribution with mean 0 and std 1 */ + Word32 rand_gauss( + Word16 *seed ); + + Word16 rand_gauss_fix( + Word16 *x, + Word16 *seed ); + + void lpc_from_spectrum( + HANDLE_FD_CNG_COM hFdCngCom, + const Word16 start, /*i : start band*/ + const Word16 stop, /*i : stop band*/ + const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ + ); + + void msvq_decoder( + const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook vector dimension */ + const Word16 Idx[], /* i : Indices */ + Word16 *uq /* o : quantized vector */ + ); + + void FdCng_exc( + HANDLE_FD_CNG_COM hs, + Word16 *CNG_mode, + Word16 L_frame, + Word16 *lsp_old, + Word16 first_CNG, + Word16 *lsp_CNG, + Word16 *Aq, /* o: LPC coeffs */ + Word16 *lsp_new, /* o: lsp */ + Word16 *lsf_new, /* o: lsf */ + Word16 *exc, /* o: LP excitation */ + Word16 *exc2, /* o: LP excitation */ + Word16 *bwe_exc /* o: LP excitation for BWE */ + ); + + void direct_transform_fx( + const Word32 in32_fx[], + Word32 out32_fx[], + const Word16 is_transient, + const Word16 L, + Word16 *Q, + const Word16 element_mode ); + + void preecho_sb_fx( + const Word32 brate, /* i Q0 : core bit-rate */ + Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ + Word16 q_sig32, /* i Q value for wtda_audio_fx */ + Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ + Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ + const Word16 framelength, /* i Q0 : frame length */ + Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ + Word16 *smoothmem_fx, /* i/o Q15 : memory */ + Word32 *mean_prev_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ + Word16 *wmold_hb_fx, /* i/o Q15 : memory */ + Word16 *prevflag, /* i/o Q0 : flag */ + Word16 *pastpre, /* i/o Q0 : flag */ + const Word16 bwidth /* i Q0 : bandwidth */ + ); + + void Inverse_Transform( + const Word32 *in_mdct, /* i : i MDCT vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 is_transient, /* i : transient flag */ + const Word16 L, /* i : output frame length */ + const Word16 L_inner, /* i : length of the transform */ + const Word16 element_mode /* i : IVAS element mode */ + ); + + void recovernorm_fx( + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ + ); + + Word32 ar_div( Word32 num, Word32 denum ); + + void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); + void ar_encoder_done_fx( PARCODEC arInst ); + void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); + void ar_decoder_done_fx( PARCODEC arInst ); + Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); + + void TCQLSB_fx( + Word16 bcount, + Word32 *abuffer_fx, + Word16 *mbuffer_fx, + Word32 *sbuffer_fx, + Word16 *dpath ); + + void TCQLSBdec_fx( + Word16 *dpath, + Word16 *mbuffer, + Word16 bcount ); + + void RestoreTCQ_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + + void RestoreTCQdec_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + + void InitLSBTCQ_fx( + Word16 *bcount ); + + void SaveTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + + void LoadTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + + Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); + Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); + Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); + + Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); + + void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); + void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); + void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); + void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); + + Word16 GetScale_fx( + Word16 blen, + Word32 bits_fx, + Word32 *surplus_fx ); + + void srt_vec_ind_fx( + const Word32 *linear, + Word32 *srt, + Word16 *I, + Word16 length ); + + void fill_spectrum_fx( + Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ + Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ + const Word16 *R, /* i : number of pulses per band Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + Word16 norm[], /* i : quantization indices for norms Q0 */ + const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ + const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ + const Word16 nf_idx, /* i : noise fill index Q0 */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ + const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ + const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ + const Word16 core_sfm, /* i : index of the end band for core Q0 */ + const Word16 HQ_mode, /* i : HQ mode Q0 */ + Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ + const Word32 L_core_brate, /* i : target bit-rate Q0 */ + Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ + Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ + const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ + const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ + const Word16 *npulses, /* i : number of pulses per band Q0 */ + const Word16 prev_is_transient, /* i : previous transient flag Q0 */ + Word32 *prev_normq, /* i/o: previous norms Q14 */ + Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ + const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ + const Word16 *sfmsize, /* i : Length of bands Q0 */ + const Word16 *sfm_start, /* i : Start of bands Q0 */ + const Word16 *sfm_end, /* i : End of bands Q0 */ + Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ + const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + Word16 *prev_env_Q, + const Word16 num_env_bands, + const Word16 element_mode ); + + void hq_bit_allocation_fx( + const Word32 core_brate, /* i : Core bit-rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + const Word16 hqswb_clas, /* i : HQ class Q0 */ + Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ + const Word16 *normqlg2, /* i : Quantized norms Q0 */ + const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ + const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ + Word16 *noise_level, /* o : HVQ noise level Q15 */ + Word16 *R, /* o : Bit allocation per sub band Q0 */ + Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ + Word16 *sum, /* o : Sum of allocated shape bits Q0 */ + Word16 *core_sfm, /* o : Last coded band in core Q0 */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ + ); + + void map_quant_weight_fx( + const Word16 normqlg2[], /* i : quantized norms Q0*/ + Word16 wnorm[], /* o : weighted norm Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ + ); + + void bitalloc_fx( + Word16 *y, /* i : reordered norm of sub-vectors Q0 */ + Word16 *idx, /* i : reordered sub-vector indices Q0 */ + Word16 sum, /* i : number of available bits Q0 */ + Word16 N, /* i : number of norms Q0 */ + Word16 K, /* i : maximum number of bits per dimension Q0 */ + Word16 *r, /* o : bit-allacation vector Q0 */ + const Word16 *sfmsize, /* i : band length Q0 */ + const Word16 hqswb_clas /* i : signal classification flag Q0 */ + ); + + Word16 BitAllocF_fx( + Word16 *y, /* i : norm of sub-vectors :Q0 */ + Word32 bit_rate, /* i : bitrate :Q0 */ + Word16 B, /* i : number of available bits :Q0 */ + Word16 N, /* i : number of sub-vectors :Q0 */ + Word16 *R, /* o : bit-allocation indicator :Q0 */ + Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ + const Word16 hqswb_clas, /* i : hq swb class */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ + ); + + Word16 BitAllocWB_fx( + Word16 *y, /* i : norm of sub-vectors Q0*/ + Word16 B, /* i : number of available bits Q0*/ + Word16 N, /* i : number of sub-vectors Q0*/ + Word16 *R, /* o : bit-allocation indicator Q0*/ + Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ + ); + + void bitallocsum_fx( + Word16 *R, /* i : bit-allocation vector Q0 */ + const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ + Word16 *sum, /* o : total number of bits allocated Q0 */ + Word16 *Rsubband, /* o : rate per subband Q3 */ + const Word16 num_bits, /* i : number of bits Q0 */ + const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ + const Word16 *sfmsize /* i : band length Q0 */ + ); + + Word16 stab_est_fx( + Word16 etot, /* i : Total energy of the current frame Q8*/ + Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ + Word16 *mem_etot, /* i/o : Total energy memory Q8*/ + Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ + Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ + Word16 *thresh, /* i/o : Detection thresold Q11*/ + Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ + const Word16 vad_flag /* i : VAD flag */ + ); + + void enhancer_fx( + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ + ); + + void enhancer_ivas_fx( + const Word16 codec_mode, /* i : flag indicating Codec Mode */ + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 cbk_index, /* i : */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ + ); + + Word16 E_UTIL_enhancer( + Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + Word16 stab_fac, /* i : LP filter stability measure Q15 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ + Word16 *code, /* i/o: innovation(in: Q9) code_exp */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ + Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ + Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ + Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ + Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ + Word16 coder_type, /* i : coder type */ + Word16 cdk_index, /* i : */ + Word16 L_subfr, /* i : */ + Word16 L_frame, /* i : frame size */ + Word16 Q_new ); + + void phase_dispersion( + const Word32 gain_code, /* i : gain of code 15Q16 */ + const Word16 gain_pit, /* i : gain of pitch Q14 */ + Word16 code[], /* i/o: code vector */ + Word16 *code_e, /* i/o: exponent of code */ + const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ + Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ + Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ + Word16 *prev_state, /* i/o: static memory Q0 */ + Word16 L_subfr /* i : subframe length [40,64] */ + ); + + void tcx_ltp_get_lpc( + Word16 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word16 *A, /* Qx */ + const Word16 order /* Q0 */ + ); + + void tcx_ltp_get_lpc_fx( + Word32 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word32 *A, /* Qx */ + const Word16 order /* Q0 */ + ); + + void predict_signal( + const Word16 excI[], /* i : input excitation buffer Qx*/ + Word16 excO[], /* o : output excitation buffer Qx*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i : fraction of lag Q0*/ + const Word16 frac_max, /* i : max fraction Q0*/ + const Word16 L_subfr /* i : subframe size Q0*/ + ); + + Word16 tcx_ltp_decode_params( + Word16 *ltp_param, /* Q0 */ + Word16 *pitch_int, /* Q0 */ + Word16 *pitch_fr, /* Q0 */ + Word16 *gain, /* Q13 */ + const Word16 pitmin, /* Q0 */ + const Word16 pitfr1, /* Q0 */ + const Word16 pitfr2, /* Q0 */ + const Word16 pitmax, /* Q0 */ + const Word16 pitres /* Q0 */ + ); + + void tcx_ltp_post_fx( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word16 *sig, /* Qx */ + Word16 *tcx_buf /* Qx */ + ); + + void tcx_ltp_post_fx32( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word32 *sig, /* sig_q */ + Word32 *tcx_buf, /* sig_q */ + Word16 sig_q ); + + void Inac_switch_ematch_fx( + Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ + Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ + Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ + const Word16 coder_type, /* i : Coding mode */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 L_frame, /* i : Frame lenght */ + const Word16 Q_exc, /* i : input and output format of exc2 */ + const Word16 bfi, /* i : frame lost indicator */ + const Word16 last_core, /* i : Last core used */ + const Word16 last_codec_mode, /* i : Last codec mode */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 element_mode /* i : element mode */ + ); + + /**< out: Q0 | multiplication factor */ + Word16 IGF_ApplyTransFac( + const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ + const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ + ); + + Word16 IGF_MapBitRateToIndex( + const Word32 brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void IGFCommonFuncsCalcSfbEnergyPowerSpec( + const Word16 startSfb, /**< in: Q0 | start sfb index */ + const Word16 stopSfb, /**< in: Q0 | stop sfb index */ + const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ + Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ + Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ + Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ + Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ + ); + + void IGFCommonFuncsMDCTSquareSpec( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ + ); + + void IGFCommonFuncsMDCTSquareSpec_ivas( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ + ); + + Word16 IGFCommonFuncsIGFConfiguration( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + Word16 IGFCommonFuncsIGFGetCFTables_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ + const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ + Word16 *cf_off_se01, /* o : offset for CF table above */ + const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ + const Word16 **cf_off_se02, /* o : offsets for CF tables above */ + const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ + Word16 *cf_off_se10, /* o : offset for CF table above */ + const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ + const Word16 **cf_off_se11 /* o : offsets for CF tables above */ + ); + + Word32 L_multi31x16_X2( + Word16 xh, + Word16 xl, + Word16 y ); + + Word32 mul_sbc_14bits( + Word32 r, /* Q0 */ + Word16 c /* Q0 */ + ); + + void ham_cos_window( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + + void ham_cos_window_ivas( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + + /* o: Q31 */ + Word32 expfp( + const Word16 x, /* i: mantissa Q-e */ + const Word16 x_e ); /* i: exponent Q0 */ + + void powfp_odd2( + const Word16 base, /* Q15 */ + const Word16 exp, /* Q0 */ + Word16 *pout1, /* Q15 */ + Word16 *pout2 ); /* Q15 */ + + void tcx_arith_scale_envelope( + const Word16 L_spec_core, /* i: number of lines to scale Q0 */ + Word16 L_frame, /* i: number of lines Q0 */ + const Word32 env[], /* i: unscaled envelope Q16 */ + Word16 target_bits, /* i: number of available bits Q0 */ + const Word16 low_complexity, /* i: low-complexity flag Q0 */ + Word16 s_env[], /* o: scaled envelope Q15-e */ + Word16 *s_env_e /* o: scaled envelope exponent Q0 */ + ); + + void tcx_arith_render_envelope( + const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 L_spec, /* Q0 */ + const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o: shaped signal envelope Q16*/ + ); + + /* returns innovation gain Q16 */ + Word32 calc_gain_inov( + const Word16 *code, /* i : algebraic excitation Q9 */ + const Word16 lcode, /* i : Subframe size Q0 */ + Word32 *dotp, /* o : intermediate result Q31-e */ + Word16 *dotp_e /* o : intermediate result exponent Q0 */ + ); + + /////////////////////////////////// + /* Lib_dec */ + ////////////////////////////////// + + void ResetSHBbuffer_Dec_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl /* i : BWE extension layer */ + ); + + void wb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ + Word16 *Q_synth ); + + void swb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ + Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ + Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ + Word16 *Q_white_exc, + Word16 *synth, /* o : SHB synthesis/final synthesis */ + Word16 *Q_synth, + Word16 *pitch_buf ); + + void ivas_dequantizeSHBparams_fx_9_1( + Decoder_State *st_fx, + const Word16 extl, /* i : extension layer */ + Word32 extl_brate, /* i : extensiuon layer bitrate */ + Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ + Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ + Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ + Word16 *uv_flag, /* o : unvoiced flag*/ + Word32 *Q_shb_ener_sf, /* o : Q15 */ + Word16 *Q_shb_res_gshape, /* o : Q14 */ + Word16 *Q_mixFactors, /* o : Q15 */ + Word16 *MSFlag ); + + void fb_tbe_dec_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word16 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp ); + + void fb_tbe_dec_ivas_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word32 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp, + Word16 *fb_synth_ref, + Word16 Q_fb_synth_ref, + Word16 output_frame ); + + void tbe_read_bitstream_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ + ); + + void GenTransition_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 rf_flag, /* i : RF flag */ + Word32 total_bitrate /* i : total bitrate */ + ); + + void GenTransition_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 prev_Qx ); + + void GenTransition_WB_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output, /* o : synthesized transitions signal */ + const Word32 output_Fs /* i : output sampling rate */ + ); + + void GenTransition_WB_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ + ); + + void TBEreset_dec_fx( + Decoder_State *st_fx /* i/o: decoder state structure */ + ); + + void td_bwe_dec_init_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl, /* i : BWE extension layer */ + const Word32 output_Fs /* i : output sampling rate */ + ); + + void lsf_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ + Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + ); + + /*! r: index of the maximum value in the input vector */ + Word16 maximum_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /*! r: index of the minimum value in the input vector */ + Word16 minimum_l( + const Word32 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word32 *min_val /* o : minimum value in the input vector */ + ); + + void v_multc_fx( + const Word32 x[], /* i : Input vector */ + const Word32 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_fx_16( + const Word32 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_fx_16_16( + const Word16 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word16 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ + ); + + void v_add_fx_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_add_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_add_fx_me( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x1_e, /* i : Exponent for input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + const Word16 x2_e, /* i : Exponent for input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 *y_e, /* i : Exponent for output vector */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_add_w64( + const Word64 x1[], /* i : Input vector 1 */ + const Word64 x2[], /* i : Input vector 2 */ + Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_sub_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ + ); + + void v_sub_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + /*! r: dot product of x[] and y[] */ + Word32 dotp_fx32( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ + ); + + /*! r: dot product of x[] and y[] in case of overflow*/ + Word32 dotp_fx32_o( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q ); + + Word32 dotp_fx32_fac( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q /*stores resultant Q*/ + ); + + Word32 dotp_fx_ivas_fx( + const Word32 x[], /* i : vector x[] */ + Word16 x_e, + const Word32 y[], /* i : vector y[] */ + Word16 y_e, + const Word16 n, /* i : vector length */ + Word16 *out_e ); + + Word32 dotp_fx_guarded( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ + ); + + Word32 dotp_me_fx( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 exp_x, + Word16 exp_y, + Word16 *exp_suma ); + + void lsf_end_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 mode2_flag, /* Q0 */ + const Word16 coder_type_org, /* i : coding type Q0*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ + Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ + Word16 *lpc_param, /* i : LPC parameters Q0*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + ); + + void lsf_mid_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ + Word16 coder_type, /* i : Coder type Q0*/ + Word16 lsp_mid[] /* o : quantized LSPs Q15*/ + ); + + void CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 last_element_mode, /* i : last element mode Q0 */ + Word16 Aq[], /* o : LP coefficients Q12 */ + Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ + Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ + Word16 *allow_cn_step, /* o : allow CN step Q0 */ + Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ + Word32 *q_env ); + + void swb_CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ + ); + + void swb_CNG_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ + ); + + void td_cng_dec_init_fx( + DEC_CORE_HANDLE st /* i/o: decoder state structure */ + ); + + void set_state( + Word16 *state, + Word16 num, + Word16 N ); + + void concealment_init_x( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + + void concealment_init_ivas_fx( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + + void concealment_update_x( + const Word16 bfi, + const Word16 core, + const Word16 tonality, + Word32 *invkoef /*Qinvkoef_scale*/, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + + Word16 Sqrt_x_fast( + Word32 value ); + + Word32 dot_w32_accuracy_x( + Word16 *s1, + Word16 *s2, + Word16 nbits, + Word16 N ); + + Word16 int_div_s_x( + Word16 a, + Word16 b ); + + Word16 GetW32Norm_x( + Word32 *s, + Word16 N ); + + Word16 harmo_x( + Word32 *X, + Word16 Framesize, + Word16 pitch ); + + void LpFilter2_x( + Word16 *x, + Word16 *y, + Word16 N ); + + void sig_tilt_x( + Word16 *s, + Word16 FrameSize, + Word32 *enr1, + Word32 *enr2 ); + + void get_maxConv_and_pitch_x( + Word16 *s_LP, + Word16 s, + Word16 e, + Word16 N, + Word32 *maxConv, + Word16 *maxConv_bits, + Word16 *pitch ); + + Word16 get_voicing_x( + Word16 *s_LP, + Word16 pitch, + Word32 covMax, + Word16 maxConv_bits, + Word16 Framesize ); + + void pitch_modify_x( + Word16 *s_LP, + Word16 *voicing, + Word16 *pitch, + Word16 FrameSize ); + + Word16 Is_Periodic_x( + Word32 *mdct_data, + Word16 cov_max, + Word16 zp, + Word32 ener, + Word32 ener_mean, + Word16 pitch, + Word16 Framesize ); + + Word16 get_conv_relation_x( + Word16 *s_LP, + Word16 shift, + Word16 N ); + + void concealment_decode_fix( + Word16 curr_mode, + Word32 *invkoef, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + + Word32 Spl_Energy_x( + const Word16 *vector, + const Word16 vector_length, + Word16 *scale_factor ); + + void Log10OfEnergy_x( + const Word16 *s, + Word32 *enerlogval, + const Word16 len ); + + void concealment_update2_x( + const Word16 *outx_new, + T_PLCInfo_HANDLE hPlcInfo, + const Word16 FrameSize ); + + Word16 ffr_getSfWord16( + Word16 *vector, /*!< Pointer to i vector */ + Word16 len ); + + void waveform_adj2_fix( + T_PLCInfo_HANDLE hPlcInfo, + Word16 *overlapbuf, + Word16 *outx_new, + const Word16 delay, + const Word16 bfi_cnt, + const Word16 bfi ); + + void concealment_signal_tuning_fx( + Decoder_State *st, + const Word16 bfi, + Word16 *outx_new_fx /*Qoutx_new_fx*/, + const Word16 past_core ); + + void DetectTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + + void RefineTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + + void ivas_RefineTonalComponents_fx( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 secondLastPowerSpectrum_e, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode, + const PsychoacousticParameters *psychParamsCurrent ); + + ivas_error PsychoacousticParameters_Init( + const Word32 sr_core, /* i : sampling rate of core-coder */ + const Word16 nBins, /* i : Number of bins (spectral lines) */ + const Word8 nBands, /* i : Number of spectrum subbands */ + const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ + const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ + PsychoacousticParameters *pPsychParams ); + + ivas_error TonalMDCTConceal_Init( + TonalMDCTConcealPtr self, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ + ); + + ivas_error TonalMDCTConceal_Init_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const UWord16 nSamples, + const UWord16 nSamplesCore, + const UWord16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ + ); + + /* Must be called only when a good frame is recieved - concealment is inactive */ + void TonalMDCTConceal_SaveFreqSignal( + TonalMDCTConcealPtr self, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + Word16 nNewSamples, + Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp ); + + void TonalMDCTConceal_SaveFreqSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + const Word16 nNewSamples, + const Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp, + const Word16 infoIGFStartLine ); + + void TonalMDCTConceal_UpdateState( + TonalMDCTConcealPtr self, + Word16 nNewSamples, + Word32 pitchLag, + Word16 badBlock, + Word8 tonalConcealmentActive ); + + void TonalMDCTConceal_Detect( + const TonalMDCTConcealPtr self, /*IN */ + const Word32 pitchLag, /*IN */ + Word16 *umIndices, /*OUT*/ + Word16 element_mode /* IN */ + ); + + void TonalMDCTConceal_Apply( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 *mdctSpectrum_exp /*IN */ + ); + + void TonalMDCTConceal_Apply_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 mdctSpectrum_exp, /*IN */ + const PsychoacousticParameters *psychParamsCurrent ); + + void TonalMDCTConceal_InsertNoise_ivas_fx( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, + Word16 *mdctSpectrum_exp, + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + const Word16 crossfadeGain, + const Word32 concealment_noise[L_FRAME48k], + const Word16 concealment_noise_e, + const Word32 cngLevelBackgroundTrace_bfi, + const Word16 cngLevelBackgroundTrace_e, + const Word16 crossOverFreq ); + + void TonalMDCTConceal_InsertNoise( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*OUT*/ + Word16 *mdctSpectrum_exp, /*OUT*/ + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + Word16 crossfadeGain, + const Word16 crossOverFreq ); + + void TonalMDCTConceal_SaveTimeSignal( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 nNewSamples ); + + void TonalMDCTConceal_SaveTimeSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 q_timeSignal, + Word16 nNewSamples ); + + void decision_matrix_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ + Word16 *hq_core_type, /* o : HQ core type Q0 */ + Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ + ); + + void hf_synth_init_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ + ); + + void hf_synth_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ + ); + + void hf_synth_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ + ); + + void hf_synth_ivas_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ + ); + + void hf_synth_amr_wb_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ + ); + + void hf_synth_amr_wb_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ + ); + + void hf_synth_amr_wb_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az : Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ + Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ + Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ + Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ + Word16 fmerit, /* i : classify parameter from FEC : Q14*/ + const Word16 *hf_gain, /* i : decoded HF gain Q0*/ + const Word16 *voice_factors, /* i : voicing factors : Q15*/ + const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ + const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ + const Word16 *lsf_new, /* i : ISF vector : Q2*/ + const Word16 Q_exc, /* i : exc scaling */ + const Word16 Q_out /* i : Q_syn2-1 */ + ); + + void Init_post_filter_fx( + PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ + ); /* i : core decoder parameters */ + + void nb_post_filt_fx( + const Word16 L_frame, /* i : frame length */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *psf_lp_noise, /* i : Long term noise Q8 */ + const Word16 tmp_noise, /* i : noise energy Q0 */ + Word16 *Synth, /* i : 12k8 synthesis Qsyn */ + const Word16 *Aq, /* i : LP filter coefficient Q12 */ + const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ + const Word16 coder_type, /* i : coder_type */ + const Word16 BER_detect, /* i : BER detect flag */ + const Word16 disable_hpf /* i : flag to diabled HPF */ + ); + + void formant_post_filt_fx( + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *synth_in, /* i : 12k8 synthesis */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ + Word16 *synth_out, /* i/o: input signal */ + const Word16 L_frame, /* i : frame length */ + const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ + const Word32 brate, /* (i) : bit-rate */ + const Word16 off_flag /* i : off flag */ + ); + + void Filt_mu_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr /* i : the length of subframe */ + ); + + void Filt_mu_ivas_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr, /* i : the length of subframe */ + const Word16 extl ); + + void scale_st_fx( + const Word16 *sig_in, /* i : postfilter i signal */ + Word16 *sig_out, /* i/o: postfilter o signal */ + Word16 *gain_prec, /* i/o: last value of gain for subframe */ + Word16 L_subfr ); + + void blend_subfr2_fx( + Word16 *sigIn1, /* i : i signal for fade-out */ + Word16 *sigIn2, /* i : i signal for fade-in */ + Word16 *sigOut /* o : output signal */ + ); + + void init_tcx_window_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ + const Word32 sr_core, /* i : SR core */ + const Word32 input_Fs, /* i : input/output SR */ + const Word16 L_frame, /* i : L_frame at sr_core */ + const Word16 L_frameTCX, /* i : L_frame at i/o SR */ + const Word16 mdctWindowLength, /* i : window length at sr_core */ + const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ + const Word16 element_mode /* i : mode of CPE/SCE */ + ); + + void init_tcx_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, /*Q15*/ + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, + const Word16 fscaleFB ); + + void syn_output_fx( + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ + const Word16 output_frame, /* i : output frame length */ + Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ + const Word16 Q_syn2 /* i : Synthesis scaling factor */ + ); + + void unscale_AGC( + const Word16 x[], /* i: 16kHz synthesis Qx */ + const Word16 Qx, /* i: scale factor of x */ + Word16 y[], /* o: output vector Q0 */ + Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ + const Word16 n /* i: vector size */ + ); + + void bass_psfilter_init_fx( + BPF_DEC_HANDLE hBPF /* o : BPF data handle */ + ); + + void bass_psfilter_fx( + BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ + const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ + Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ + const Word16 L_frame, /* i : length of the last frame Q0*/ + Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ + const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ + Word16 v_stab_fx, /* i : stability factor Q15*/ + Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ + const Word16 coder_type, /* i : coder_type Q0*/ + Word16 Q_syn, + Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ + ); + + void addBassPostFilter_fx( + const Word16 *harm_timeIn_Fx, /* timeIn_e */ + Word32 **rAnalysis_Fx, /* Qx - 5 */ + Word32 **iAnalysis_Fx, /* Qx - 5 */ + HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, + Word32 *workBuffer, /* Qx */ + const Word16 timeIn_e, + const Word16 nTimeSlots, /* Q0 */ + const Word16 nTimeSlotsTotal, /* Q0 */ + const Word16 nBandsTotal, /* Q0 */ + CLDFB_SCALE_FACTOR *cldfb_scale ); + + void FEC_exc_estim_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* o : pointer to excitation buffer (with past) */ + Word16 *exc2, /* o : total excitation (for synthesis) */ + Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ + Word16 *pitch_buf, /* o : Floating pitch for each subframe */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *tmp_tc, /* o : FEC pitch Q6 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *lsf_new, /* i : ISFs at the end of the frame */ + Word16 *Q_exc, + Word16 *tmp_noise /* o : long-term noise energy Q0 */ + ); + + void pitch_pred_linear_fit( + const Word16 bfi_cnt, /* i: bfi counter Q0 */ + const Word16 last_good, /* i: last classification type Q0 */ + Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ + Word32 *old_fpitch, /* i: Q16*/ + Word32 *T0_out, /* o: estimated close loop pitch Q16*/ + Word16 pit_min, /* i: Minimum pitch lag Q0 */ + Word16 pit_max, /* i: Maximum pitch lag Q0 */ + Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ + Word16 limitation, + Word16 plc_use_future_lag, /* i: Q0 */ + Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ + Word16 nb_subfr /* i: number of ACELP subframes */ + ); + + void get_subframe_pitch( + Word16 nSubframes, /* i: number of subframes Q0 */ + Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ + Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ + Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ + ); + + void PulseResynchronization_fx( + Word16 const *const src_exc, /*i Q15*/ + Word16 *const dst_exc, /*o Q15*/ + Word16 const nFrameLength, /*i Q0 */ + Word16 const nSubframes, /*i Q0 */ + Word32 const pitchStart, /*i Q16*/ + Word32 const pitchEnd /*i Q16*/ + ); + + void decod_audio_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ + ); + + void gsc_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ + Word16 *Q_exc ); + + void GSC_dec_init_fx( + GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ + ); + + void Es_pred_dec_fx( + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + const Word16 enr_idx, /* i : indice */ + const Word16 nb_bits, /* i : number of bits */ + const Word16 no_ltp /* i : no LTP flag */ + ); + + void gain_dec_tc_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ + ); + + void gain_dec_tc_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ + ); + + void gain_dec_mless_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ + ); + + void gain_dec_lbr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 *code_fx, /* i : algebraic excitation Q9 */ + Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes */ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ + const Word16 L_subfr /* i : subfr lenght */ + ); + +#ifndef CLEANUP_ACELP_ENC + void lp_gain_updt_fx( + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ + ); +#endif +#ifdef CLEANUP_ACELP_ENC + void lp_gain_updt_fx( + const Word16 element_mode, /* i : element mode */ #else -void highband_exc_dct_in_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 *mfreq_bindiv, /* i : bin per bands tables */ - Word16 last_bin, /* i : last bin of bit allocation */ - Word16 Diff_len, /* i : number of bin before cut-off frequency */ - Word16 noise_lev, /* i : pulses dynamic */ - Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - Word16 *exc_diffQ, /* i : frequency coefficients of per band */ - Word16 *seed_tcx, /* i : Seed for noise */ - Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ - Word16 nb_subfr, /* i : Number of subframe considered */ - Word16 *exc_dct_in, /* o : dct of residual signal */ - Word16 last_coder_type, /* i : coding type of last frame */ - Word16 *bitallocation_band, /* i : bit allocation flag of each band */ - const Word16 *lsf_new, /* i : LSFs at the end of the frame */ - Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ - Word16 *last_ener, /* i : frequency energy of last frame */ - Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ - Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ - Word16 bfi, /* i : bad frame indicator */ - const Word16 coder_type, /* i : coder type */ - Word16 bwidth, - Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ - Word16 Qexc_diffQ, - Word16 *Q_exc, - const Word16 GSC_noisy_speech, - Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); -#endif - -void lsf_dec_bfi( - const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ - Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ - const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ - Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ - const Word16 lsfBase[], /* i : base for differential lsf coding */ - Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ - const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ - Word16 L_frame, - const Word16 last_good, /*!< i : last good received frame */ - const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ - const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ - Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ - Word16 *lsf_cng, /* Q2.56 */ - Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ - const Word16 Last_GSC_pit_band_idx, - const Word16 Opt_AMR_WB, /* i : IO flag */ - const Word8 tcxonly, - const short bwidth /* i: coded bandwidth */ -); - -Word16 const *PlcGetLsfBase( - Word16 const lpcQuantization, - Word16 const narrowBand, - Word32 const sr_core ); - -/* Create an instance of type FD_CNG */ -ivas_error createFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - -void initFdCngCom( - HANDLE_FD_CNG_COM hFdCngCom, - Word16 scale ); - -/* Delete the instance of type FD_CNG */ -void deleteFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - -/* Initialize the spectral partitioning */ -void initPartitions( - const Word16 *part_in, - const Word16 npart_in, - const Word16 startBand, - const Word16 stopBand, - Word16 *part_out, - Word16 *npart_out, - Word16 *midband, - Word16 *psize, - Word16 *psize_norm, - Word16 *psize_norm_exp, - Word16 *psize_inv, - const Word16 stopBandFR ); - -/* Noise estimation using Minimum Statistics (MS) */ -void compress_range( - Word32 *in, - Word16 in_exp, - Word16 *out, - const Word16 len ); - -void expand_range( - Word16 *in, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - -void expand_range_fx( - Word32 *in, // Q25 - Word32 *out, // exp:out_exp - Word16 *out_exp, - const Word16 len ); - -void expand_range_var_exp( - Word16 *in, - Word16 in_exp, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - -void minimum_statistics( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ -); - -void minimum_statistics_fx( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ - Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ -); - -/* Apply bitrate-dependant scale */ -void apply_scale( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ -); - -Word16 apply_scale_ind( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ -); -void apply_scale_ivas_fx( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize, /* i : Size of scale table */ - Word16 *index ); - -/* Compute the power for each partition */ -void bandcombinepow( - const Word32 *bandpow, /* i : Power for each band */ - const Word16 exp_bandpow, /* i : exponent of bandpow */ - const Word16 nband, /* i : Number of bands */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - const Word16 *psize_inv, /* i : Inverse partition sizes */ - Word32 *partpow, /* o : Power for each partition */ - Word16 *exp_partpow ); - -/* Scale partitions (with smoothing) */ -void scalebands( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - -void scalebands_fx( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - -/* STFT analysis filterbank */ -void AnalysisSTFT( - const Word16 *timeDomainInput, /* i : pointer to time signal */ - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void AnalysisSTFT_fx( - const Word16 *timeDomainInput, - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -/* STFT synthesis filterbank */ -void SynthesisSTFT( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -void SynthesisSTFT_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -Word32 sign_l( - const Word32 x /* i : input value of x */ -); - -void ivas_updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ -); - -/* Random generator with Gaussian distribution with mean 0 and std 1 */ -Word32 rand_gauss( - Word16 *seed ); - -Word16 rand_gauss_fix( - Word16 *x, - Word16 *seed ); - -void lpc_from_spectrum( - HANDLE_FD_CNG_COM hFdCngCom, - const Word16 start, /*i : start band*/ - const Word16 stop, /*i : stop band*/ - const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ -); - -void msvq_decoder( - const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook vector dimension */ - const Word16 Idx[], /* i : Indices */ - Word16 *uq /* o : quantized vector */ -); - -void FdCng_exc( - HANDLE_FD_CNG_COM hs, - Word16 *CNG_mode, - Word16 L_frame, - Word16 *lsp_old, - Word16 first_CNG, - Word16 *lsp_CNG, - Word16 *Aq, /* o: LPC coeffs */ - Word16 *lsp_new, /* o: lsp */ - Word16 *lsf_new, /* o: lsf */ - Word16 *exc, /* o: LP excitation */ - Word16 *exc2, /* o: LP excitation */ - Word16 *bwe_exc /* o: LP excitation for BWE */ -); - -void direct_transform_fx( - const Word32 in32_fx[], - Word32 out32_fx[], - const Word16 is_transient, - const Word16 L, - Word16 *Q, - const Word16 element_mode ); - -void preecho_sb_fx( - const Word32 brate, /* i Q0 : core bit-rate */ - Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ - Word16 q_sig32, /* i Q value for wtda_audio_fx */ - Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ - Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ - const Word16 framelength, /* i Q0 : frame length */ - Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ - Word16 *smoothmem_fx, /* i/o Q15 : memory */ - Word32 *mean_prev_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ - Word16 *wmold_hb_fx, /* i/o Q15 : memory */ - Word16 *prevflag, /* i/o Q0 : flag */ - Word16 *pastpre, /* i/o Q0 : flag */ - const Word16 bwidth /* i Q0 : bandwidth */ -); - -void Inverse_Transform( - const Word32 *in_mdct, /* i : i MDCT vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 is_transient, /* i : transient flag */ - const Word16 L, /* i : output frame length */ - const Word16 L_inner, /* i : length of the transform */ - const Word16 element_mode /* i : IVAS element mode */ -); - -void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ - Word16 *ynrm, /* o : recovered quantization indices Q0*/ - Word16 *normqlg2, /* o : recovered quantized norms Q0*/ - const Word16 nb_sfm /* i : number of SFMs Q0*/ -); - -Word32 ar_div( Word32 num, Word32 denum ); - -void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); -void ar_encoder_done_fx( PARCODEC arInst ); -void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); -void ar_decoder_done_fx( PARCODEC arInst ); -Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); - -void TCQLSB_fx( - Word16 bcount, - Word32 *abuffer_fx, - Word16 *mbuffer_fx, - Word32 *sbuffer_fx, - Word16 *dpath ); - -void TCQLSBdec_fx( - Word16 *dpath, - Word16 *mbuffer, - Word16 bcount ); - -void RestoreTCQ_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - -void RestoreTCQdec_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - -void InitLSBTCQ_fx( - Word16 *bcount ); - -void SaveTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - -void LoadTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - -Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); -Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); -Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); - -Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); - -void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); -void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); -void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); -void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); - -Word16 GetScale_fx( - Word16 blen, - Word32 bits_fx, - Word32 *surplus_fx ); - -void srt_vec_ind_fx( - const Word32 *linear, - Word32 *srt, - Word16 *I, - Word16 length ); - -void fill_spectrum_fx( - Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ - Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ - const Word16 *R, /* i : number of pulses per band Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - Word16 norm[], /* i : quantization indices for norms Q0 */ - const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ - const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ - const Word16 nf_idx, /* i : noise fill index Q0 */ - const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ - const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ - Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ - Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ - Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ - const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ - const Word16 core_sfm, /* i : index of the end band for core Q0 */ - const Word16 HQ_mode, /* i : HQ mode Q0 */ - Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ - const Word32 L_core_brate, /* i : target bit-rate Q0 */ - Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ - Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ - Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ - const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ - const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ - const Word16 *npulses, /* i : number of pulses per band Q0 */ - const Word16 prev_is_transient, /* i : previous transient flag Q0 */ - Word32 *prev_normq, /* i/o: previous norms Q14 */ - Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ - const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ - const Word16 *sfmsize, /* i : Length of bands Q0 */ - const Word16 *sfm_start, /* i : Start of bands Q0 */ - const Word16 *sfm_end, /* i : End of bands Q0 */ - Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ - const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ - const Word16 num_sfm, /* i : Total number of bands Q0 */ - Word16 *prev_env_Q, - const Word16 num_env_bands, - const Word16 element_mode ); - -void hq_bit_allocation_fx( - const Word32 core_brate, /* i : Core bit-rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - const Word16 hqswb_clas, /* i : HQ class Q0 */ - Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ - const Word16 *normqlg2, /* i : Quantized norms Q0 */ - const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ - const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ - Word16 *noise_level, /* o : HVQ noise level Q15 */ - Word16 *R, /* o : Bit allocation per sub band Q0 */ - Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ - Word16 *sum, /* o : Sum of allocated shape bits Q0 */ - Word16 *core_sfm, /* o : Last coded band in core Q0 */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ -); - -void map_quant_weight_fx( - const Word16 normqlg2[], /* i : quantized norms Q0*/ - Word16 wnorm[], /* o : weighted norm Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ -); - -void bitalloc_fx( - Word16 *y, /* i : reordered norm of sub-vectors Q0 */ - Word16 *idx, /* i : reordered sub-vector indices Q0 */ - Word16 sum, /* i : number of available bits Q0 */ - Word16 N, /* i : number of norms Q0 */ - Word16 K, /* i : maximum number of bits per dimension Q0 */ - Word16 *r, /* o : bit-allacation vector Q0 */ - const Word16 *sfmsize, /* i : band length Q0 */ - const Word16 hqswb_clas /* i : signal classification flag Q0 */ -); - -Word16 BitAllocF_fx( - Word16 *y, /* i : norm of sub-vectors :Q0 */ - Word32 bit_rate, /* i : bitrate :Q0 */ - Word16 B, /* i : number of available bits :Q0 */ - Word16 N, /* i : number of sub-vectors :Q0 */ - Word16 *R, /* o : bit-allocation indicator :Q0 */ - Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ - const Word16 hqswb_clas, /* i : hq swb class */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ -); - -Word16 BitAllocWB_fx( - Word16 *y, /* i : norm of sub-vectors Q0*/ - Word16 B, /* i : number of available bits Q0*/ - Word16 N, /* i : number of sub-vectors Q0*/ - Word16 *R, /* o : bit-allocation indicator Q0*/ - Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ -); - -void bitallocsum_fx( - Word16 *R, /* i : bit-allocation vector Q0 */ - const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ - Word16 *sum, /* o : total number of bits allocated Q0 */ - Word16 *Rsubband, /* o : rate per subband Q3 */ - const Word16 num_bits, /* i : number of bits Q0 */ - const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ - const Word16 *sfmsize /* i : band length Q0 */ -); - -Word16 stab_est_fx( - Word16 etot, /* i : Total energy of the current frame Q8*/ - Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ - Word16 *mem_etot, /* i/o : Total energy memory Q8*/ - Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ - Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ - Word16 *thresh, /* i/o : Detection thresold Q11*/ - Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ - const Word16 vad_flag /* i : VAD flag */ -); - -void enhancer_fx( - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ -); - -void enhancer_ivas_fx( - const Word16 codec_mode, /* i : flag indicating Codec Mode */ - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 cbk_index, /* i : */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ -); - -Word16 E_UTIL_enhancer( - Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - Word16 stab_fac, /* i : LP filter stability measure Q15 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ - Word16 *code, /* i/o: innovation(in: Q9) code_exp */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ - Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ - Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ - Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ - Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ - Word16 coder_type, /* i : coder type */ - Word16 cdk_index, /* i : */ - Word16 L_subfr, /* i : */ - Word16 L_frame, /* i : frame size */ - Word16 Q_new ); - -void phase_dispersion( - const Word32 gain_code, /* i : gain of code 15Q16 */ - const Word16 gain_pit, /* i : gain of pitch Q14 */ - Word16 code[], /* i/o: code vector */ - Word16 *code_e, /* i/o: exponent of code */ - const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ - Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ - Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ - Word16 *prev_state, /* i/o: static memory Q0 */ - Word16 L_subfr /* i : subframe length [40,64] */ -); - -void tcx_ltp_get_lpc( - Word16 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word16 *A, /* Qx */ - const Word16 order /* Q0 */ -); - -void tcx_ltp_get_lpc_fx( - Word32 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word32 *A, /* Qx */ - const Word16 order /* Q0 */ -); - -void predict_signal( - const Word16 excI[], /* i : input excitation buffer Qx*/ - Word16 excO[], /* o : output excitation buffer Qx*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i : fraction of lag Q0*/ - const Word16 frac_max, /* i : max fraction Q0*/ - const Word16 L_subfr /* i : subframe size Q0*/ -); - -Word16 tcx_ltp_decode_params( - Word16 *ltp_param, /* Q0 */ - Word16 *pitch_int, /* Q0 */ - Word16 *pitch_fr, /* Q0 */ - Word16 *gain, /* Q13 */ - const Word16 pitmin, /* Q0 */ - const Word16 pitfr1, /* Q0 */ - const Word16 pitfr2, /* Q0 */ - const Word16 pitmax, /* Q0 */ - const Word16 pitres /* Q0 */ -); - -void tcx_ltp_post_fx( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word16 *sig, /* Qx */ - Word16 *tcx_buf /* Qx */ -); - -void tcx_ltp_post_fx32( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word32 *sig, /* sig_q */ - Word32 *tcx_buf, /* sig_q */ - Word16 sig_q ); - -void Inac_switch_ematch_fx( - Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ - Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ - const Word16 coder_type, /* i : Coding mode */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 L_frame, /* i : Frame lenght */ - const Word16 Q_exc, /* i : input and output format of exc2 */ - const Word16 bfi, /* i : frame lost indicator */ - const Word16 last_core, /* i : Last core used */ - const Word16 last_codec_mode, /* i : Last codec mode */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 element_mode /* i : element mode */ -); - -/**< out: Q0 | multiplication factor */ -Word16 IGF_ApplyTransFac( - const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ - const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ -); - -Word16 IGF_MapBitRateToIndex( - const Word32 brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void IGFCommonFuncsCalcSfbEnergyPowerSpec( - const Word16 startSfb, /**< in: Q0 | start sfb index */ - const Word16 stopSfb, /**< in: Q0 | stop sfb index */ - const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ - Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ - Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ - Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ - Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ -); - -void IGFCommonFuncsMDCTSquareSpec( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ -); - -void IGFCommonFuncsMDCTSquareSpec_ivas( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ -); - -Word16 IGFCommonFuncsIGFConfiguration( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -Word16 IGFCommonFuncsIGFGetCFTables_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ - const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ - Word16 *cf_off_se01, /* o : offset for CF table above */ - const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ - const Word16 **cf_off_se02, /* o : offsets for CF tables above */ - const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ - Word16 *cf_off_se10, /* o : offset for CF table above */ - const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ - const Word16 **cf_off_se11 /* o : offsets for CF tables above */ -); - -Word32 L_multi31x16_X2( - Word16 xh, - Word16 xl, - Word16 y ); - -Word32 mul_sbc_14bits( - Word32 r, /* Q0 */ - Word16 c /* Q0 */ -); - -void ham_cos_window( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - -void ham_cos_window_ivas( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - -/* o: Q31 */ -Word32 expfp( - const Word16 x, /* i: mantissa Q-e */ - const Word16 x_e ); /* i: exponent Q0 */ - -void powfp_odd2( - const Word16 base, /* Q15 */ - const Word16 exp, /* Q0 */ - Word16 *pout1, /* Q15 */ - Word16 *pout2 ); /* Q15 */ - -void tcx_arith_scale_envelope( - const Word16 L_spec_core, /* i: number of lines to scale Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - const Word32 env[], /* i: unscaled envelope Q16 */ - Word16 target_bits, /* i: number of available bits Q0 */ - const Word16 low_complexity, /* i: low-complexity flag Q0 */ - Word16 s_env[], /* o: scaled envelope Q15-e */ - Word16 *s_env_e /* o: scaled envelope exponent Q0 */ -); - -void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ - const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ -); - -/* returns innovation gain Q16 */ -Word32 calc_gain_inov( - const Word16 *code, /* i : algebraic excitation Q9 */ - const Word16 lcode, /* i : Subframe size Q0 */ - Word32 *dotp, /* o : intermediate result Q31-e */ - Word16 *dotp_e /* o : intermediate result exponent Q0 */ -); - -/////////////////////////////////// -/* Lib_dec */ -////////////////////////////////// - -void ResetSHBbuffer_Dec_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl /* i : BWE extension layer */ -); - -void wb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ - Word16 *Q_synth ); - -void swb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ - Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ - Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ - Word16 *Q_white_exc, - Word16 *synth, /* o : SHB synthesis/final synthesis */ - Word16 *Q_synth, - Word16 *pitch_buf ); - -void ivas_dequantizeSHBparams_fx_9_1( - Decoder_State *st_fx, - const Word16 extl, /* i : extension layer */ - Word32 extl_brate, /* i : extensiuon layer bitrate */ - Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ - Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ - Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ - Word16 *uv_flag, /* o : unvoiced flag*/ - Word32 *Q_shb_ener_sf, /* o : Q15 */ - Word16 *Q_shb_res_gshape, /* o : Q14 */ - Word16 *Q_mixFactors, /* o : Q15 */ - Word16 *MSFlag ); - -void fb_tbe_dec_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word16 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp ); - -void fb_tbe_dec_ivas_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word32 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp, - Word16 *fb_synth_ref, - Word16 Q_fb_synth_ref, - Word16 output_frame ); - -void tbe_read_bitstream_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); - -void GenTransition_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 rf_flag, /* i : RF flag */ - Word32 total_bitrate /* i : total bitrate */ -); - -void GenTransition_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 prev_Qx ); - -void GenTransition_WB_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output, /* o : synthesized transitions signal */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void GenTransition_WB_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void TBEreset_dec_fx( - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -void td_bwe_dec_init_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl, /* i : BWE extension layer */ - const Word32 output_Fs /* i : output sampling rate */ -); - -void lsf_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ -); - -/*! r: index of the maximum value in the input vector */ -Word16 maximum_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -Word16 minimum_l( - const Word32 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word32 *min_val /* o : minimum value in the input vector */ -); - -void v_multc_fx( - const Word32 x[], /* i : Input vector */ - const Word32 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_fx_16( - const Word32 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_fx_16_16( - const Word16 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word16 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ -); - -void v_add_fx_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_add_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_add_fx_me( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x1_e, /* i : Exponent for input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - const Word16 x2_e, /* i : Exponent for input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 *y_e, /* i : Exponent for output vector */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_add_w64( - const Word64 x1[], /* i : Input vector 1 */ - const Word64 x2[], /* i : Input vector 2 */ - Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_sub_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ -); - -void v_sub_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -/*! r: dot product of x[] and y[] */ -Word32 dotp_fx32( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ -); - -/*! r: dot product of x[] and y[] in case of overflow*/ -Word32 dotp_fx32_o( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q ); - -Word32 dotp_fx32_fac( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q /*stores resultant Q*/ -); - -Word32 dotp_fx_ivas_fx( - const Word32 x[], /* i : vector x[] */ - Word16 x_e, - const Word32 y[], /* i : vector y[] */ - Word16 y_e, - const Word16 n, /* i : vector length */ - Word16 *out_e ); - -Word32 dotp_fx_guarded( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ -); - -Word32 dotp_me_fx( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 exp_x, - Word16 exp_y, - Word16 *exp_suma ); - -void lsf_end_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 mode2_flag, /* Q0 */ - const Word16 coder_type_org, /* i : coding type Q0*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ - Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ - Word16 *lpc_param, /* i : LPC parameters Q0*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices, /* o : number of indices Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ -); - -void lsf_mid_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ - Word16 coder_type, /* i : Coder type Q0*/ - Word16 lsp_mid[] /* o : quantized LSPs Q15*/ -); - -void CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ - Word16 Aq[], /* o : LP coefficients Q12 */ - Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ - Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ - Word32 *q_env ); - -void swb_CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -); - -void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ -); - -void td_cng_dec_init_fx( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ -); - -void set_state( - Word16 *state, - Word16 num, - Word16 N ); - -void concealment_init_x( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_init_ivas_fx( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - -void concealment_update_x( - const Word16 bfi, - const Word16 core, - const Word16 tonality, - Word32 *invkoef /*Qinvkoef_scale*/, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - -Word16 Sqrt_x_fast( - Word32 value ); - -Word32 dot_w32_accuracy_x( - Word16 *s1, - Word16 *s2, - Word16 nbits, - Word16 N ); - -Word16 int_div_s_x( - Word16 a, - Word16 b ); - -Word16 GetW32Norm_x( - Word32 *s, - Word16 N ); - -Word16 harmo_x( - Word32 *X, - Word16 Framesize, - Word16 pitch ); - -void LpFilter2_x( - Word16 *x, - Word16 *y, - Word16 N ); - -void sig_tilt_x( - Word16 *s, - Word16 FrameSize, - Word32 *enr1, - Word32 *enr2 ); - -void get_maxConv_and_pitch_x( - Word16 *s_LP, - Word16 s, - Word16 e, - Word16 N, - Word32 *maxConv, - Word16 *maxConv_bits, - Word16 *pitch ); - -Word16 get_voicing_x( - Word16 *s_LP, - Word16 pitch, - Word32 covMax, - Word16 maxConv_bits, - Word16 Framesize ); - -void pitch_modify_x( - Word16 *s_LP, - Word16 *voicing, - Word16 *pitch, - Word16 FrameSize ); - -Word16 Is_Periodic_x( - Word32 *mdct_data, - Word16 cov_max, - Word16 zp, - Word32 ener, - Word32 ener_mean, - Word16 pitch, - Word16 Framesize ); - -Word16 get_conv_relation_x( - Word16 *s_LP, - Word16 shift, - Word16 N ); - -void concealment_decode_fix( - Word16 curr_mode, - Word32 *invkoef, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - -Word32 Spl_Energy_x( - const Word16 *vector, - const Word16 vector_length, - Word16 *scale_factor ); - -void Log10OfEnergy_x( - const Word16 *s, - Word32 *enerlogval, - const Word16 len ); - -void concealment_update2_x( - const Word16 *outx_new, - T_PLCInfo_HANDLE hPlcInfo, - const Word16 FrameSize ); - -Word16 ffr_getSfWord16( - Word16 *vector, /*!< Pointer to i vector */ - Word16 len ); - -void waveform_adj2_fix( - T_PLCInfo_HANDLE hPlcInfo, - Word16 *overlapbuf, - Word16 *outx_new, - const Word16 delay, - const Word16 bfi_cnt, - const Word16 bfi ); - -void concealment_signal_tuning_fx( - Decoder_State *st, - const Word16 bfi, - Word16 *outx_new_fx /*Qoutx_new_fx*/, - const Word16 past_core ); - -void DetectTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - -void RefineTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - -void ivas_RefineTonalComponents_fx( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 secondLastPowerSpectrum_e, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode, - const PsychoacousticParameters *psychParamsCurrent ); - -ivas_error PsychoacousticParameters_Init( - const Word32 sr_core, /* i : sampling rate of core-coder */ - const Word16 nBins, /* i : Number of bins (spectral lines) */ - const Word8 nBands, /* i : Number of spectrum subbands */ - const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); - -ivas_error TonalMDCTConceal_Init( - TonalMDCTConcealPtr self, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ -); - -ivas_error TonalMDCTConceal_Init_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const UWord16 nSamples, - const UWord16 nSamplesCore, - const UWord16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ -); - -/* Must be called only when a good frame is recieved - concealment is inactive */ -void TonalMDCTConceal_SaveFreqSignal( - TonalMDCTConcealPtr self, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - Word16 nNewSamples, - Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp ); - -void TonalMDCTConceal_SaveFreqSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - const Word16 nNewSamples, - const Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp, - const Word16 infoIGFStartLine ); - -void TonalMDCTConceal_UpdateState( - TonalMDCTConcealPtr self, - Word16 nNewSamples, - Word32 pitchLag, - Word16 badBlock, - Word8 tonalConcealmentActive ); - -void TonalMDCTConceal_Detect( - const TonalMDCTConcealPtr self, /*IN */ - const Word32 pitchLag, /*IN */ - Word16 *umIndices, /*OUT*/ - Word16 element_mode /* IN */ -); - -void TonalMDCTConceal_Apply( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 *mdctSpectrum_exp /*IN */ -); - -void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 mdctSpectrum_exp, /*IN */ - const PsychoacousticParameters *psychParamsCurrent ); - -void TonalMDCTConceal_InsertNoise_ivas_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, - Word16 *mdctSpectrum_exp, - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - const Word16 crossfadeGain, - const Word32 concealment_noise[L_FRAME48k], - const Word16 concealment_noise_e, - const Word32 cngLevelBackgroundTrace_bfi, - const Word16 cngLevelBackgroundTrace_e, - const Word16 crossOverFreq ); - -void TonalMDCTConceal_InsertNoise( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*OUT*/ - Word16 *mdctSpectrum_exp, /*OUT*/ - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - Word16 crossfadeGain, - const Word16 crossOverFreq ); - -void TonalMDCTConceal_SaveTimeSignal( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 nNewSamples ); - -void TonalMDCTConceal_SaveTimeSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 q_timeSignal, - Word16 nNewSamples ); - -void decision_matrix_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ - Word16 *hq_core_type, /* o : HQ core type Q0 */ - Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ -); - -void hf_synth_init_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ -); - -void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); - -void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ -); - -void hf_synth_amr_wb_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void hf_synth_amr_wb_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az : Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ - Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ - Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ - Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ - Word16 fmerit, /* i : classify parameter from FEC : Q14*/ - const Word16 *hf_gain, /* i : decoded HF gain Q0*/ - const Word16 *voice_factors, /* i : voicing factors : Q15*/ - const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ - const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ - const Word16 *lsf_new, /* i : ISF vector : Q2*/ - const Word16 Q_exc, /* i : exc scaling */ - const Word16 Q_out /* i : Q_syn2-1 */ -); - -void Init_post_filter_fx( - PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ -); /* i : core decoder parameters */ - -void nb_post_filt_fx( - const Word16 L_frame, /* i : frame length */ - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *psf_lp_noise, /* i : Long term noise Q8 */ - const Word16 tmp_noise, /* i : noise energy Q0 */ - Word16 *Synth, /* i : 12k8 synthesis Qsyn */ - const Word16 *Aq, /* i : LP filter coefficient Q12 */ - const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ - const Word16 coder_type, /* i : coder_type */ - const Word16 BER_detect, /* i : BER detect flag */ - const Word16 disable_hpf /* i : flag to diabled HPF */ -); - -void formant_post_filt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient Q12 */ - Word16 *synth_out, /* i/o: input signal */ - const Word16 L_frame, /* i : frame length */ - const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - const Word32 brate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ -); - -void Filt_mu_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr /* i : the length of subframe */ -); - -void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ); - -void scale_st_fx( - const Word16 *sig_in, /* i : postfilter i signal */ - Word16 *sig_out, /* i/o: postfilter o signal */ - Word16 *gain_prec, /* i/o: last value of gain for subframe */ - Word16 L_subfr ); - -void blend_subfr2_fx( - Word16 *sigIn1, /* i : i signal for fade-out */ - Word16 *sigIn2, /* i : i signal for fade-in */ - Word16 *sigOut /* o : output signal */ -); - -void init_tcx_window_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ - const Word32 sr_core, /* i : SR core */ - const Word32 input_Fs, /* i : input/output SR */ - const Word16 L_frame, /* i : L_frame at sr_core */ - const Word16 L_frameTCX, /* i : L_frame at i/o SR */ - const Word16 mdctWindowLength, /* i : window length at sr_core */ - const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ - const Word16 element_mode /* i : mode of CPE/SCE */ -); - -void init_tcx_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, /*Q15*/ - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, - const Word16 fscaleFB ); - -void syn_output_fx( - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ - const Word16 output_frame, /* i : output frame length */ - Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ - const Word16 Q_syn2 /* i : Synthesis scaling factor */ -); - -void unscale_AGC( - const Word16 x[], /* i: 16kHz synthesis Qx */ - const Word16 Qx, /* i: scale factor of x */ - Word16 y[], /* o: output vector Q0 */ - Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ - const Word16 n /* i: vector size */ -); - -void bass_psfilter_init_fx( - BPF_DEC_HANDLE hBPF /* o : BPF data handle */ -); - -void bass_psfilter_fx( - BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ - const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ - Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ - const Word16 L_frame, /* i : length of the last frame Q0*/ - Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ - const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ - Word16 v_stab_fx, /* i : stability factor Q15*/ - Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ - const Word16 coder_type, /* i : coder_type Q0*/ - Word16 Q_syn, - Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ -); - -void addBassPostFilter_fx( - const Word16 *harm_timeIn_Fx, /* timeIn_e */ - Word32 **rAnalysis_Fx, /* Qx - 5 */ - Word32 **iAnalysis_Fx, /* Qx - 5 */ - HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, - Word32 *workBuffer, /* Qx */ - const Word16 timeIn_e, - const Word16 nTimeSlots, /* Q0 */ - const Word16 nTimeSlotsTotal, /* Q0 */ - const Word16 nBandsTotal, /* Q0 */ - CLDFB_SCALE_FACTOR *cldfb_scale ); - -void FEC_exc_estim_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* o : pointer to excitation buffer (with past) */ - Word16 *exc2, /* o : total excitation (for synthesis) */ - Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ - Word16 *pitch_buf, /* o : Floating pitch for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *tmp_tc, /* o : FEC pitch Q6 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *Q_exc, - Word16 *tmp_noise /* o : long-term noise energy Q0 */ -); - -void pitch_pred_linear_fit( - const Word16 bfi_cnt, /* i: bfi counter Q0 */ - const Word16 last_good, /* i: last classification type Q0 */ - Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ - Word32 *old_fpitch, /* i: Q16*/ - Word32 *T0_out, /* o: estimated close loop pitch Q16*/ - Word16 pit_min, /* i: Minimum pitch lag Q0 */ - Word16 pit_max, /* i: Maximum pitch lag Q0 */ - Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ - Word16 limitation, - Word16 plc_use_future_lag, /* i: Q0 */ - Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ - Word16 nb_subfr /* i: number of ACELP subframes */ -); - -void get_subframe_pitch( - Word16 nSubframes, /* i: number of subframes Q0 */ - Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ - Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ - Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ -); - -void PulseResynchronization_fx( - Word16 const *const src_exc, /*i Q15*/ - Word16 *const dst_exc, /*o Q15*/ - Word16 const nFrameLength, /*i Q0 */ - Word16 const nSubframes, /*i Q0 */ - Word32 const pitchStart, /*i Q16*/ - Word32 const pitchEnd /*i Q16*/ -); - -void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ -); - -void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ - Word16 *Q_exc ); - -void GSC_dec_init_fx( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ -); - -void Es_pred_dec_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ - const Word16 enr_idx, /* i : indice */ - const Word16 nb_bits, /* i : number of bits */ - const Word16 no_ltp /* i : no LTP flag */ -); - -void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -); - -void gain_dec_tc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ -); - -void gain_dec_mless_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ -); - -void gain_dec_lbr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 *code_fx, /* i : algebraic excitation Q9 */ - Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 L_subfr /* i : subfr lenght */ -); - -#ifndef CLEANUP_ACELP_ENC -void lp_gain_updt_fx( - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ -); -#endif -#ifdef CLEANUP_ACELP_ENC -void lp_gain_updt_fx( - const Word16 element_mode, /* i : element mode */ -#else -void lp_gain_updt_ivas_fx( -#endif - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ -); - -/*! r: quantized codebook gain Q16 */ -Word32 gain_dec_gaus_fx( - Word16 index, /* i : quantization index */ - const Word16 bits, /* i : number of bits to quantize */ - const Word16 lowBound, /* i : lower bound of quantizer (dB) */ - const Word16 topBound, /* i : upper bound of quantizer (dB) */ - const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ -); - -void gain_dec_SQ_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 *code, /* i : algebraic code excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ - Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ -); - -void gain_dec_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - Word16 *gain_pit, /* o : Quantized pitch gain */ - Word32 *gain_code, /* o : Quantized codeebook gain */ - Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ - Word16 *gain_inov, /* o : unscaled innovation gain */ - const Word16 *code, /* i : algebraic code excitation */ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ -); - -void transf_cdbk_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ - const Word32 gain_code, /* i : innovative excitation gain (Q16) */ - Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ - Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ - Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ - Word16 *unbits /* o : number of AVQ unused bits */ -); - -/* o: decoded gain */ -Word16 gain_dequant_fx( - Word16 index, /* i: quantization index */ - const Word16 min, /* i: value of lower limit */ - const Word16 max, /* i: value of upper limit */ - const Word16 bits, /* i: number of bits to dequantize */ - Word16 *expg ); - -void AVQ_demuxdec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ - Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ - const Word16 Nsv, /* i : number of subvectors Q0*/ - Word16 nq[], /* i/o: AVQ nq index Q0*/ - Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ - Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ -); - -void AVQ_dec_lpc( - Word16 *indx, /* input: index[] (4 bits per words) Q0*/ - Word16 *nvecq, /* output: vector quantized Q0*/ - Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ - -void re8_dec_fx( - Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ - const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ - const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ -); - -void re8_decode_base_index_fx( - const Word16 n, - UWord16 I, - Word16 *x ); - -void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ -); - -void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ - Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ -); - -void re8_PPV_fx( - const Word32 x[], /* i : point in R^8 Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ -); - -void dec_pit_exc_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -/* o: pitch value Q16 */ -Word32 Mode2_pit_decode( - const Word16 coder_type, /* i: coding model */ - Word16 i_subfr, /* i: subframe index */ - Word16 L_subfr, - Word16 **pt_indice, /* i/o: quantization indices pointer */ - Word16 *T0, /* i/o: close loop integer pitch Q0 */ - Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ - Word16 *T0_res, /* i/o: pitch resolution Q0 */ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ - Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr1b, - Word16 pit_fr2, - Word16 pit_max, - Word16 pit_res_max ); - -void Mode2_abs_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 *T0_res, /* o: pitch resolution Q0 */ - Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr2, - Word16 pit_res_max ); - -void Mode2_delta_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 T0_res, /* i: pitch resolution Q0 */ - Word16 *T0_min, /* i: delta search min Q0 */ - Word16 *T0_min_frac, /* i: delta search min Q0 */ - Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ -); - -/* o : floating pitch value */ -Word16 pit_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ -); - -void pit_Q_dec_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 delta, /* i : Half the CL searched interval */ - const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ -); - -void pit16k_Q_dec_fx( - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ -); - -void abs_pit_dec_fx( - const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ - Word16 pitch_index, /* i: pitch index */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o: integer pitch lag */ - Word16 *T0_frac /* o: pitch fraction */ -); - -void delta_pit_dec_fx( - const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - const Word16 pitch_index, /* i : pitch index */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - const Word16 T0_min /* i : delta search min */ -); - -void limit_T0_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 delta, /* i : Half the close-loop searched interval */ - const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_max /* o : higher pitch limit */ -); - -void limit_T0_voiced( - const Word16 nbits, - const Word16 res, - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - const Word16 T0_res, /* i : pitch resolution */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_min_frac, /* o : lower pitch limit */ - Word16 *T0_max, /* o : higher pitch limit */ - Word16 *T0_max_frac, /* o : higher pitch limit */ - const Word16 pit_min, /* i : Minimum pitch lag */ - const Word16 pit_max /* i : Maximum pitch lag */ -); - -void inov_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ -); - -void inov_decode_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ -); - -void dec_acelp_4t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 nbbits, /* i : number of bits per codebook */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - const Word16 Opt_AMR_WB ); - -void D_ACELP_decode_43bit_fx( - UWord16 idxs[], - Word16 code[], - Word16 *pulsestrack ); - -void D_ACELP_indexing_fx( - Word16 code[], - PulseConfig config, - Word16 num_tracks, - Word16 index[], - Word16 *BER_detect ); - -void fcb_pulse_track_joint_decode_fx( - UWord16 *idxs, - Word16 wordcnt, - UWord32 *index_n, - Word16 *pulse_num, - Word16 track_num ); - -void dec_acelp_2t32_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[] /* o: algebraic (fixed) codebook excitation */ -); - -void dec_acelp_1t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ - const Word16 L_subfr /* i : sub frame lenght*/ -); - -ivas_error acelp_core_switch_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ - Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ - const Word16 output_frame, /* i : input frame length */ - const Word16 core_switching_flag, /* i : core switching flag */ - Word16 *mem_synth, /* o : synthesis to overlap */ - Word16 *Q_syn ); - -ivas_error acelp_core_switch_dec_bfi_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -); - -ivas_error acelp_core_switch_dec_bfi_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ -); - -void pred_lt4( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ -); - -void pred_lt4_ivas_fx( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word32 *win, /* i : interpolation window Q31*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ -); - -void pred_lt4_tc_fx( - Word16 exc[], /* i/o: excitation buffer Q0*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i: fraction of lag Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 imp_pos, /* i : glottal impulse position Q0*/ - const Word16 i_subfr /* i : subframe index Q0*/ -); - -void pvq_decode_frame_fx( - Decoder_State *st_fx, - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ -); - -Word16 pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - -Word16 ivas_pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, /* Q3 */ - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - -void decode_energies_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 Np, - Word16 *dim_part, - Word16 *bits_part, - Word16 *g_part, /* Q15 */ - Word16 qband, - Word16 *bits_left, - Word16 dim, - const Word16 strict_bits ); - -void rc_dec_init_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 tot_bits /* i : Total bit budget */ -); - -/* o : Decoded cumulative frequency */ -UWord32 rc_decode_fx( - Word16 *BER_detect, /* o : Bit error detection flag */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Total cumulative frequency */ -); - -void rc_dec_update_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - - UWord32 cum_freq, /* i : Cumulative frequency */ - UWord32 sym_freq /* i : Symbol frequency */ -); - -/* o : Decoded value */ -Word32 rc_dec_bits_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 bits /* i : Number of bits */ -); - -/* o : Decoded value */ -UWord32 rc_dec_uniform_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Maximum value */ -); - -void rc_dec_finish_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ -); - -void pvq_decode_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 *xq, /* o: decoded vector (Q15) */ - Word16 *y, /* o: decoded vector (non-scaled int) */ - const Word16 k_val, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ -); -void nelp_decoder_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ - Word16 *exc, /* o : adapt. excitation exc Q_exc */ - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate Q0 */ - const Word16 coder_type, /* i : coding type Q0 */ - Word16 *gain_buf /* Q14 */ -); - -void decod_nelp_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ - Word16 *exc_fx, /* o : adapt. excitation exc */ - Word16 *exc2_fx, /* o : adapt. excitation/total exc */ - Word16 *voice_factors, /* o : Voice factor */ - Word16 *bwe_exc, - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate */ - Word16 *gain_buf /*Q14*/ -); - -void lp_filt_exc_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 codec_mode, /* i : coder mode */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 L_subfr, /* i : subframe size */ - const Word16 L_frame, /* i : frame size */ - Word16 lp_flag, /* i : operation mode signalling */ - Word16 *exc ); - -void FEC_lsf2lsp_interp( - Decoder_State *st, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *Aq, /* o : calculated A(z) for 4 subframes */ - Word16 *lsf, /* o : estimated LSF vector */ - Word16 *lsp /* o : estimated LSP vector */ -); - -ivas_error createFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -void initFdCngDec_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - const Word16 scale ); - -/* Delete the instance of type FD_CNG */ -void deleteFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - -/* Configure CLDFB-CNG */ -void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ - Word16 bandwidth, - Word32 bitrate, - Word16 L_frame, - const Word16 Last_L_frame, - const Word16 element_mode ); - -Word16 ApplyFdCng_fx( - Word16 *timeDomainInput, /* i : pointer to time domain input */ - Word16 Q, - Word32 *powerSpectrum, - Word16 Q_power_spectrum, - Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ - Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ - Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ - Decoder_State *st, - const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ - Word16 is_music ); - -/* Perform noise estimation */ -void perform_noise_estimation_dec_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain i */ - const Word16 Q, - HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void perform_noise_estimation_dec_ivas_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain input */ - const Word16 Q, - Word32 *power_spectrum, - Word16 Q_power_spectrum, - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - const Word16 VAD /* i : VAD flag in the decoder */ -); - -/* Decode the CLDFB-CNG bitstream */ -void FdCng_decodeSID_fx( - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Decoder_State *corest ); /* i/o: decoder state structure */ - -void noisy_speech_detection_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ - const Word16 vad, /* i : VAD flag */ - const Word16 *syn, /* i : i time-domain frame */ - const Word16 Q ); - -void generate_comfort_noise_dec_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ -); - -void generate_comfort_noise_dec_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ -); - -void generate_comfort_noise_dec_hf_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec ); - -void generate_comfort_noise_dec_hf_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of input bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ -); - -/* Generate the comfort noise based on the target noise level */ -void generate_masking_noise_fx( - Word16 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 Q, - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 length, - Word16 core ); - -void generate_masking_noise_update_seed_fx( - HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ -); - -void generate_masking_noise_mdct_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 L_frame ); - -void generate_masking_noise_mdct_ivas_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); - -ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o : Decoder static variables structure */ - const Word16 idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ -); - -void reset_preecho_dec_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -); - -void destroy_cldfb_decoder_fx( - Decoder_State *st_fx /* o: Decoder static variables structure */ -); - -void destroy_cldfb_encoder_fx( - Encoder_State *st /* i/o: state structure */ -); - -Word16 WB_BWE_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *WB_fenv /*Q15*/ -); - -Word16 wb_bwe_dec_fx( - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *Qpost ); - -/* o : BWE class */ -Word16 swb_bwe_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 core, /* i : core */ - Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ - Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ - const Word16 hr_flag, /* i : high rate flag */ - const Word16 hqswb_clas /* i : HQ BWE class */ -); - -/*o :Q_syn_hb*/ -Word16 swb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *Qpost ); - -void fd_bwe_dec_init( - Decoder_State *st_fx, /* i/o: decoder state structure */ - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void hq_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *audio_fx, /* i : input audio signal Q0 */ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ -); - -void hq_core_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word16 synth[], /* o : output synthesis Q_synth*/ - Word16 *Q_synth, /* o : Q value of synth */ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ -); - -void HQ_core_dec_init_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ -); - -void HQ_nbfec_init_fx( - HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ -); - - -void hq_ecu_fx( - const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ - Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ - Word16 *time_offs, - Word16 *X_sav, - Word16 *Q_spec, /* i/o : Q value of stored spectrum */ - Word16 *num_p, - Word16 *plocs, - Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ - const Word16 env_stab, - Word16 *last_fec, - const Word16 ph_ecu_HqVoicing, - Word16 *ph_ecu_active, /* i : Phase ECU active flag */ - Word16 *gapsynth, - const Word16 prev_bfi, /* i : indicating burst frame error */ - const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ - Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ - Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ - Word16 *beta_mute, /* o : Factor for long-term mute */ - const Word16 output_frame, /* i : frame length */ - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -void hq_lr_dec_fx( - Decoder_State *st_fx, /* i/o: : decoder state structure */ - Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ - const Word16 inner_frame, /* i : Q0 : inner frame length */ - Word16 num_bits, /* i : Q0 : number of available bits */ - Word16 *is_transient_fx /* o : Q0 : transient flag */ -); - -/* o : Number of bits Q0*/ -Word16 decode_envelope_indices_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : starting band index Q0*/ - const Word16 num_sfm, /* i : Number of subbands Q0*/ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ - Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ -); - -void dequantize_norms_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : First SDE encoded norm Q0*/ - const Word16 num_sfm, /* i : Number of norms Q0*/ - const Word16 is_transient, /* i : Transient flag Q0*/ - Word16 *ynrm, /* o : Decoded norm indices Q0*/ - Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ -); - -void hdecnrm_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* (i) number of norms Q0*/ - Word16 *index ); /* (o) indices of quantized norms Q0*/ - -Word16 decode_huff_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *hufftab, - Word16 *rbits ); - -void hdecnrm_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* Q0 */ - Word16 *index, /* Q0 */ - Word16 *n_length /* Q0 */ -); - -void hdecnrm_resize_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs Q0*/ - Word16 *index /* (o) norm quantization index vector Q0*/ -); - -void huff_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : Number of codewords to decode Q0*/ - const Word16 buffer_len, /* i : Number of bits to read Q0*/ - const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ - const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ - const Word16 *offset, /* i : Offset for first codeword Q0*/ - const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ - Word16 *index /* o : Decoded index Q0*/ -); - -void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms Q0*/ - Word16 *index /* o : indices of quantized norms Q0*/ -); - -void tcq_core_LR_dec_fx( - Decoder_State *st_fx, - Word16 *inp_vector_fx, /*x5 */ - const Word16 bit_budget, /*Q0 */ - const Word16 BANDS, /*Q0 */ - const Word16 *band_start, /*Q0 */ - const Word16 *band_width, /*Q0 */ - Word32 *Rk_fx, /*Q16*/ - Word16 *npulses, /*Q0 */ - Word16 *k_sort, /*Q0 */ - const Word16 *p2a_flags, /*Q0 */ - const Word16 p2a_bands, /*Q0 */ - const Word16 *last_bitalloc, /*Q0 */ - const Word16 input_frame, /*Q0 */ - const Word16 adjustFlag, /*Q0 */ - const Word16 *is_transient /*Q0 */ -); - -void HQ_FEC_processing_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ - Word16 is_transient, /* i : Old flag for transient */ - Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ - Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ - Word16 num_Sb, /* i : Number of sub-band group */ - Word16 nb_sfm, /* i : Number of sub-band */ - Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ - Word16 output_frame, /* i : Frame size */ - const Word16 *sfm_start, /* i : Start of bands */ - const Word16 *sfm_end /* i : End of bands */ -); - -void HQ_FEC_Mem_update_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /*Q12*/ - Word32 *normq_fx, /*Q14*/ - Word16 *ynrm, - Word16 *Num_bands_p, - Word16 is_transient, - Word16 hqswb_clas, - Word16 c_switching_flag, - Word16 nb_sfm, - Word16 num_Sb, - Word16 *mean_en_high_fx, /*Q5*/ - Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ); - -void time_domain_FEC_HQ_fx( - Decoder_State *st_fx, /* i : Decoder State */ - Word32 *wtda_audio_fx, /* i : i */ - Word16 *out_fx, /* o : output audio */ - Word16 mean_en_high_fx, /* i : transient flag */ - const Word16 output_frame, - Word16 *Q_synth ); - -void hq_pred_hb_bws_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *ynrm, /* i : norm quantization index vector Q0*/ - const Word16 length, /* i : frame length Q0*/ - const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ -); - -void hq_hr_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ - const Word16 length, /* i : frame length Q0 */ - Word16 num_bits, /* i : number of available bits Q0 */ - Word16 *ynrm, /* o : norm quantization index vector Q0 */ - Word16 *is_transient, /* o : transient flag Q0 */ - Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ - Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q1 */ -); - -/* o : Consumed bits */ -Word16 hq_classifier_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : Core bit rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - Word16 *is_transient, /* o : Transient flag Q0 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); - -void hvq_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 num_bits, /* i : Number of available bits */ - const Word32 core_brate, /* i : Core bit-rate */ - const Word16 *ynrm, /* i : Envelope coefficients Q0 */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *noise_level, /* o : Noise level in Q15 */ - Word16 *peak_idx, /* o : Peak position vector */ - Word16 *Npeaks, /* o : Total number of peaks */ - Word32 *coefsq_norm, /* o : Output vector in Q12 */ - const Word16 core ); - -Word16 hvq_pvq_bitalloc_fx( - Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ - const Word32 brate, /* i : bitrate */ - const Word16 bwidth_fx, /* i : Encoded bandwidth */ - const Word16 *ynrm, /* i : Envelope coefficients */ - const Word32 manE_peak, /* i : Peak energy mantissa */ - const Word16 expE_peak, /* i : Peak energy exponent */ - Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ - Word16 *R, /* Q0 i/o: Global bit allocation */ - Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ - Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ -); - -void hq_configure_bfi_fx( - Word16 *nb_sfm, /* o : Number of sub bands Q0*/ - Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ - Word16 *num_bands_p, /* o : FEC sub bands Q0*/ - const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ - const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ - const Word16 **sfm_end /* o : Subband end coefficients Q0*/ -); - -void bandwidth_switching_detect_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); - -void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ -); - -void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ -); - -ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -); - -ivas_error core_switching_post_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - const Word16 nchan_out, /* i : number of output channels Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ -); - -void core_switching_hq_prepare_dec_fx( - Decoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 output_frame /* i : output frame length Q0*/ -); - -ivas_error amr_wb_dec_fx( - Word16 output_sp[], /* o : synthesis output */ - Decoder_State *st_fx /* o : Decoder static variables structure */ -); - -void amr_wb_dec_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ -); - -void updt_dec_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 *old_exc_fx, /* i : buffer of excitation */ - const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ - const Word16 Es_pred, /* i : predicited scaled innovation energy */ - const Word16 *Aq, /* i : A(z) quantized for all subframes */ - const Word16 *lsf_new_fx, /* i : current frame LSF vector */ - const Word16 *lsp_new_fx, /* i : current frame LSP vector */ - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ - const Word16 *gain_buf /*Q14*/ -); - -void updt_IO_switch_dec_fx( - const Word16 output_frame, /* i : output frame length */ - Decoder_State *st_fx /* o : Decoder static variables structure */ -); - -void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost ); - -void updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ -); - -void update_decoder_LPD_cng( - Decoder_State *st, - Word16 coder_type, - Word16 *timeDomainBuffer, - Word16 *A, - Word16 *bpf_noise_buf ); - -void FEC_clas_estim_fx( - Decoder_State *st_fx, /* i/o: decoder state handle */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ - const Word16 L_frame, /* i : length of the frame */ - Word16 *clas, /* i/o: frame classification */ - const Word16 coder_type, /* i : coder type */ - const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ - Word16 *syn, /* i : synthesis buffer */ - Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ - Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ - Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ - Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ - Word16 *Last_ener, /* i/o: last_energy frame A*/ - Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ - Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ - Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ - Word16 Q_syn, /* i : Synthesis scaling */ - Word16 *class_para, /* o : classification para. fmerit1 A*/ - Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ - Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ - Word16 mode, /* i : signal classifier mode B*/ - Word16 bfi, /* i : bad frame indicator B*/ - Word32 last_core_brate, /* i : bitrate of previous frame */ - const Word16 FEC_mode /* i : ACELP FEC mode */ -); - -Word16 FEC_pos_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ - Word32 *enr_q, /* o : decoded energy in Q0 */ - const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ -); - -void post_decoder( - Decoder_State *st, - Word16 synth_buf[], /* Q0 */ - Word16 pit_gain[], /* Q14 */ - Word16 pitch[], /* Q0 */ - Word16 signal_out[], /* Q0 */ - Word16 *bpf_noise_buf /* Q0 */ -); - -void post_decoder_ivas_fx( - Decoder_State *st, - Word16 synth_buf[], // Q0 - Word16 pit_gain[], // Q14 - Word16 pitch[], // Q0 - Word16 signal_out[], // Q0 - Word16 *bpf_noise_buf // Q0 -); - -void cldfb_synth_set_bandsToZero( - Decoder_State *st, - Word32 **rAnalysis, - Word32 **iAnalysis, - const Word16 nTimeSlots, - const CLDFB_SCALE_FACTOR scaleFactor ); - -void FEC_pitch_estim_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 last_core, /* i : last core */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 clas, /* i : current frame classification */ - const Word16 last_good, /* i : last good clas information */ - const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ - const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ - Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ - Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ - Word16 *upd_cnt, /* i/o: update counter */ - const Word16 coder_type, /* i : coder_type */ - Word16 element_mode /* i : element mode */ -); - -void FEC_scale_syn_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ - Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ - Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const Word16 *pitch, /* i: pitch values for each subframe */ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ - Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ - Word16 *exc, /* i/o: excitation signal without enhancement */ - Word16 *exc2, /* i/o: excitation signal with enhancement */ - Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ - Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ - Word16 *mem_syn, /* o: initial synthesis filter states */ - Word16 Q_exc, - Word16 Q_syn, - const Word16 element_mode, /* i : element mode */ - const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i : force scaling */ -); - -void LD_music_post_filter_fx( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const Word16 dtc_in[], /* i : i synthesis Qdct */ - Word16 dtc_out[], /* o : output synthesis Qdct */ - const Word32 core_brate, /* i : core bitrate Q0 */ - Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ - const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ - const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ -); - -void Prep_music_postP_fx( - Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ - Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ - Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ - const Word16 last_core, /* i : last core */ - const Word16 element_mode, /* i : element mode */ - const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ - Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 *qdct /* o : Scaling factor of dct coefficient */ -); - -void Post_music_postP_fx( - Word16 dct_buffer_in[], /* i/o: excitation buffer */ - Word16 *exc2, /* i/o: Current excitation to be overwriten */ - const Word16 *mem_tmp, /* i : previous frame synthesis memory */ - Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ - const Word16 *Aq, /* i : LPC filter coefficients */ - Word16 *syn, /* i/o: 12k8 synthesis */ - Word16 *Q_exc, /* i : excitation scaling */ - Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ - Word16 *Q_syn, /* i : Current frame synthesis scaling */ - Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ - const Word16 IsIO, /* i : Flag to indicate IO mode */ - Word16 *mem_deemph, /* i/o: speech deemph filter memory */ - Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ - Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ - Word16 *mem_agc, - PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ - Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ -); - -void music_postfilt_init( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ -); - -void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class Q0*/ - const Word16 coder_type, /* i : coder type Q0*/ - const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ - Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ - Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ - const Word16 locattack, /* i : Flag for a detected attack Q0*/ - Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ - Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ - Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ - const Word16 Q_syn, /* i : Synthesis scaling */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ - const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ - const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ - const Word16 last_coder_type /* i : Last coder_type Q0*/ -); - -void decod_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficients */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ -); - -void CNG_reset_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ - Word16 *voice_factors /* o : voicing factors Q15*/ -); - -ivas_error ppp_voiced_decoder_fx( - Decoder_State *st_fx, /* i/o: state structure */ - Word16 *out_fx, /* o : residual signal */ - const Word16 *lpc2_fx, /* i : current frame LPC */ - Word16 *exc_fx, /* i : previous frame excitation */ - Word16 *pitch, /* o : floating pitch values for each subframe */ - Word16 bfi /* i : Frame error rate */ -); - -void sc_vbr_dec_init( - SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ -); - -ivas_error ppp_quarter_decoder_fx( - DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ - Word16 prevCW_lag_fx, /* i : Previous lag */ - Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ - Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ - Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ - Word16 bfi, /* i : FER flag */ - Word16 *S_fx, /* i : sine table, Q15 */ - Word16 *C_fx, /* i : cosine table, Q15 */ - DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ - Decoder_State *st_fx ); - -void open_decoder_LPD_fx( - Decoder_State *st, - const Word32 total_brate, /* Q0 */ - const Word16 bwidth /* Q0 */ -); - -void open_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - -void reset_tcx_overl_buf_fx( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ -); - -void acelp_plc_mdct_transition_fx( - Decoder_State *st /* i/o: Decoder state */ -); - -void cldfb_reset_memory_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void tcxltp_dec_init_fx( - TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ - const Word16 ini_frame, /* Q0 */ - const Word16 last_codec_mode, /* Q0 */ - const Word16 element_mode, /* Q0 */ - const Word16 pit_max, /* Q0 */ - const Word32 sr_core ); /* Q0 */ - -/* o : Exponent of SHB synthesis */ -Word16 swb_bwe_dec_hr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ - const Word16 exp, /* i : Exponent of core synthesis */ - Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ - const Word16 output_frame, /* i : frame length */ - const Word16 unbits, /* i : number of core unused bits */ - const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ -); - -void hr_bwe_dec_init( - HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ -); - -void swb_hr_noise_fill_fx( - const Word16 is_transient, /* i : transient flag */ - const Word16 spect_start, /* i : spectrum start point */ - const Word16 spect_end, /* i : spectrum end point */ - const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ - const Word16 pitch, /* i : pitch value Q15 */ - const Word16 nq[], /* i : AVQ nq index */ - Word16 Nsv, /* i : number of subband */ - Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ - Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ - Word16 Q_audio ); - -void stat_noise_uv_dec_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ - Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ - Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ - const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ -); - -void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ - Word16 *exc2, /* i/o: excitation buffer Q_exc */ - Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q15 */ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : input bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ -); - -void stat_noise_uv_mod_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q=0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ - Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q=15*/ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : i bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ -); - -Word16 FEC_SinOnset_fx( - Word16 *exc, /* i/o : exc vector to modify */ - Word16 puls_pos, /* i : last pulse position desired */ - const Word16 T0, /* i : Pitch information of the 1 subfr */ - Word32 enr_q, /* i : energy provide by the encoder */ - Word16 *Aq, /* i : A(z) filter Q12 */ - const Word16 L_frame, /* i : frame length */ - const Word16 Qold ); - -Word16 FEC_enhACB_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 last_L_frame, /* i : frame length of previous frame */ - Word16 *exc_io, /* i/o : adaptive codebook memory */ - const Word16 new_pit, /* i : decoded first frame pitch */ - const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ - const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ -); - -/*! r: do_WI flag */ -Word16 FEC_synchro_exc_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* i/o: exc vector to modify */ - const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ - const Word16 true_puls_pos, /* i : Present pulse location */ - const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ -); - -void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ - Word16 *gain_buf ); - -void gaus_dec_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* o : unvoiced excitation Q12 */ - Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ - Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ - Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ - Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ - Word16 *voice_fac, /* o : estimated voicing factor Q15 */ - Word16 *gain_pit, /* o : pitch gain Q14 */ - Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ - Word16 *exc, /* o : excitation signal frame */ - Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ - Word16 *exc2, /* o : Scaled excitation signal frame */ - Word16 *bwe_exc_fx, - Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ - Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ -); - -void gaus_L2_dec( - Word16 *code, /* o : decoded gaussian codevector Q9 */ - Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *A, /* i : quantized LPCs Q12 */ - Word16 formant_enh, /* i : formant enhancement factor Q15 */ - Word16 *seed_acelp /*i/o : random seed Q0 */ -); - -ivas_error decod_gen_voic_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ -); - -void decod_tran_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ - Word16 *unbits, /* i/o: number of unused bits */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 *gain_buf /*Q14*/ -); - -void transition_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *exc, /* o : excitation signal */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - Word16 **pt_pitch, /* o : floating pitch values */ - Word16 *position, /* i/o: first glottal impulse position in frame */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *Q_exc /*i/o : scaling of excitation */ -); - -Word16 tc_classif_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame /* i : length of the frame */ -); - -ivas_error decod_ppp_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ - Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation */ - Word16 *exc2_fx, /* i/o: current enhanced excitation */ - Word16 bfi, /* i : bad frame indicator */ - Word16 *gain_buf, /*Q14*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ -); - -void swb_bwe_dec_lr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis : QsL */ - const Word16 QsL, /* i : Q value of m_core */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ - Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ - Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ - Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ - const Word16 hqswb_clas_fx, /* i : class information : Q0 */ - Word16 lowlength_fx, /* i : Lowband Length : Q0 */ - Word16 highlength_fx, /* i : Highband Length : Q0 */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ - Word16 *prev_frm_hfe2, /* i/o: : Q0 */ - Word16 *prev_stab_hfe2, /* i/o: : Q0 */ - Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ - const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ - Word16 *ni_seed_fx /* i/o: random seed : QsL */ -); - -Word16 dec_acelp_tcx_frame_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *concealWholeFrame, /* i/o: concealment flag */ - Word16 *pcmBuf, /* o : synthesis */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 *pcmbufFB, /* o : synthesis @output_FS */ - Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 pitch_buf[] /* o : floating pitch for each subframe */ -); - -void decoder_LPD_fx( - Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ - Word16 signal_outFB[], /* o : synthesis @output_FS */ - Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ - Decoder_State *st, /* i/o: decoder memory state pointer */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 bfi, /* i : BFI flag */ - Word16 *bitsRead, /* o : number of read bits */ - Word16 param[], /* o : buffer of parameters */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ -); - -void mode_switch_decoder_LPD_fx( - Decoder_State *st, /* Q0 */ - Word16 bandwidth_in, /* Q0 */ - Word32 bitrate, /* Q0 */ - Word16 frame_size_index /* Q0 */ -); - -void mode_switch_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ - const Word16 frame_size_index, /* i : index determining the frame size Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - -Word16 DecodeIndex( - Decoder_State *st, - const Word16 Bandwidth, /* o : NB, 1: (S)WB */ - Word16 *PeriodicityIndex ); - -Word16 DecodeIndex_fx( - Decoder_State *st, - const Word16 Bandwidth, - Word16 *PeriodicityIndex ); - -void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ -); - -Word16 lsf_msvq_ma_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ -); - -Word16 lsf_bctcvq_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ -); - -Word16 D_lsf_tcxlpc( - const Word16 indices[], /* i : VQ indices Q0*/ - Word16 lsf_q[], /* o : quantized LSF Q1*/ - Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk, /* i : codebook selector Q0*/ - Word16 mem_MA[] /* i : MA memory Q1*/ -); - -Word16 dec_lsf_tcxlpc( - Decoder_State *st, /* i/o: Decoder state */ - Word16 **indices, /* o : Ptr to VQ indices Q0*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk /* i : codebook selector Q0*/ -); - -void midlsf_dec( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 idx, /* i: codebook index */ - Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ - const Word16 coder_type, - Word16 *mid_lsf_int, - const Word16 prev_bfi, - const Word16 safety_net ); - -Word16 lsf_ind_is_active( - const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ - const Word16 means[], /*(14Q1*1.28)*/ - const Word16 narrowband, - const Word16 cdk ); - -void IGFSCFDecoderOpen( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ - H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const Word32 total_brate, - const Word16 bwidth, - const Word16 element_mode, - const Word16 rf_mode ); - -void IGFSCFDecoderReset( - IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ -); - -void IGFSCFDecoderDecode( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - Decoder_State *st, /* i/o: pointer to decoder state */ - Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, - if 0 on input the decoder will be forced to encode without a reset */ -); - -Word32 ari_decode_overflow_fx( - Tastat *s ); - -void ari_start_decoding_14bits_fx( - Decoder_State *st, - Tastat *s ); - -Word16 ari_start_decoding_14bits_prm_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - -Word16 ari_decode_14bits_s17_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - -Word16 ari_decode_14bits_s27_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - -Word16 ari_decode_14bits_bit_ext_fx( - Decoder_State *st, - Tastat *s ); - -Word16 ari_decode_14bits_pow_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - Word16 base ); - -Word16 ari_decode_14bits_sign_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - -void getTCXparam_fx( - Decoder_State *st, /* i/o: Decoder State handle */ - Decoder_State *st0, /* i : bitstream */ - CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - Word16 param[], /* o : decoded parameters Q0 */ - const Word16 bits_common, /* i : number of common bits Q0 */ - const Word16 start_bit_pos, /* i : position of the start bit Q0 */ - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ - Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ - Word16 nTnsBitsTCX10[2], /*Q0*/ - const Word16 pre_past_flag /*Q0*/ -); - -void dec_prm_fx( - Word16 *coder_type, - Word16 param[], /* (o) : decoded parameters */ - Word16 param_lpc[], /* (o) : LPC parameters */ - Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ - Decoder_State *st, - Word16 L_frame, - Word16 *bitsRead ); - -void getLPCparam_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Word16 param_lpc[], /* o : LTP parameters Q0 */ - Decoder_State *st0, /* i : bitstream */ - const Word16 ch, /* i : channel Q0 */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ -); - -void UnmapIndex( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word16 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ -); - -void ConfigureContextHm( - const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ - const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ - const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ - const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ -); - -Word16 CountIndexBits( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ - Word16 PeriodicityIndex /* Q0 */ -); - -Word32 tcx_hm_render( - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ -); - -void tcx_hm_modify_envelope( - Word16 gain, /* i: HM gain Q11 */ - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - Word16 L_frame /* i: number of spectral lines Q0 */ -); - -Word16 ReadTnsData( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -void ReadTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -Word16 DecodeTnsData( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -Word16 DecodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -void GetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void const *pParameter, - Word16 **pStream, - Word16 *pnSize, - Word16 *pnBits ); - -void GetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, // Q0 - void const *pParameter, // Q0 - Word16 **pStream, // Q0 - Word16 *pnSize, // Q0 - Word16 *pnBits // Q0 -); - -void EncodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream Q0*/ - Word16 *pnSize, /* o : number of written parameters Q0*/ - Word16 *pnBits /* o : number of written bits Q0*/ -); - -void SetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - -void SetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - -void WriteToBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - -void ReadFromBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - -void ReadFromBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - -void IGFDecReadData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ -); - -void IGFDecReadLevel( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ -); - -void IGFDecApplyMono( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ -); - -void IGFDecApplyMono_ivas( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ - Word16 element_mode /**< in: | IVAS element mode */ -); - -void IGFDecApplyStereo( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ - Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ - Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ - Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ - const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 *coreMsMask, - const Word16 restrict_hopsize, - const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping ); - -void IGFDecSetMode( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void IGFDecSetMode_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void IGFDecUpdateInfo( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 igfGridIdx /**< in: | IGF grid index */ -); - -void IGFDecUpdateInfo_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const Word16 subFrameIdx, /* i : subframe index */ - const Word16 igfGridIdx /* i : IGF grid index */ -); - -void IGFDecCopyLPCFlatSpectrum( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ -); - -void IGFDecCopyLPCFlatSpectrum_fx( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ -); - -void IGFDecStoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ -); - -void IGFDecRestoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ -); - -void IGFDecRestoreTCX10SubFrameData_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word16 subFrameIdx /* i : index of subframe */ -); - -void init_igf_dec( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ -); - -Word16 dlpc_avq_fx( - Word16 *index, /* (i) Quantization indices */ - Word16 *LSF_Q, /* (o) Quantized LSF vectors */ - Word16 numlpc, /* (i) Number of sets of lpc */ - Word32 sr_core ); - -Word16 decode_lpc_avq_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ -); - -Word16 decode_lpc_avq_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc, /* o : lpc parameters */ - const Word16 ch, /* i : channel */ - const Word16 element_mode, /* i : element mode */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ -); - -void vlpc_1st_dec( - Word16 index, /* i : codebook index */ - Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ - -void vlpc_2st_dec( - Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - Word16 *indx, /* i : index[] (4 bits per words) */ - Word16 mode, /* i : 0=abs, >0=rel */ - Word32 sr_core ); - -void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ - const Word16 mode /* input: operational mode Q0 */ -); - -/* Returns: index of next coefficient */ -Word16 get_next_coeff_mapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -/* Returns: index of next coefficient */ -Word16 get_next_coeff_unmapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -Word16 update_mixed_context( - Word16 ctx, /* Q0 */ - Word16 a /* Q0 */ -); - -Word32 update_mixed_context_ivas_fx( - Word32 ctx, /* Q0 */ - Word16 a /* Q0 */ -); - -typedef Word16 ( *get_next_coeff_function )( - Word16 ii[2], /* i/o: coefficient indexes */ - Word16 *pp, /* o : peak(1)/hole(0) indicator */ - Word16 *idx, /* o : index in unmapped domain */ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -Word16 ACcontextMapping_decode2_no_mem_s17_LC( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o: decoded spectrum */ - Word16 nt, /* i: size of spectrum */ - Word16 nbbits, /* i: bit budget */ - Word16 resQMaxBits, /* i: residual coding maximum bits*/ - CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ -); - -Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o : decoded spectrum */ - const Word16 nt, /* i : size of spectrum */ - const Word16 nbbits, /* i : bit budget */ - const Word16 resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ -); - -void reconfig_decoder_LPD_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 bits_frame, /* i : bit budget Q0*/ - Word16 bwidth, /* i : audio bandwidth Q0*/ - Word32 total_brate, /* i : total bitrate Q0*/ - Word16 L_frame_old /* i : frame length Q0*/ -); - -void reconfig_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bits_frame, /* i : bit budget Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word16 L_frame_old /* i : frame length Q0*/ -); - -void minimumStatistics_fx( - Word16 *noiseLevelMemory, /* Q15, internal state */ - Word16 *noiseLevelIndex, /* Q0, internal state */ - Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ - Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ - Word16 *lastFrameLevel, /* Q15, level of the last frame */ - Word16 currentFrameLevel, /* Q15, level of the current frame */ - Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ - Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ - Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ - Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ - Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ - -/*10Q5*/ -Word16 getLevelSynDeemph_fx( - Word16 h1Init[], /* i: i value or vector to be processed Q15 */ - Word16 const A[], /* i: LPC coefficients Qx */ - Word16 const lpcorder, /* i: LPC order Q0 */ - Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ - Word16 const preemph_fac, /* i: preemphasis factor Q15 */ - Word16 const numLoops, /* i: number of loops Q0 */ - Word16 *Exp /* o: exponent of return value Q15 */ -); - -void genPlcFiltBWAdap_fx( - Word32 const sr_core, /*mem_syn >rescaling done */ - Word16 *pitch_buffer, - Word16 *voice_factors, - Word16 *bwe_exc ); - -void decoder_acelp_fx( - Decoder_State *st, - Word16 prm[], /* i : parameters */ - Word16 A[], /* i : coefficients NxAz[M+1] */ - ACELP_config acelp_cfg, /* i : ACELP config */ - Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ - Word16 *pT, /* out: pitch for all subframe Q0 */ - Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ - Word16 stab_fac, /* i : stability of isf */ - Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ - Word16 *voice_factors, /* out: voicing factors */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *bwe_exc /* out: excitation for SWB TBE */ -); - -void decode_acelp_gains_fx( - Word16 *code, - Word16 gains_mode, - Word16 mean_ener_code, - Word16 *gain_pit, - Word32 *gain_code, - Word16 **pt_indice, - Word16 *past_gpit, - Word32 *past_gcode, - Word16 *gain_inov, - Word16 L_subfr, - Word16 *code2, - Word32 *gain_code2 ); - -void d_gain_pred_fx( - Word16 nrg_mode, /* i : NRG mode */ - Word16 *Es_pred, /* o : predicited scaled innovation energy */ - Word16 **pt_indice /* i/o: pointer to the buffer of indices */ -); - -ivas_error evs_dec_fx( - Decoder_State *st_fx, /* i/o : Decoder state structure */ - Word16 output_sp[], /* o : output synthesis signal */ - FRAME_MODE frameMode /* i : Decoder frame mode */ -); - -void fft_cldfb_fx( - Word32 *data, /* i/o: input/output vector */ - const Word16 size /* size of fft operation */ -); - -void stereo_dft_dec_analyze_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 *input_fx, /* i : input signal q*/ - Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 input_frame, /* i : input frame size Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ - const Word16 k_offset, /* i : offset of DFT Q0*/ - const Word16 delay, /* i : delay in samples FOR input signal Q0*/ - Word16 *q, - Word16 *q_DFT ); - -void set32_fx( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -); - -void delay_signal_q_adj_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay, /* i : delay in samples */ - const Word16 q_x, - const Word16 q_mem ); - -Word32 anint_fx( - const Word32 x, /* i: Round to the nearest integer */ - const Word16 exp /* i: Exponent for round step */ -); - -Word32 ceil_fx( - const Word32 x, /* i: number to ceil */ - const Word16 exp /* i: Exponent for ceil step */ -); - -void v_add_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_shr_16( - const Word16 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word16 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ -); - -void v_shr( - const Word32 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word32 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ -); - -void cldfbAnalysis_ts_fx( - const Word32 *timeIn_fx, /* i : time buffer */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, - Word16 *q_cldfb ); - -Word16 floor_log_2( - Word32 num ); - -void cldfbAnalysis_ts_fx_var_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - -void cldfbAnalysis_ts_fx_fixed_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - -void configureCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void dec_acelp_fast_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 cdk_index, /* i : codebook index */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - const Word16 L_subfr /* i : subframe length */ -); - -void tcx5SpectrumInterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - -void tcx5SpectrumDeinterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - -void tcx5TnsGrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum ); - -void tcx5TnsUngrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum, - const Word16 enc_dec ); - -void bpf_pitch_coherence_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ -); - -/* fft_rel.c */ - -#define SIZE_256 256 -#define NUM_STAGE_256 7 -#define SIZE2_256 ( SIZE_256 / 2 ) - -void cldfbAnalysis_ivas_fx( - const Word32 *timeIn_fx, /* i : time buffer Qx */ - Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ - Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ -); - -void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ - const Word16 out_shift, /* i : scale for output buffer */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ -); - -void addBassPostFilter_ivas_fx( - const Word32 *harm_timeIn_fx, - const Word16 samplesToProcess, - Word32 **rAnalysis_fx, - Word32 **iAnalysis_fx, - HANDLE_CLDFB_FILTER_BANK cldfb ); - -/* o : Q22*/ -Word32 ism_dequant_meta_fx( - const Word16 idx, /* i : quantizer index */ - const Word32 borders_fx[], /* i : level borders Q22*/ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ - const Word16 cbsize /* i : codebook size */ -); - -void save_synthesis_hq_fec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ - const Word32 output_fx[], /* i : decoded synthesis */ - const Word16 output_frame, /* i : decoded synthesis */ - const Word16 Qpostd, /* i : Q value of delayed signal */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ -); - -void calculate_nbits_meta_fx( - const Word16 nchan_ism, - Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 - Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 - const Word16 numSf, - const Word16 numCodingBands, - Word16 *bits_ism, - const Word16 idx_sep_obj, - const Word16 ism_imp ); - -void ivas_get_stereo_panning_gains_fx( - const Word16 aziDeg, - const Word16 eleDeg, - Word16 panningGains[2] ); - -ivas_error openCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - const Word16 enc_dec ); /* i : encoder/decoder flag */ - -Word32 rand_gauss_fx( - Word32 *x, - Word16 *seed, - Word16 q ); - -void resampleCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate ); - -void generate_masking_noise_dirac_ivas_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ - Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ - Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ - const Word16 slot_index, /* i : CLDFB slot index */ - const Word16 cna_flag, /* i : CNA flag for LB and HB */ - const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ - Word16 q_input, - Word16 *q_cldfb ); - -void IMDCT_fx( - Word32 *x, - Word16 x_e, - Word16 *old_syn_overl, - Word16 *syn_Overl_TDAC, - Word16 *xn_buf, - const Word16 *tcx_aldo_window_1, - const PWord16 *tcx_aldo_window_1_trunc, - const PWord16 *tcx_aldo_window_2, - const PWord16 *tcx_mdct_window_half, - const PWord16 *tcx_mdct_window_minimum, - const PWord16 *tcx_mdct_window_trans, - Word16 tcx_mdct_window_half_length, - Word16 tcx_mdct_window_min_length, - Word16 index, - Word16 left_rect, - Word16 tcx_offset, - Word16 overlap, - Word16 L_frame, - Word16 L_frameTCX, - Word16 L_spec_TCX5, - Word16 L_frame_glob, - Word16 frame_cnt, - Word16 bfi, - Word16 *old_out, - Word16 *Q_old_wtda, - Decoder_State *st, - Word16 fullbandScale, - Word16 *acelp_zir ); - -void IMDCT_ivas_fx( - Word32 *x_fx, - Word16 q_x, - Word16 *old_syn_overl_fx, - Word16 *Q_old_syn_overl_fx, - Word16 *syn_Overl_TDAC_fx, - Word16 *Q_syn_Overl_TDAC_fx, - Word16 *xn_buf_fx, - Word16 q_xn_buf_fx, - const Word16 *tcx_aldo_window_1_fx, - const PWord16 *tcx_aldo_window_1_trunc_fx, - const PWord16 *tcx_aldo_window_2_fx, - const PWord16 *tcx_mdct_window_half_fx, - const PWord16 *tcx_mdct_window_minimum_fx, - const PWord16 *tcx_mdct_window_trans_fx, - const Word16 tcx_mdct_window_half_length, - const Word16 tcx_mdct_window_min_length, - Word16 index, - const UWord16 kernel_type, /* i : TCX transform kernel type */ - const Word16 left_rect, - const Word16 tcx_offset, - const Word16 overlap, - const Word16 L_frame, - const Word16 L_frameTCX, - const Word16 L_spec_TCX5, - const Word16 L_frame_glob, - const Word16 frame_cnt, - const Word16 bfi, - Word16 *old_out_fx, - Word16 *q_old_out_fx, - const Word16 FB_flag, - Decoder_State *st, - const Word16 fullbandScale, - Word16 *acelp_zir_fx, - Word16 *q_acelp_zir_fx, - Word16 *pq_win ); - -void v_mult16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, - const Word32 total_brate, - const Word16 L_frame, - const Word16 last_L_frame, - const Word16 element_mode ); - -Word32 sum2_f_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ -); - -Word32 sum2_f_16_gb_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - -Word32 sum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - -Word16 vq_dec_lvq_ivas_fx( - Word16 sf_flag, /* i : safety net flag */ - Word16 x[], /* o : Decoded vector Q(x2.56)*/ - Word16 indices[], /* i : Indices */ - Word16 stages, /* i : Number of stages */ - Word16 N, /* i : Vector dimension */ - Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ - Word16 no_bits /* (i): no. bits for lattice */ -); - -Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ -); - -void deleteCldfb_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ -); - -void fd_bwe_dec_init_fx( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ -); - -void stereo_dft_dec_open( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 nchan_transport /* i : number of transport channels */ -); - -void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ); - -UWord32 mvl2s_r( - const Word32 x[], /* i : input vector */ - const Word16 q, - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - -void decoder_tcx_post_ivas_fx( - Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 Q_syn, - Word16 *A, - Word16 bfi, - Word16 MCT_flag ); - -void con_tcx_ivas_fx( - Decoder_State *st, /* i/o: coder memory state */ - Word16 synth[], /* i/o: synth[] Q0 */ - const Word16 coh, /* i : coherence of stereo signal */ - Word16 *noise_seed, /* i/o: noise seed for stereo */ - const Word16 only_left, /* i : TD-PLC only in left channel */ - const Word16 *A_cng /* i : CNG LP filter coefficients */ -); - -void ivas_mdct_core_reconstruct_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ - Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ - Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - Word16 q_x, - Word16 e_sig[CPE_CHANNELS] ); - -void ari_start_encoding_14bits_ivas_fx( - Tastat *s ); - -void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i: input coefficients */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ - const Word16 alfe_flag ); - -Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( - Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ - Word16 *lastnz_out, /* Q0 */ - Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ - Word16 *stop, /* Q0 */ - Word16 mode, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ -); - -/* Qx*/ -Word16 usdequant_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta /* i: quantization step Qy*/ -); - -/* Qx*/ -Word32 usdequant32_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word32 delta /* i: quantization step Qy*/ -); - -/* o: index of the winning codeword */ -Word16 usquant_fx( - const Word16 x, /* i: scalar value to quantize Qx*/ - Word16 *xq, /* o: quantized value Qx*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta, /* i: quantization step Qx-1*/ - const Word16 cbsize /* i: codebook size */ -); - -/* o : Sum */ -Word32 Dot_product( - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg /* i : vector length */ -); - -/* o : dot product of x[] and y[] */ -Word32 dotp_fx( - const Word16 x[], /* i : vector x[] */ - const Word16 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 *exp /* (o) : exponent of result (0..+30) */ -); - -/* o : sum of all squared vector elements Q(2x+1)*/ -Word32 sum2_fx_mod( - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ -); - -void Copy_Scale_sig( - const Word16 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Scale_sig32( - Word32 x[], /* i/o: signal to scale Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_16_32_DEPREC( - const Word16 x[], /* i : signal to scale i Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_16_32_r( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_16_32_no_sat( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Copy_Scale_sig_32_16( - const Word32 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void Random_Fill( - Word16 *seed, /* i/o: random seed */ - Word16 n, /* i : number of values */ - Word16 *y, /* o : output values */ - Word16 scaling /* i : scaling of values */ -); - -/* o : mean of vector */ -Word16 mean_fx( - const Word16 *vec_fx, /* i : i vector */ - const Word16 lvec_fx /* i : length of i vector */ -); - -/* o : mean of vector Qx */ -Word16 mean_no_sat_fx( - const Word16 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx /* i : length of input vector */ -); - -/* o : mean of vector Qx */ -Word32 mean_no_sat_Word32_fx( - const Word32 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx, /* i : length of input vector */ - const Word16 gb ); -void sort( - UWord16 *x, /* i/o: Vector to be sorted */ - UWord16 len /* i/o: vector length */ -); - -void sort_fx( - Word16 *r, /* i/o: Vector to be sorted in place */ - Word16 lo, /* i : Low limit of sorting range */ - Word16 up /* I : High limit of sorting range */ -); - -void sort_32_fx( - Word32 *r, /* i/o: Vector to be sorted in place */ - const Word16 lo, /* i : Low limit of sorting range */ - const Word16 up /* I : High limit of sorting range */ -); - -/* o : index of the minimum value in the input vector */ -Word16 minimum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *min_fx /* o : minimum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *max_fx /* o : maximum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_exp_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 *exp_vec, /* i : exponents of input vector */ - const Word16 lvec_fx /* i : length of input vector */ -); - -/* o : index of the maximum abs value in the input vector */ -Word16 maximum_abs_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max_val /* o : maximum value in the input vector */ -); - -/* o : index of the minimum value in the input vector */ -Word16 minimum_abs32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ -); - -/* o : index of the minimum value in the input vector */ -Word16 minimum_32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/* o : index of the maximum value in the input vector */ -Word16 maximum_abs_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the maximum value in the input vector */ -Word16 maximum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ -); - -Word16 Exp16Array( - const Word16 n, /* (i): Array size */ - const Word16 *sx /* (i): Data array */ -); - -Word16 Exp32Array( - const Word16 n, /* (i): Array size */ - const Word32 *sx /* (i): Data array */ -); - -/* o : sum of all vector elements Qx*/ -Word32 sum16_32_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -/* o : sum of all vector elements Qx*/ -Word32 sum32_sat( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -/* o: variance of vector Qx+16*/ -Word32 var_fx_32( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ -); - -/* o: variance of vector Qx+16*/ -Word32 var_fx_32in_32out( - const Word32 *x, /* i: input vector Qx*/ - Word16 *Qx, - const Word16 len, /* i: length of inputvector */ - const Word16 gb ); - -/* o: variance of vector Qx*/ -Word16 var_fx( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ -); - -/* o: variance of vector Qx*/ -Word16 std_fx( - const Word16 x[], /* i: input vector */ - const Word16 len /* i: length of the input vector */ -); - -/* o : the dot product x'*A*x */ -Word32 dot_product_mat_fx( - const Word16 *x, /* i : vector x Q15 */ - const Word32 *A, /* i : matrix A Q0*/ - const Word16 m /* i : vector & matrix size */ -); - -void Vr_subt( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 N /* i : Vector lenght */ -); - -/* o: index of the winning codevector */ -Word16 vquant_ivas_fx( - Word32 x[], /* i: vector to quantize Q25 */ - const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ - Word32 xq[], /* o: quantized vector Q25 */ - const Word32 cb[], /* i: codebook Q25 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ -); - -/* o: index of the winning codevector */ -Word16 vquant_fx( - Word16 x[], /* i: vector to quantize Q13 */ - const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ - Word16 xq[], /* o: quantized vector Q13 */ - const Word16 cb[], /* i: codebook Q13 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ -); - -Word16 w_vquant_fx( - Word16 x[], /* i: vector to quantize in Q10 */ - Word16 Qx, - const Word16 weights[], /* i: error weights in Q0 */ - Word16 xq[], /* o: quantized vector in Q15 */ - const Word16 cb[], /* i: codebook in Q15 */ - const Word16 cbsize, /* i: codebook size */ - const Word16 rev_vect /* i: reverse codebook vectors */ -); - -/* o : return index with max energy value in vector Q0 */ -Word16 emaximum_fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word16 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ -); - -/* o : return index with max energy value in vector Q0 */ -Word16 emaximum_32fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word32 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ -); - -/* o : mean of the elements of the vector */ -Word32 Mean32( - const Word32 in[], /* i : input vector */ - const Word16 L /* i : length of input vector */ -); - -/* o : sum of all vector elements Qx*/ -Word32 sum32_fx( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -/* o : sum of all vector elements Qx*/ -Word16 sum16_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ -); - -Word16 own_random2_fx( - Word16 seed ); - -void iDiv_and_mod_32( - const Word32 Numer, /* i : 32 bits numerator */ - const Word16 Denom, /* i : 16 bits denominator */ - Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ - Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ - const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ -); - -void pz_filter_sp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word16 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - -Word32 root_a_fx( - Word32 a, - Word16 Q_a, - Word16 *exp_out ); - -Word32 root_a_over_b_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - -Word32 root_a_over_b_ivas_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - -void fir_fx( - const Word16 x[], /* i : input vector Qx*/ - const Word16 h[], /* i : impulse response of the FIR filter Q12*/ - Word16 y[], /* o : output vector (result of filtering) Qx*/ - Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ - const Word16 L, /* i : input vector size */ - const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ - const Word16 upd, /* i : 1 = update the memory, 0 = not */ - Word16 shift /* i : difference between Q15 and scaling of h[] */ -); - -void v_add_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_shr_32( - Word32 x1[], /* i : Input vector 1 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N, /* i : Vector length */ - Word16 shift /*shift value*/ -); - -void v_sub_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_add_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_sub_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -/* o: index of the winning codeword */ -Word16 squant_fx( - const Word16 x, /* i: scalar value to quantize */ - Word16 *xq, /* o: quantized value */ - const Word16 cb[], /* i: codebook */ - const Word16 cbsize /* i: codebook size */ -); - -Word16 squant_int_fx( - UWord8 x, /* i : scalar value to quantize */ - UWord8 *xq, /* o : quantized value */ - const UWord8 *cb, /* i : codebook */ - const Word16 cbsize /* i : codebook size */ -); - -void pz_filter_dp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word32 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - -void Copy_Scale_sig32_16( - const Word32 *src, /* i : signal to scale Qx */ - Word16 *dst, /* o : scaled signal Qx */ - Word16 len, /* i : size of x[] Q0 */ - Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ - -void v_multc_att( - const Word16 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word16 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_att32( - const Word32 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ -); - -void v_multc_att3232( - const Word32 x[], /* i : Input vector Qx */ - const Word32 att, /* i : Constant Q32, <= MAX_32 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ -); - -void v_L_mult_1616( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_L_mult_3216( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void add_vec_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 Qx1, /* i : SCaling of input 1 */ - const Word16 x2[], /* i : Input vector 2 */ - const Word16 Qx2, /* i : SCaling of input 1 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 Qy, /* i : SCaling of output 1 */ - const Word16 N /* i : Vector lenght */ -); - -/* o: Result (Normalized) */ -Word32 Add_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ -); - -/* o: Result (Normalized) */ -Word32 Mul_flt32_Q15( - Word32 value, /* i: Pseudo_float Value */ - Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ - Word16 frac /* i: Q15 value */ -); - -/* o: Result (Normalized) */ -Word32 Div_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ -); - -/* o: Result (Normalized) */ -Word32 Calc_Energy_Autoscaled( - const Word16 *signal, /* i: Signal */ - Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ - Word16 len, /* i: Frame Length */ - Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ -); - -Word16 Find_Max_Norm16( - const Word16 *src, - Word16 len ); - -Word16 Find_Max_Norm32( - const Word32 *src, - Word16 len ); - -/* o: Result in Q31 */ -Word32 Sqrt_Ratio32( - Word32 L_val1, /* i: Mantisa of Val1 */ - Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ - Word32 L_val2, /* i: Mantisa of Val2 */ - Word16 exp2, /* i: Exp of Val2 (same as exp1) */ - Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ -); - -/* result in Q'15 + 'exp' */ -Word16 Invert16( - Word16 val, - Word16 *exp ); - -Word16 find_rem( - Word16 n, - Word16 m, - Word16 *r ); - -Word32 find_remd( - Word32 n, - Word32 m, - Word32 *r ); - -Word16 rint_new_fx( - Word32 x /*Q16 */ -); - -Word16 erb_diff_search_fx( - Word16 *prev_erb, - const Word16 *curr_erb, - Word16 *dif_erb, - Word16 *pow_spec, - const Word16 *cb_fx, - Word16 cb_size, - Word16 cb_dim, - Word16 offset ); - -void Acelp_dec_total_exc( - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - const Word16 gain_code16, /* i : Gain code Q0 */ - const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ - const Word16 i_subfr, /* i ; subfr */ - const Word16 *code_fx, /* i : code in Q9 */ - const Word16 L_subfr /* i : Subframne lenght */ -); - -UWord32 UL_inverse( - const UWord32 UL_val, - Word16 *exp ); - -UWord32 UL_div( - const UWord32 UL_num, - const UWord32 UL_den ); - -Word16 ratio( - const Word32 numer, - const Word32 denom, - Word16 *expo ); - -void hp400_12k8_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ -); - -void hp400_12k8_ivas_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ -); - -Word16 dot_prod_satcontr( - const Word16 *x, - const Word16 *y, - Word16 qx, - Word16 qy, - Word16 *qo, - Word16 len ); - -void E_UTIL_f_convolve( - const Word16 x[], - const Word16 h[], - Word16 y[], - const Word16 size ); - -void floating_point_add( - Word32 *mx, /* io: mantissa of the addend Q31 */ - Word16 *ex, /* io: exponent of the addend Q0 */ - const Word32 my, /* i: mantissa of the adder Q31 */ - const Word16 ey /* i: exponent of the adder Q0 */ -); - -void delay_signal_fx( - Word16 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word16 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ -); - -void delay_signal32_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ -); - -Word16 lin_interp_ivas_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ -); - -Word16 lin_interp_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ -); - -Word16 ceil_log_2( - UWord64 val ); - -Word32 imax_pos_fx( - const Word32 *y /* i : Input vector for peak interpolation Qx*/ -); - -void msvq_enc_ivas_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ - const Word16 Q_cb, /* i : Codebook Q */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ - const Word16 u_e, /* i : Exponent for Vector to be encoded */ - const Word16 *levels, /* i : Number of levels in each stage */ - const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ - const Word16 stages, /* i : Number of stages */ - const Word16 w[], /* i : Weights Q8 */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 applyDCT_flag, /* i : applyDCT flag */ - Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ - Word16 Idx[] /* o : Indices */ -); - -void msvq_dec_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 Idx[], /* i : Indices */ - const Word16 applyIDCT_flag, /* i : applyIDCT flag */ - const Word32 *invTrfMatrix, /* i : synthesis matrix */ - Word32 *uq, /* o : quantized vector */ - Word16 *uq_ind, /* o : quantized vector (fixed point) */ - Word16 exp ); - -void dec_FDCNG_MSVQ_stage1_fx( - Word16 j_full, /* i : index full range */ - Word16 n, /* i : dimension to generate */ - const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ - const DCTTYPE idcttype, /* i : specify which IDCT */ - Word32 *uq, /* o : synthesized stage1 vector Q20 */ - Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ -); - -void dctT2_N_apply_matrix_fx( - const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ - Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ - const Word16 dct_dim, /* i : dct processing dim possibly truncated */ - const Word16 fdcngvq_dim, /* i : fdcng domain length */ - const Word32 *matrix, /* i : IDCT matrix */ - const Word16 matrix_row_dim, /* i : */ - const DCTTYPE dcttype /* i : matrix operation type */ -); - -Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - -Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - -void v_mult_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_sub_s16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -void v_sub32_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ -); - -void ivas_swb_tbe_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ - Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ - Word16 *Q_white_exc ); - -Word16 swb_bwe_dec_fx32( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ - Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ - Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ - Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - Word16 output_frame /* i : frame length */ -); - -ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs */ - Word16 synth_fx16[], /* o : synthesis */ - Word16 save_hb_synth_fx16[], /* o : HB synthesis */ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ -); - -void wtda_fx32( - const Word32 *new_audio, /* i : input audio Q11 */ - Word32 *wtda_audio, /* o : windowed audio Q11 */ - Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ - const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const Word16 L /* i : length */ -); - -ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ); - -void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - -void hp20_fx_32_opt( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - -void getTCXMode_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void getTCXWindowing_ivas_fx( - const Word16 core, /* i : current frame mode */ - const Word16 last_core, /* i : last frame mode */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ -); - -Word16 ari_start_decoding_14bits_prm_ivas_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - -void generate_masking_noise_ivas_fx( - Word32 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 *exp_out, /* o : time-domain signal exp */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 length, /* i : frame size */ - const Word16 core, /* i : core */ - const Word16 return_noise, /* i : noise is returned instead of added */ - const Word16 secondary, /* i : flag to indicate secondary noise generation */ - const Word16 element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ -); - -void SynthesisSTFT_dirac_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 samples_out, - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ -); - -void generate_stereo_masking_noise_fx( - Word16 *syn, /* i/o: time-domain signal */ - Word16 Q_syn, - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ -); - -void SynthesisSTFT_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ -); - -void FdCng_decodeSID_ivas_fx( - Decoder_State *st /* i/o: decoder state structure */ -); - -void cldfb_restore_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -ivas_error cldfb_save_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ -); - -Word16 sr2fscale( - const Word32 sr_core /* i : internal sampling rate */ -); - -void Copy_Scale_sig32( - const Word32 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ -); - -void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ - Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ -); - -void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ -); - -/* o : Q(2x - 31 - gb) */ -Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb /* i : guard bits */ -); - -Word32 sum2_16_exp_fx( - const Word16 *vec, /* i : input vector Q(15 - exp) */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ -); - -Word32 sum2_32_exp_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ -); +void lp_gain_updt_ivas_fx( +#endif + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ + ); + + /*! r: quantized codebook gain Q16 */ + Word32 gain_dec_gaus_fx( + Word16 index, /* i : quantization index */ + const Word16 bits, /* i : number of bits to quantize */ + const Word16 lowBound, /* i : lower bound of quantizer (dB) */ + const Word16 topBound, /* i : upper bound of quantizer (dB) */ + const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ + ); + + void gain_dec_SQ_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 *code, /* i : algebraic code excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ + Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ + ); + + void gain_dec_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + Word16 *gain_pit, /* o : Quantized pitch gain */ + Word32 *gain_code, /* o : Quantized codeebook gain */ + Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ + Word16 *gain_inov, /* o : unscaled innovation gain */ + const Word16 *code, /* i : algebraic code excitation */ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ + ); + + void transf_cdbk_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ + const Word32 gain_code, /* i : innovative excitation gain (Q16) */ + Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ + Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ + Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ + Word16 *unbits /* o : number of AVQ unused bits */ + ); + + /* o: decoded gain */ + Word16 gain_dequant_fx( + Word16 index, /* i: quantization index */ + const Word16 min, /* i: value of lower limit */ + const Word16 max, /* i: value of upper limit */ + const Word16 bits, /* i: number of bits to dequantize */ + Word16 *expg ); + + void AVQ_demuxdec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ + Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ + const Word16 Nsv, /* i : number of subvectors Q0*/ + Word16 nq[], /* i/o: AVQ nq index Q0*/ + Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ + Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ + ); + + void AVQ_dec_lpc( + Word16 *indx, /* input: index[] (4 bits per words) Q0*/ + Word16 *nvecq, /* output: vector quantized Q0*/ + Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ + + void re8_dec_fx( + Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ + const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ + const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ + ); + + void re8_decode_base_index_fx( + const Word16 n, + UWord16 I, + Word16 *x ); + + void re8_k2y_fx( + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ + ); + + void re8_vor_fx( + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ + ); + + void re8_PPV_fx( + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ + ); + + void dec_pit_exc_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + ); + + /* o: pitch value Q16 */ + Word32 Mode2_pit_decode( + const Word16 coder_type, /* i: coding model */ + Word16 i_subfr, /* i: subframe index */ + Word16 L_subfr, + Word16 **pt_indice, /* i/o: quantization indices pointer */ + Word16 *T0, /* i/o: close loop integer pitch Q0 */ + Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ + Word16 *T0_res, /* i/o: pitch resolution Q0 */ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ + Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr1b, + Word16 pit_fr2, + Word16 pit_max, + Word16 pit_res_max ); + + void Mode2_abs_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 *T0_res, /* o: pitch resolution Q0 */ + Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr2, + Word16 pit_res_max ); + + void Mode2_delta_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 T0_res, /* i: pitch resolution Q0 */ + Word16 *T0_min, /* i: delta search min Q0 */ + Word16 *T0_min_frac, /* i: delta search min Q0 */ + Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ + ); + + /* o : floating pitch value */ + Word16 pit_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ + ); + + void pit_Q_dec_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 delta, /* i : Half the CL searched interval */ + const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ + ); + + void pit16k_Q_dec_fx( + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ + ); + + void abs_pit_dec_fx( + const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ + Word16 pitch_index, /* i: pitch index */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o: integer pitch lag */ + Word16 *T0_frac /* o: pitch fraction */ + ); + + void delta_pit_dec_fx( + const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ + const Word16 pitch_index, /* i : pitch index */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + const Word16 T0_min /* i : delta search min */ + ); + + void limit_T0_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 delta, /* i : Half the close-loop searched interval */ + const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ + const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_max /* o : higher pitch limit */ + ); + + void limit_T0_voiced( + const Word16 nbits, + const Word16 res, + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + const Word16 T0_res, /* i : pitch resolution */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_min_frac, /* o : lower pitch limit */ + Word16 *T0_max, /* o : higher pitch limit */ + Word16 *T0_max_frac, /* o : higher pitch limit */ + const Word16 pit_min, /* i : Minimum pitch lag */ + const Word16 pit_max /* i : Maximum pitch lag */ + ); + + void inov_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ + ); + + void inov_decode_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ + ); + + void dec_acelp_4t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 nbbits, /* i : number of bits per codebook */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + const Word16 Opt_AMR_WB ); + + void D_ACELP_decode_43bit_fx( + UWord16 idxs[], + Word16 code[], + Word16 *pulsestrack ); + + void D_ACELP_indexing_fx( + Word16 code[], + PulseConfig config, + Word16 num_tracks, + Word16 index[], + Word16 *BER_detect ); + + void fcb_pulse_track_joint_decode_fx( + UWord16 *idxs, + Word16 wordcnt, + UWord32 *index_n, + Word16 *pulse_num, + Word16 track_num ); + + void dec_acelp_2t32_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[] /* o: algebraic (fixed) codebook excitation */ + ); + + void dec_acelp_1t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ + const Word16 L_subfr /* i : sub frame lenght*/ + ); + + ivas_error acelp_core_switch_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ + Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ + const Word16 output_frame, /* i : input frame length */ + const Word16 core_switching_flag, /* i : core switching flag */ + Word16 *mem_synth, /* o : synthesis to overlap */ + Word16 *Q_syn ); + + ivas_error acelp_core_switch_dec_bfi_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ + ); + + ivas_error acelp_core_switch_dec_bfi_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ + ); + + void pred_lt4( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ + ); + + void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ + ); + + void pred_lt4_tc_fx( + Word16 exc[], /* i/o: excitation buffer Q0*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i: fraction of lag Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 imp_pos, /* i : glottal impulse position Q0*/ + const Word16 i_subfr /* i : subframe index Q0*/ + ); + + void pvq_decode_frame_fx( + Decoder_State *st_fx, + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ + ); + + Word16 pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + + Word16 ivas_pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, /* Q3 */ + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + + void decode_energies_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 Np, + Word16 *dim_part, + Word16 *bits_part, + Word16 *g_part, /* Q15 */ + Word16 qband, + Word16 *bits_left, + Word16 dim, + const Word16 strict_bits ); + + void rc_dec_init_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 tot_bits /* i : Total bit budget */ + ); + + /* o : Decoded cumulative frequency */ + UWord32 rc_decode_fx( + Word16 *BER_detect, /* o : Bit error detection flag */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Total cumulative frequency */ + ); + + void rc_dec_update_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + + UWord32 cum_freq, /* i : Cumulative frequency */ + UWord32 sym_freq /* i : Symbol frequency */ + ); + + /* o : Decoded value */ + Word32 rc_dec_bits_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 bits /* i : Number of bits */ + ); + + /* o : Decoded value */ + UWord32 rc_dec_uniform_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Maximum value */ + ); + + void rc_dec_finish_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ + ); + + void pvq_decode_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 *xq, /* o: decoded vector (Q15) */ + Word16 *y, /* o: decoded vector (non-scaled int) */ + const Word16 k_val, /* i: number of allocated pulses */ + const Word16 dim, /* i: Length of vector */ + const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ + ); + void nelp_decoder_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ + Word16 *exc, /* o : adapt. excitation exc Q_exc */ + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate Q0 */ + const Word16 coder_type, /* i : coding type Q0 */ + Word16 *gain_buf /* Q14 */ + ); + + void decod_nelp_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ + Word16 *exc_fx, /* o : adapt. excitation exc */ + Word16 *exc2_fx, /* o : adapt. excitation/total exc */ + Word16 *voice_factors, /* o : Voice factor */ + Word16 *bwe_exc, + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate */ + Word16 *gain_buf /*Q14*/ + ); + + void lp_filt_exc_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 codec_mode, /* i : coder mode */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 L_subfr, /* i : subframe size */ + const Word16 L_frame, /* i : frame size */ + Word16 lp_flag, /* i : operation mode signalling */ + Word16 *exc ); + + void FEC_lsf2lsp_interp( + Decoder_State *st, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *Aq, /* o : calculated A(z) for 4 subframes */ + Word16 *lsf, /* o : estimated LSF vector */ + Word16 *lsp /* o : estimated LSP vector */ + ); + + ivas_error createFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + + void initFdCngDec_fx( + DEC_CORE_HANDLE st, /* i/o: decoder state structure */ + const Word16 scale ); + + /* Delete the instance of type FD_CNG */ + void deleteFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + + /* Configure CLDFB-CNG */ + void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ + Word16 bandwidth, + Word32 bitrate, + Word16 L_frame, + const Word16 Last_L_frame, + const Word16 element_mode ); + + Word16 ApplyFdCng_fx( + Word16 *timeDomainInput, /* i : pointer to time domain input */ + Word16 Q, + Word32 *powerSpectrum, + Word16 Q_power_spectrum, + Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ + Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ + Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ + Decoder_State *st, + const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ + Word16 is_music ); + + /* Perform noise estimation */ + void perform_noise_estimation_dec_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain i */ + const Word16 Q, + HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + void perform_noise_estimation_dec_ivas_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain input */ + const Word16 Q, + Word32 *power_spectrum, + Word16 Q_power_spectrum, + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + const Word16 VAD /* i : VAD flag in the decoder */ + ); + + /* Decode the CLDFB-CNG bitstream */ + void FdCng_decodeSID_fx( + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Decoder_State *corest ); /* i/o: decoder state structure */ + + void noisy_speech_detection_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ + const Word16 vad, /* i : VAD flag */ + const Word16 *syn, /* i : i time-domain frame */ + const Word16 Q ); + + void generate_comfort_noise_dec_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ + ); + + void generate_comfort_noise_dec_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ + ); + + void generate_comfort_noise_dec_hf_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec ); + + void generate_comfort_noise_dec_hf_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of input bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ + ); + + /* Generate the comfort noise based on the target noise level */ + void generate_masking_noise_fx( + Word16 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 Q, + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 length, + Word16 core ); + + void generate_masking_noise_update_seed_fx( + HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ + ); + + void generate_masking_noise_mdct_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 L_frame ); + + void generate_masking_noise_mdct_ivas_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); + + ivas_error init_decoder_fx( + Decoder_State *st_fx, /* o : Decoder static variables structure */ + const Word16 idchan, /* i : channel ID */ + const MC_MODE mc_mode /* i : MC mode */ + ); + + void reset_preecho_dec_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ + ); + + void destroy_cldfb_decoder_fx( + Decoder_State *st_fx /* o: Decoder static variables structure */ + ); + + void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: state structure */ + ); + + Word16 WB_BWE_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *WB_fenv /*Q15*/ + ); + + Word16 wb_bwe_dec_fx( + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *voice_factors_fx, /* i : voicing factors Q15 */ + const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *Qpost ); + + /* o : BWE class */ + Word16 swb_bwe_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 core, /* i : core */ + Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ + Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ + const Word16 hr_flag, /* i : high rate flag */ + const Word16 hqswb_clas /* i : HQ BWE class */ + ); + + /*o :Q_syn_hb*/ + Word16 swb_bwe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *Qpost ); + + void fd_bwe_dec_init( + Decoder_State *st_fx, /* i/o: decoder state structure */ + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ + ); + + void hq_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *audio_fx, /* i : input audio signal Q0 */ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ + ); + + void hq_core_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word16 synth[], /* o : output synthesis Q_synth*/ + Word16 *Q_synth, /* o : Q value of synth */ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ + ); + + void HQ_core_dec_init_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ + ); + + void HQ_nbfec_init_fx( + HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ + ); + + + void hq_ecu_fx( + const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ + Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ + Word16 *time_offs, + Word16 *X_sav, + Word16 *Q_spec, /* i/o : Q value of stored spectrum */ + Word16 *num_p, + Word16 *plocs, + Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ + const Word16 env_stab, + Word16 *last_fec, + const Word16 ph_ecu_HqVoicing, + Word16 *ph_ecu_active, /* i : Phase ECU active flag */ + Word16 *gapsynth, + const Word16 prev_bfi, /* i : indicating burst frame error */ + const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ + Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ + Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ + Word16 *beta_mute, /* o : Factor for long-term mute */ + const Word16 output_frame, /* i : frame length */ + Decoder_State *st_fx /* i/o: decoder state structure */ + ); + + void hq_lr_dec_fx( + Decoder_State *st_fx, /* i/o: : decoder state structure */ + Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ + const Word16 inner_frame, /* i : Q0 : inner frame length */ + Word16 num_bits, /* i : Q0 : number of available bits */ + Word16 *is_transient_fx /* o : Q0 : transient flag */ + ); + + /* o : Number of bits Q0*/ + Word16 decode_envelope_indices_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : starting band index Q0*/ + const Word16 num_sfm, /* i : Number of subbands Q0*/ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ + Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ + ); + + void dequantize_norms_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : First SDE encoded norm Q0*/ + const Word16 num_sfm, /* i : Number of norms Q0*/ + const Word16 is_transient, /* i : Transient flag Q0*/ + Word16 *ynrm, /* o : Decoded norm indices Q0*/ + Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ + ); + + void hdecnrm_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 numNorms, /* (i) number of norms Q0*/ + Word16 *index ); /* (o) indices of quantized norms Q0*/ + + Word16 decode_huff_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *hufftab, + Word16 *rbits ); + + void hdecnrm_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* Q0 */ + Word16 *index, /* Q0 */ + Word16 *n_length /* Q0 */ + ); + + void hdecnrm_resize_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ + ); + + void huff_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : Number of codewords to decode Q0*/ + const Word16 buffer_len, /* i : Number of bits to read Q0*/ + const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ + const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ + const Word16 *offset, /* i : Offset for first codeword Q0*/ + const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ + Word16 *index /* o : Decoded index Q0*/ + ); + + void hdecnrm_tran_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ + ); + + void tcq_core_LR_dec_fx( + Decoder_State *st_fx, + Word16 *inp_vector_fx, /*x5 */ + const Word16 bit_budget, /*Q0 */ + const Word16 BANDS, /*Q0 */ + const Word16 *band_start, /*Q0 */ + const Word16 *band_width, /*Q0 */ + Word32 *Rk_fx, /*Q16*/ + Word16 *npulses, /*Q0 */ + Word16 *k_sort, /*Q0 */ + const Word16 *p2a_flags, /*Q0 */ + const Word16 p2a_bands, /*Q0 */ + const Word16 *last_bitalloc, /*Q0 */ + const Word16 input_frame, /*Q0 */ + const Word16 adjustFlag, /*Q0 */ + const Word16 *is_transient /*Q0 */ + ); + + void HQ_FEC_processing_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ + Word16 is_transient, /* i : Old flag for transient */ + Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ + Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ + Word16 num_Sb, /* i : Number of sub-band group */ + Word16 nb_sfm, /* i : Number of sub-band */ + Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ + Word16 output_frame, /* i : Frame size */ + const Word16 *sfm_start, /* i : Start of bands */ + const Word16 *sfm_end /* i : End of bands */ + ); + + void HQ_FEC_Mem_update_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /*Q12*/ + Word32 *normq_fx, /*Q14*/ + Word16 *ynrm, + Word16 *Num_bands_p, + Word16 is_transient, + Word16 hqswb_clas, + Word16 c_switching_flag, + Word16 nb_sfm, + Word16 num_Sb, + Word16 *mean_en_high_fx, /*Q5*/ + Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ + Word16 output_frame ); + + void time_domain_FEC_HQ_fx( + Decoder_State *st_fx, /* i : Decoder State */ + Word32 *wtda_audio_fx, /* i : i */ + Word16 *out_fx, /* o : output audio */ + Word16 mean_en_high_fx, /* i : transient flag */ + const Word16 output_frame, + Word16 *Q_synth ); + + void hq_pred_hb_bws_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *ynrm, /* i : norm quantization index vector Q0*/ + const Word16 length, /* i : frame length Q0*/ + const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ + ); + + void hq_hr_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ + const Word16 length, /* i : frame length Q0 */ + Word16 num_bits, /* i : number of available bits Q0 */ + Word16 *ynrm, /* o : norm quantization index vector Q0 */ + Word16 *is_transient, /* o : transient flag Q0 */ + Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ + Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ + const Word16 core_switching_flag /* i : Core switching flag Q1 */ + ); + + /* o : Consumed bits */ + Word16 hq_classifier_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : Core bit rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + Word16 *is_transient, /* o : Transient flag Q0 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ + ); + + void hvq_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 num_bits, /* i : Number of available bits */ + const Word32 core_brate, /* i : Core bit-rate */ + const Word16 *ynrm, /* i : Envelope coefficients Q0 */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *noise_level, /* o : Noise level in Q15 */ + Word16 *peak_idx, /* o : Peak position vector */ + Word16 *Npeaks, /* o : Total number of peaks */ + Word32 *coefsq_norm, /* o : Output vector in Q12 */ + const Word16 core ); + + Word16 hvq_pvq_bitalloc_fx( + Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ + const Word32 brate, /* i : bitrate */ + const Word16 bwidth_fx, /* i : Encoded bandwidth */ + const Word16 *ynrm, /* i : Envelope coefficients */ + const Word32 manE_peak, /* i : Peak energy mantissa */ + const Word16 expE_peak, /* i : Peak energy exponent */ + Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ + Word16 *R, /* Q0 i/o: Global bit allocation */ + Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ + Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ + ); + + void hq_configure_bfi_fx( + Word16 *nb_sfm, /* o : Number of sub bands Q0*/ + Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ + Word16 *num_bands_p, /* o : FEC sub bands Q0*/ + const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ + const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ + const Word16 **sfm_end /* o : Subband end coefficients Q0*/ + ); + + void bandwidth_switching_detect_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ + ); + + void bandwidth_switching_detect_ivas_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ + ); + + void bw_switching_pre_proc_fx( + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ + ); + + ivas_error core_switching_pre_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output_frame /* i : frame length Q0*/ + ); + + ivas_error core_switching_post_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + ); + + ivas_error core_switching_post_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + const Word16 nchan_out, /* i : number of output channels Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ + ); + + void core_switching_hq_prepare_dec_fx( + Decoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 output_frame /* i : output frame length Q0*/ + ); + + ivas_error amr_wb_dec_fx( + Word16 output_sp[], /* o : synthesis output */ + Decoder_State *st_fx /* o : Decoder static variables structure */ + ); + + void amr_wb_dec_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ + ); + + void updt_dec_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 *old_exc_fx, /* i : buffer of excitation */ + const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ + const Word16 Es_pred, /* i : predicited scaled innovation energy */ + const Word16 *Aq, /* i : A(z) quantized for all subframes */ + const Word16 *lsf_new_fx, /* i : current frame LSF vector */ + const Word16 *lsp_new_fx, /* i : current frame LSP vector */ + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ + const Word16 *gain_buf /*Q14*/ + ); + + void updt_IO_switch_dec_fx( + const Word16 output_frame, /* i : output frame length */ + Decoder_State *st_fx /* o : Decoder static variables structure */ + ); + + void updt_bw_switching_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ + const Word16 Qpost ); + + void updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word16 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ + ); + + void update_decoder_LPD_cng( + Decoder_State *st, + Word16 coder_type, + Word16 *timeDomainBuffer, + Word16 *A, + Word16 *bpf_noise_buf ); + + void FEC_clas_estim_fx( + Decoder_State *st_fx, /* i/o: decoder state handle */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ + const Word16 L_frame, /* i : length of the frame */ + Word16 *clas, /* i/o: frame classification */ + const Word16 coder_type, /* i : coder type */ + const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ + Word16 *syn, /* i : synthesis buffer */ + Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ + Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ + Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ + Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ + Word16 *Last_ener, /* i/o: last_energy frame A*/ + Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ + Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ + Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ + Word16 Q_syn, /* i : Synthesis scaling */ + Word16 *class_para, /* o : classification para. fmerit1 A*/ + Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ + Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ + Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ + Word16 mode, /* i : signal classifier mode B*/ + Word16 bfi, /* i : bad frame indicator B*/ + Word32 last_core_brate, /* i : bitrate of previous frame */ + const Word16 FEC_mode /* i : ACELP FEC mode */ + ); + + Word16 FEC_pos_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ + Word32 *enr_q, /* o : decoded energy in Q0 */ + const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ + ); + + void post_decoder( + Decoder_State *st, + Word16 synth_buf[], /* Q0 */ + Word16 pit_gain[], /* Q14 */ + Word16 pitch[], /* Q0 */ + Word16 signal_out[], /* Q0 */ + Word16 *bpf_noise_buf /* Q0 */ + ); + + void post_decoder_ivas_fx( + Decoder_State *st, + Word16 synth_buf[], // Q0 + Word16 pit_gain[], // Q14 + Word16 pitch[], // Q0 + Word16 signal_out[], // Q0 + Word16 *bpf_noise_buf // Q0 + ); + + void cldfb_synth_set_bandsToZero( + Decoder_State *st, + Word32 **rAnalysis, + Word32 **iAnalysis, + const Word16 nTimeSlots, + const CLDFB_SCALE_FACTOR scaleFactor ); + + void FEC_pitch_estim_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 last_core, /* i : last core */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 clas, /* i : current frame classification */ + const Word16 last_good, /* i : last good clas information */ + const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ + const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ + Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ + Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ + Word16 *upd_cnt, /* i/o: update counter */ + const Word16 coder_type, /* i : coder_type */ + Word16 element_mode /* i : element mode */ + ); + + void FEC_scale_syn_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ + Word16 clas, /* i/o: frame classification */ + const Word16 last_good, /* i: last good frame classification */ + Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ + const Word16 *pitch, /* i: pitch values for each subframe */ + Word32 L_enr_old, /* i: energy at the end of previous frame */ + Word32 L_enr_q, /* i: transmitted energy for current frame */ + const Word16 coder_type, /* i: coder type */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ + Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ + Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ + const Word16 bfi, /* i: current frame BFI */ + const Word32 total_brate, /* i: total bitrate */ + const Word16 prev_bfi, /* i: previous frame BFI */ + const Word32 last_core_brate, /* i: previous frame core bitrate */ + Word16 *exc, /* i/o: excitation signal without enhancement */ + Word16 *exc2, /* i/o: excitation signal with enhancement */ + Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ + Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ + const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ + Word16 *mem_syn, /* o: initial synthesis filter states */ + Word16 Q_exc, + Word16 Q_syn, + const Word16 element_mode, /* i : element mode */ + const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ + const Word16 force_scaling /* i : force scaling */ + ); + + void LD_music_post_filter_fx( + MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ + const Word16 dtc_in[], /* i : i synthesis Qdct */ + Word16 dtc_out[], /* o : output synthesis Qdct */ + const Word32 core_brate, /* i : core bitrate Q0 */ + Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ + const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ + const Word16 Last_coder_type, /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ + ); + + void Prep_music_postP_fx( + Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ + Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ + Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ + const Word16 last_core, /* i : last core */ + const Word16 element_mode, /* i : element mode */ + const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ + Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ + const Word16 Q_exc, /* i : excitation scaling */ + Word16 *qdct /* o : Scaling factor of dct coefficient */ + ); + + void Post_music_postP_fx( + Word16 dct_buffer_in[], /* i/o: excitation buffer */ + Word16 *exc2, /* i/o: Current excitation to be overwriten */ + const Word16 *mem_tmp, /* i : previous frame synthesis memory */ + Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ + const Word16 *Aq, /* i : LPC filter coefficients */ + Word16 *syn, /* i/o: 12k8 synthesis */ + Word16 *Q_exc, /* i : excitation scaling */ + Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ + Word16 *Q_syn, /* i : Current frame synthesis scaling */ + Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ + const Word16 IsIO, /* i : Flag to indicate IO mode */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ + Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ + Word16 *mem_agc, + PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ + ); + + void music_postfilt_init( + MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ + ); + + void improv_amr_wb_gs_fx( + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 locattack, /* i : Flag for a detected attack Q0*/ + Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ + Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ + ); + + void decod_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficients */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ + ); + + void CNG_reset_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ + Word16 *voice_factors /* o : voicing factors Q15*/ + ); + + ivas_error ppp_voiced_decoder_fx( + Decoder_State *st_fx, /* i/o: state structure */ + Word16 *out_fx, /* o : residual signal */ + const Word16 *lpc2_fx, /* i : current frame LPC */ + Word16 *exc_fx, /* i : previous frame excitation */ + Word16 *pitch, /* o : floating pitch values for each subframe */ + Word16 bfi /* i : Frame error rate */ + ); + + void sc_vbr_dec_init( + SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ + ); + + ivas_error ppp_quarter_decoder_fx( + DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ + Word16 prevCW_lag_fx, /* i : Previous lag */ + Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ + Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ + Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ + Word16 bfi, /* i : FER flag */ + Word16 *S_fx, /* i : sine table, Q15 */ + Word16 *C_fx, /* i : cosine table, Q15 */ + DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ + Decoder_State *st_fx ); + + void open_decoder_LPD_fx( + Decoder_State *st, + const Word32 total_brate, /* Q0 */ + const Word16 bwidth /* Q0 */ + ); + + void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + + void reset_tcx_overl_buf_fx( + TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ + ); + + void acelp_plc_mdct_transition_fx( + Decoder_State *st /* i/o: Decoder state */ + ); + + void cldfb_reset_memory_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + void tcxltp_dec_init_fx( + TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ + const Word16 ini_frame, /* Q0 */ + const Word16 last_codec_mode, /* Q0 */ + const Word16 element_mode, /* Q0 */ + const Word16 pit_max, /* Q0 */ + const Word32 sr_core ); /* Q0 */ + + /* o : Exponent of SHB synthesis */ + Word16 swb_bwe_dec_hr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ + const Word16 exp, /* i : Exponent of core synthesis */ + Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ + const Word16 output_frame, /* i : frame length */ + const Word16 unbits, /* i : number of core unused bits */ + const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ + ); + + void hr_bwe_dec_init( + HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ + ); + + void swb_hr_noise_fill_fx( + const Word16 is_transient, /* i : transient flag */ + const Word16 spect_start, /* i : spectrum start point */ + const Word16 spect_end, /* i : spectrum end point */ + const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ + const Word16 pitch, /* i : pitch value Q15 */ + const Word16 nq[], /* i : AVQ nq index */ + Word16 Nsv, /* i : number of subband */ + Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ + Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ + Word16 Q_audio ); + + void stat_noise_uv_dec_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ + Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ + Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ + const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ + ); + + void stat_noise_uv_mod_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + Word16 *exc2, /* i/o: excitation buffer Q_exc */ + Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q15 */ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : input bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + ); + + void stat_noise_uv_mod_ivas_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ + ); + + Word16 FEC_SinOnset_fx( + Word16 *exc, /* i/o : exc vector to modify */ + Word16 puls_pos, /* i : last pulse position desired */ + const Word16 T0, /* i : Pitch information of the 1 subfr */ + Word32 enr_q, /* i : energy provide by the encoder */ + Word16 *Aq, /* i : A(z) filter Q12 */ + const Word16 L_frame, /* i : frame length */ + const Word16 Qold ); + + Word16 FEC_enhACB_fx( + const Word16 L_frame, /* i : frame length */ + const Word16 last_L_frame, /* i : frame length of previous frame */ + Word16 *exc_io, /* i/o : adaptive codebook memory */ + const Word16 new_pit, /* i : decoded first frame pitch */ + const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ + const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ + ); + + /*! r: do_WI flag */ + Word16 FEC_synchro_exc_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* i/o: exc vector to modify */ + const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ + const Word16 true_puls_pos, /* i : Present pulse location */ + const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ + ); + + void decod_unvoiced_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Word16 *gain_buf ); + + void gaus_dec_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* o : unvoiced excitation Q12 */ + Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ + Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ + Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ + Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ + Word16 *voice_fac, /* o : estimated voicing factor Q15 */ + Word16 *gain_pit, /* o : pitch gain Q14 */ + Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ + Word16 *exc, /* o : excitation signal frame */ + Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ + Word16 *exc2, /* o : Scaled excitation signal frame */ + Word16 *bwe_exc_fx, + Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ + Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ + ); + + void gaus_L2_dec( + Word16 *code, /* o : decoded gaussian codevector Q9 */ + Word16 tilt_code, /* i : tilt of code Q15 */ + const Word16 *A, /* i : quantized LPCs Q12 */ + Word16 formant_enh, /* i : formant enhancement factor Q15 */ + Word16 *seed_acelp /*i/o : random seed Q0 */ + ); + + ivas_error decod_gen_voic_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 sharpFlag_fx, /* i : formant sharpening flag */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 do_WI_fx, /* i : do interpolation after a FER */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + Word16 *unbits, /* number of unused bits */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + ); + + void decod_tran_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ + Word16 *unbits, /* i/o: number of unused bits */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 *gain_buf /*Q14*/ + ); + + void transition_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 tc_subfr, /* i : TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *exc, /* o : excitation signal */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + Word16 **pt_pitch, /* o : floating pitch values */ + Word16 *position, /* i/o: first glottal impulse position in frame */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *Q_exc /*i/o : scaling of excitation */ + ); + + Word16 tc_classif_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame /* i : length of the frame */ + ); + + ivas_error decod_ppp_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ + Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ + Word16 *exc_fx, /* i/o: current non-enhanced excitation */ + Word16 *exc2_fx, /* i/o: current enhanced excitation */ + Word16 bfi, /* i : bad frame indicator */ + Word16 *gain_buf, /*Q14*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ + ); + + void swb_bwe_dec_lr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis : QsL */ + const Word16 QsL, /* i : Q value of m_core */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ + Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ + Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ + Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ + const Word16 hqswb_clas_fx, /* i : class information : Q0 */ + Word16 lowlength_fx, /* i : Lowband Length : Q0 */ + Word16 highlength_fx, /* i : Highband Length : Q0 */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ + Word16 *prev_frm_hfe2, /* i/o: : Q0 */ + Word16 *prev_stab_hfe2, /* i/o: : Q0 */ + Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ + const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ + Word16 *ni_seed_fx /* i/o: random seed : QsL */ + ); + + Word16 dec_acelp_tcx_frame_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *concealWholeFrame, /* i/o: concealment flag */ + Word16 *pcmBuf, /* o : synthesis */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 *pcmbufFB, /* o : synthesis @output_FS */ + Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 pitch_buf[] /* o : floating pitch for each subframe */ + ); + + void decoder_LPD_fx( + Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ + Word16 signal_outFB[], /* o : synthesis @output_FS */ + Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ + Decoder_State *st, /* i/o: decoder memory state pointer */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 bfi, /* i : BFI flag */ + Word16 *bitsRead, /* o : number of read bits */ + Word16 param[], /* o : buffer of parameters */ + Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ + ); + + void mode_switch_decoder_LPD_fx( + Decoder_State *st, /* Q0 */ + Word16 bandwidth_in, /* Q0 */ + Word32 bitrate, /* Q0 */ + Word16 frame_size_index /* Q0 */ + ); + + void mode_switch_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ + const Word16 frame_size_index, /* i : index determining the frame size Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + + Word16 DecodeIndex( + Decoder_State *st, + const Word16 Bandwidth, /* o : NB, 1: (S)WB */ + Word16 *PeriodicityIndex ); + + Word16 DecodeIndex_fx( + Decoder_State *st, + const Word16 Bandwidth, + Word16 *PeriodicityIndex ); + + void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ + ); + + Word16 lsf_msvq_ma_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ + ); + + Word16 lsf_bctcvq_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ + ); + + Word16 D_lsf_tcxlpc( + const Word16 indices[], /* i : VQ indices Q0*/ + Word16 lsf_q[], /* o : quantized LSF Q1*/ + Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk, /* i : codebook selector Q0*/ + Word16 mem_MA[] /* i : MA memory Q1*/ + ); + + Word16 dec_lsf_tcxlpc( + Decoder_State *st, /* i/o: Decoder state */ + Word16 **indices, /* o : Ptr to VQ indices Q0*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk /* i : codebook selector Q0*/ + ); + + void midlsf_dec( + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 idx, /* i: codebook index */ + Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ + const Word16 coder_type, + Word16 *mid_lsf_int, + const Word16 prev_bfi, + const Word16 safety_net ); + + Word16 lsf_ind_is_active( + const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ + const Word16 means[], /*(14Q1*1.28)*/ + const Word16 narrowband, + const Word16 cdk ); + + void IGFSCFDecoderOpen( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ + H_IGF_INFO hIgfInfo, /* i : IGF info handle */ + const Word32 total_brate, + const Word16 bwidth, + const Word16 element_mode, + const Word16 rf_mode ); + + void IGFSCFDecoderReset( + IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ + ); + + void IGFSCFDecoderDecode( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + Decoder_State *st, /* i/o: pointer to decoder state */ + Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, + if 0 on input the decoder will be forced to encode without a reset */ + ); + + Word32 ari_decode_overflow_fx( + Tastat *s ); + + void ari_start_decoding_14bits_fx( + Decoder_State *st, + Tastat *s ); + + Word16 ari_start_decoding_14bits_prm_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + + Word16 ari_decode_14bits_s17_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + + Word16 ari_decode_14bits_s27_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + + Word16 ari_decode_14bits_bit_ext_fx( + Decoder_State *st, + Tastat *s ); + + Word16 ari_decode_14bits_pow_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + Word16 base ); + + Word16 ari_decode_14bits_sign_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + + void getTCXparam_fx( + Decoder_State *st, /* i/o: Decoder State handle */ + Decoder_State *st0, /* i : bitstream */ + CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ + Word16 param[], /* o : decoded parameters Q0 */ + const Word16 bits_common, /* i : number of common bits Q0 */ + const Word16 start_bit_pos, /* i : position of the start bit Q0 */ + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ + Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ + Word16 nTnsBitsTCX10[2], /*Q0*/ + const Word16 pre_past_flag /*Q0*/ + ); + + void dec_prm_fx( + Word16 *coder_type, + Word16 param[], /* (o) : decoded parameters */ + Word16 param_lpc[], /* (o) : LPC parameters */ + Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ + Decoder_State *st, + Word16 L_frame, + Word16 *bitsRead ); + + void getLPCparam_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param_lpc[], /* o : LTP parameters Q0 */ + Decoder_State *st0, /* i : bitstream */ + const Word16 ch, /* i : channel Q0 */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ + ); + + void UnmapIndex( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word16 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ + ); + + void ConfigureContextHm( + const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ + const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ + const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ + const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ + ); + + Word16 CountIndexBits( + Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ + Word16 PeriodicityIndex /* Q0 */ + ); + + Word32 tcx_hm_render( + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ + ); + + void tcx_hm_modify_envelope( + Word16 gain, /* i: HM gain Q11 */ + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + Word16 L_frame /* i: number of spectral lines Q0 */ + ); + + Word16 ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + + void ReadTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + + Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + + Word16 DecodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + + void GetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void const *pParameter, + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ); + + void GetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, // Q0 + void const *pParameter, // Q0 + Word16 **pStream, // Q0 + Word16 *pnSize, // Q0 + Word16 *pnBits // Q0 + ); + + void EncodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream Q0*/ + Word16 *pnSize, /* o : number of written parameters Q0*/ + Word16 *pnBits /* o : number of written bits Q0*/ + ); + + void SetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + + void SetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + + void WriteToBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + void ReadFromBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + + void ReadFromBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + + void IGFDecReadData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ + ); + + void IGFDecReadLevel( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ + ); + + void IGFDecApplyMono( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ + ); + + void IGFDecApplyMono_ivas( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ + Word16 element_mode /**< in: | IVAS element mode */ + ); + + void IGFDecApplyStereo( + const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ + const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ + Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ + Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ + Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ + Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ + const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 *coreMsMask, + const Word16 restrict_hopsize, + const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ + const Word16 bfi_apply_damping ); + + void IGFDecSetMode( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void IGFDecSetMode_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 igfGridIdx /**< in: | IGF grid index */ + ); + + void IGFDecUpdateInfo_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ + const Word16 subFrameIdx, /* i : subframe index */ + const Word16 igfGridIdx /* i : IGF grid index */ + ); + + void IGFDecCopyLPCFlatSpectrum( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + ); + + void IGFDecCopyLPCFlatSpectrum_fx( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ + ); + + void IGFDecStoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ + ); + + void IGFDecRestoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ + ); + + void IGFDecRestoreTCX10SubFrameData_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word16 subFrameIdx /* i : index of subframe */ + ); + + void init_igf_dec( + IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ + ); + + Word16 dlpc_avq_fx( + Word16 *index, /* (i) Quantization indices */ + Word16 *LSF_Q, /* (o) Quantized LSF vectors */ + Word16 numlpc, /* (i) Number of sets of lpc */ + Word32 sr_core ); + + Word16 decode_lpc_avq_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc /* o : lpc parameters */ + ); + + Word16 decode_lpc_avq_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc, /* o : lpc parameters */ + const Word16 ch, /* i : channel */ + const Word16 element_mode, /* i : element mode */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ + ); + + void vlpc_1st_dec( + Word16 index, /* i : codebook index */ + Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ + + void vlpc_2st_dec( + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ + Word16 *indx, /* i : index[] (4 bits per words) */ + Word16 mode, /* i : 0=abs, >0=rel */ + Word32 sr_core ); + + void lsf_weight_2st( + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ + ); + + /* Returns: index of next coefficient */ + Word16 get_next_coeff_mapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + /* Returns: index of next coefficient */ + Word16 get_next_coeff_unmapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + Word16 update_mixed_context( + Word16 ctx, /* Q0 */ + Word16 a /* Q0 */ + ); + + Word32 update_mixed_context_ivas_fx( + Word32 ctx, /* Q0 */ + Word16 a /* Q0 */ + ); + + typedef Word16 ( *get_next_coeff_function )( + Word16 ii[2], /* i/o: coefficient indexes */ + Word16 *pp, /* o : peak(1)/hole(0) indicator */ + Word16 *idx, /* o : index in unmapped domain */ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + Word16 ACcontextMapping_decode2_no_mem_s17_LC( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o: decoded spectrum */ + Word16 nt, /* i: size of spectrum */ + Word16 nbbits, /* i: bit budget */ + Word16 resQMaxBits, /* i: residual coding maximum bits*/ + CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ + ); + + Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o : decoded spectrum */ + const Word16 nt, /* i : size of spectrum */ + const Word16 nbbits, /* i : bit budget */ + const Word16 resQMaxBits, /* i : residual coding maximum bits */ + CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ + ); + + void reconfig_decoder_LPD_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 bits_frame, /* i : bit budget Q0*/ + Word16 bwidth, /* i : audio bandwidth Q0*/ + Word32 total_brate, /* i : total bitrate Q0*/ + Word16 L_frame_old /* i : frame length Q0*/ + ); + + void reconfig_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bits_frame, /* i : bit budget Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word16 L_frame_old /* i : frame length Q0*/ + ); + + void minimumStatistics_fx( + Word16 *noiseLevelMemory, /* Q15, internal state */ + Word16 *noiseLevelIndex, /* Q0, internal state */ + Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ + Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ + Word16 *lastFrameLevel, /* Q15, level of the last frame */ + Word16 currentFrameLevel, /* Q15, level of the current frame */ + Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ + Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ + Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ + Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ + Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ + + /*10Q5*/ + Word16 getLevelSynDeemph_fx( + Word16 h1Init[], /* i: i value or vector to be processed Q15 */ + Word16 const A[], /* i: LPC coefficients Qx */ + Word16 const lpcorder, /* i: LPC order Q0 */ + Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ + Word16 const preemph_fac, /* i: preemphasis factor Q15 */ + Word16 const numLoops, /* i: number of loops Q0 */ + Word16 *Exp /* o: exponent of return value Q15 */ + ); + + void genPlcFiltBWAdap_fx( + Word32 const sr_core, /*mem_syn >rescaling done */ + Word16 *pitch_buffer, + Word16 *voice_factors, + Word16 *bwe_exc ); + + void decoder_acelp_fx( + Decoder_State *st, + Word16 prm[], /* i : parameters */ + Word16 A[], /* i : coefficients NxAz[M+1] */ + ACELP_config acelp_cfg, /* i : ACELP config */ + Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ + Word16 *pT, /* out: pitch for all subframe Q0 */ + Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ + Word16 stab_fac, /* i : stability of isf */ + Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ + Word16 *voice_factors, /* out: voicing factors */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *bwe_exc /* out: excitation for SWB TBE */ + ); + + void decode_acelp_gains_fx( + Word16 *code, + Word16 gains_mode, + Word16 mean_ener_code, + Word16 *gain_pit, + Word32 *gain_code, + Word16 **pt_indice, + Word16 *past_gpit, + Word32 *past_gcode, + Word16 *gain_inov, + Word16 L_subfr, + Word16 *code2, + Word32 *gain_code2 ); + + void d_gain_pred_fx( + Word16 nrg_mode, /* i : NRG mode */ + Word16 *Es_pred, /* o : predicited scaled innovation energy */ + Word16 **pt_indice /* i/o: pointer to the buffer of indices */ + ); + + ivas_error evs_dec_fx( + Decoder_State *st_fx, /* i/o : Decoder state structure */ + Word16 output_sp[], /* o : output synthesis signal */ + FRAME_MODE frameMode /* i : Decoder frame mode */ + ); + + void fft_cldfb_fx( + Word32 *data, /* i/o: input/output vector */ + const Word16 size /* size of fft operation */ + ); + + void stereo_dft_dec_analyze_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 *input_fx, /* i : input signal q*/ + Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 input_frame, /* i : input frame size Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ + const Word16 k_offset, /* i : offset of DFT Q0*/ + const Word16 delay, /* i : delay in samples FOR input signal Q0*/ + Word16 *q, + Word16 *q_DFT ); + + void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ + ); + + void delay_signal_q_adj_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay, /* i : delay in samples */ + const Word16 q_x, + const Word16 q_mem ); + + Word32 anint_fx( + const Word32 x, /* i: Round to the nearest integer */ + const Word16 exp /* i: Exponent for round step */ + ); + + Word32 ceil_fx( + const Word32 x, /* i: number to ceil */ + const Word16 exp /* i: Exponent for ceil step */ + ); + + void v_add_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_shr_16( + const Word16 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word16 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ + ); + + void v_shr( + const Word32 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word32 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ + ); + + void cldfbAnalysis_ts_fx( + const Word32 *timeIn_fx, /* i : time buffer */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, + Word16 *q_cldfb ); + + Word16 floor_log_2( + Word32 num ); + + void cldfbAnalysis_ts_fx_var_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + + void cldfbAnalysis_ts_fx_fixed_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + + void configureCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ + const Word32 sampling_rate /* i : sampling rate */ + ); + + void dec_acelp_fast_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const Word16 L_subfr /* i : subframe length */ + ); + + void tcx5SpectrumInterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + + void tcx5SpectrumDeinterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + + void tcx5TnsGrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum ); + + void tcx5TnsUngrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum, + const Word16 enc_dec ); + + void bpf_pitch_coherence_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ + ); + + /* fft_rel.c */ -Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - -void ProcessStereoIGF_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - Word16 q_pITFMDCTSpectrum_1, - Word16 q_pITFMDCTSpectrum_2, - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - -void IGFEncApplyStereo_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - -void IGFSaveSpectrumForITF_ivas_fx( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - const Word32 *pITFSpectrum, /* i : MDCT spectrum */ - Word16 exp_pITFSpectrum ); - -Word16 IGFEncWriteBitstream_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /* i : ptr to bitOffset counter */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -); - -Word16 IGFSCFEncoderEncode_ivas_fx( - IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ - Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ -); - -Word16 ari_encode_14bits_ext_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s, - Word32 symbol, /* Q0 */ - UWord16 const *cum_freq /* Q0 */ -); - -Word16 ari_encode_14bits_sign_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word32 bits, /* Q0 */ - Tastat *s, - Word16 sign /* Q0 */ -); - -Word16 ari_done_encoding_14bits_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s ); - -void IGFEncConcatenateBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - -void hq_generic_hf_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ - Word16 length ); - -Word16 ari_decode_14bits_pow_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - UWord16 base ); - -Word16 ari_decode_14bits_sign_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - -void lsf_syn_mem_backup_ivas_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code_fx, /* i: tilt code Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ - Word16 *pstreaklen ); +#define SIZE_256 256 +#define NUM_STAGE_256 7 +#define SIZE2_256 ( SIZE_256 / 2 ) -ivas_error config_acelp1_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 total_brate, /* i : total bitrate */ - const Word32 core_brate_inp, /* i : core bitrate */ - const Word16 core, /* i : core */ - const Word16 extl, /* i : extension layer */ - const Word32 extl_brate, /* i : extension layer bitrate */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const Word16 signaling_bits, /* i : number of signaling bits */ - const Word16 coder_type, /* i : coder type */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 tc_subfr, /* i : TC subfr ID */ - const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ - Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - Word16 *unbits, /* o : number of unused bits */ - const Word16 element_mode, /* i : element mode */ - Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 idchan, /* i : stereo channel ID */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); + void cldfbAnalysis_ivas_fx( + const Word32 *timeIn_fx, /* i : time buffer Qx */ + Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ + Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ + ); + + void cldfbSynthesis_ivas_fx( + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ + const Word16 out_shift, /* i : scale for output buffer */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ + ); + + void addBassPostFilter_ivas_fx( + const Word32 *harm_timeIn_fx, + const Word16 samplesToProcess, + Word32 **rAnalysis_fx, + Word32 **iAnalysis_fx, + HANDLE_CLDFB_FILTER_BANK cldfb ); + + /* o : Q22*/ + Word32 ism_dequant_meta_fx( + const Word16 idx, /* i : quantizer index */ + const Word32 borders_fx[], /* i : level borders Q22*/ + const Word32 q_step_fx, /* i : quantization step Q22 */ + const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ + const Word16 cbsize /* i : codebook size */ + ); + + void save_synthesis_hq_fec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ + const Word32 output_fx[], /* i : decoded synthesis */ + const Word16 output_frame, /* i : decoded synthesis */ + const Word16 Qpostd, /* i : Q value of delayed signal */ + CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ + ); + + void calculate_nbits_meta_fx( + const Word16 nchan_ism, + Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 + Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 + const Word16 numSf, + const Word16 numCodingBands, + Word16 *bits_ism, + const Word16 idx_sep_obj, + const Word16 ism_imp ); + + void ivas_get_stereo_panning_gains_fx( + const Word16 aziDeg, + const Word16 eleDeg, + Word16 panningGains[2] ); + + ivas_error openCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + const Word16 enc_dec ); /* i : encoder/decoder flag */ + + Word32 rand_gauss_fx( + Word32 *x, + Word16 *seed, + Word16 q ); + + void resampleCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate ); + + void generate_masking_noise_dirac_ivas_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ + Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ + Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ + const Word16 slot_index, /* i : CLDFB slot index */ + const Word16 cna_flag, /* i : CNA flag for LB and HB */ + const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ + Word16 q_input, + Word16 *q_cldfb ); + + void IMDCT_fx( + Word32 *x, + Word16 x_e, + Word16 *old_syn_overl, + Word16 *syn_Overl_TDAC, + Word16 *xn_buf, + const Word16 *tcx_aldo_window_1, + const PWord16 *tcx_aldo_window_1_trunc, + const PWord16 *tcx_aldo_window_2, + const PWord16 *tcx_mdct_window_half, + const PWord16 *tcx_mdct_window_minimum, + const PWord16 *tcx_mdct_window_trans, + Word16 tcx_mdct_window_half_length, + Word16 tcx_mdct_window_min_length, + Word16 index, + Word16 left_rect, + Word16 tcx_offset, + Word16 overlap, + Word16 L_frame, + Word16 L_frameTCX, + Word16 L_spec_TCX5, + Word16 L_frame_glob, + Word16 frame_cnt, + Word16 bfi, + Word16 *old_out, + Word16 *Q_old_wtda, + Decoder_State *st, + Word16 fullbandScale, + Word16 *acelp_zir ); + + void IMDCT_ivas_fx( + Word32 *x_fx, + Word16 q_x, + Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, + Word16 *xn_buf_fx, + Word16 q_xn_buf_fx, + const Word16 *tcx_aldo_window_1_fx, + const PWord16 *tcx_aldo_window_1_trunc_fx, + const PWord16 *tcx_aldo_window_2_fx, + const PWord16 *tcx_mdct_window_half_fx, + const PWord16 *tcx_mdct_window_minimum_fx, + const PWord16 *tcx_mdct_window_trans_fx, + const Word16 tcx_mdct_window_half_length, + const Word16 tcx_mdct_window_min_length, + Word16 index, + const UWord16 kernel_type, /* i : TCX transform kernel type */ + const Word16 left_rect, + const Word16 tcx_offset, + const Word16 overlap, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 L_spec_TCX5, + const Word16 L_frame_glob, + const Word16 frame_cnt, + const Word16 bfi, + Word16 *old_out_fx, + Word16 *q_old_out_fx, + const Word16 FB_flag, + Decoder_State *st, + const Word16 fullbandScale, + Word16 *acelp_zir_fx, + Word16 *q_acelp_zir_fx, + Word16 *pq_win ); + + void v_mult16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, + const Word32 total_brate, + const Word16 L_frame, + const Word16 last_L_frame, + const Word16 element_mode ); + + Word32 sum2_f_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ + ); + + Word32 sum2_f_16_gb_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + + Word32 sum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + + Word16 vq_dec_lvq_ivas_fx( + Word16 sf_flag, /* i : safety net flag */ + Word16 x[], /* o : Decoded vector Q(x2.56)*/ + Word16 indices[], /* i : Indices */ + Word16 stages, /* i : Number of stages */ + Word16 N, /* i : Vector dimension */ + Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ + Word16 no_bits /* (i): no. bits for lattice */ + ); + + Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ + ); + + void deleteCldfb_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ + ); + + void fd_bwe_dec_init_fx( + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ + ); + + void stereo_dft_dec_open( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_transport /* i : number of transport channels */ + ); + + void ivas_bw_switching_pre_proc_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + Word32 *old_syn_12k8_16k_fx, + Word16 Q, + Word16 Q_audio ); + + UWord32 mvl2s_r( + const Word32 x[], /* i : input vector */ + const Word16 q, + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ + ); + + void decoder_tcx_post_ivas_fx( + Decoder_State *st_fx, + Word16 *synth, + Word16 *synthFB, + Word16 Q_syn, + Word16 *A, + Word16 bfi, + Word16 MCT_flag ); + + void con_tcx_ivas_fx( + Decoder_State *st, /* i/o: coder memory state */ + Word16 synth[], /* i/o: synth[] Q0 */ + const Word16 coh, /* i : coherence of stereo signal */ + Word16 *noise_seed, /* i/o: noise seed for stereo */ + const Word16 only_left, /* i : TD-PLC only in left channel */ + const Word16 *A_cng /* i : CNG LP filter coefficients */ + ); + + void ivas_mdct_core_reconstruct_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ + Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ + Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + Word16 q_x, + Word16 e_sig[CPE_CHANNELS] ); + + void ari_start_encoding_14bits_ivas_fx( + Tastat *s ); + + void tcx_scalar_quantization_ivas_fx( + Word32 *x, /* i: input coefficients */ + Word16 x_e, /* i: exponent */ + Word16 *xq, /* o: quantized coefficients */ + Word16 L_frame, /* i: frame length */ + Word16 gain, /* i: quantization gain */ + Word16 gain_e, /* i: quantization gain exponent */ + Word16 offset, /* i: rounding offset (deadzone) */ + Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + const Word16 alfe_flag ); + + Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( + Word16 *x, /* Spectral coefficients Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + Word16 *lastnz_out, /* Q0 */ + Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ + const Word16 target, /* Target bits Q0*/ + Word16 *stop, /* Q0 */ + Word16 mode, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ + ); + + /* Qx*/ + Word16 usdequant_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qy*/ + ); + + /* Qx*/ + Word32 usdequant32_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word32 delta /* i: quantization step Qy*/ + ); + + /* o: index of the winning codeword */ + Word16 usquant_fx( + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ + ); + + /* o : Sum */ + Word32 Dot_product( + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ + ); + + /* o : dot product of x[] and y[] */ + Word32 dotp_fx( + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 *exp /* (o) : exponent of result (0..+30) */ + ); + + /* o : sum of all squared vector elements Q(2x+1)*/ + Word32 sum2_fx_mod( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ + ); + + void Copy_Scale_sig( + const Word16 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_16_32_DEPREC( + const Word16 x[], /* i : signal to scale i Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_16_32_r( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_16_32_no_sat( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Copy_Scale_sig_32_16( + const Word32 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void Random_Fill( + Word16 *seed, /* i/o: random seed */ + Word16 n, /* i : number of values */ + Word16 *y, /* o : output values */ + Word16 scaling /* i : scaling of values */ + ); + + /* o : mean of vector */ + Word16 mean_fx( + const Word16 *vec_fx, /* i : i vector */ + const Word16 lvec_fx /* i : length of i vector */ + ); + + /* o : mean of vector Qx */ + Word16 mean_no_sat_fx( + const Word16 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx /* i : length of input vector */ + ); + + /* o : mean of vector Qx */ + Word32 mean_no_sat_Word32_fx( + const Word32 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx, /* i : length of input vector */ + const Word16 gb ); + void sort( + UWord16 *x, /* i/o: Vector to be sorted */ + UWord16 len /* i/o: vector length */ + ); + + void sort_fx( + Word16 *r, /* i/o: Vector to be sorted in place */ + Word16 lo, /* i : Low limit of sorting range */ + Word16 up /* I : High limit of sorting range */ + ); + + void sort_32_fx( + Word32 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ + ); + + /* o : index of the minimum value in the input vector */ + Word16 minimum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *max_fx /* o : maximum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_exp_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 *exp_vec, /* i : exponents of input vector */ + const Word16 lvec_fx /* i : length of input vector */ + ); + + /* o : index of the maximum abs value in the input vector */ + Word16 maximum_abs_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max_val /* o : maximum value in the input vector */ + ); + + /* o : index of the minimum value in the input vector */ + Word16 minimum_abs32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ + ); + + /* o : index of the minimum value in the input vector */ + Word16 minimum_32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /* o : index of the maximum value in the input vector */ + Word16 maximum_abs_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /*! r: index of the maximum value in the input vector */ + Word16 maximum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max /* o : maximum value in the input vector */ + ); + + /*! r: index of the minimum value in the input vector */ + Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ + ); + + Word16 Exp16Array( + const Word16 n, /* (i): Array size */ + const Word16 *sx /* (i): Data array */ + ); + + Word16 Exp32Array( + const Word16 n, /* (i): Array size */ + const Word32 *sx /* (i): Data array */ + ); + + /* o : sum of all vector elements Qx*/ + Word32 sum16_32_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + /* o : sum of all vector elements Qx*/ + Word32 sum32_sat( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + /* o: variance of vector Qx+16*/ + Word32 var_fx_32( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ + ); + + /* o: variance of vector Qx+16*/ + Word32 var_fx_32in_32out( + const Word32 *x, /* i: input vector Qx*/ + Word16 *Qx, + const Word16 len, /* i: length of inputvector */ + const Word16 gb ); + + /* o: variance of vector Qx*/ + Word16 var_fx( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ + ); + + /* o: variance of vector Qx*/ + Word16 std_fx( + const Word16 x[], /* i: input vector */ + const Word16 len /* i: length of the input vector */ + ); + + /* o : the dot product x'*A*x */ + Word32 dot_product_mat_fx( + const Word16 *x, /* i : vector x Q15 */ + const Word32 *A, /* i : matrix A Q0*/ + const Word16 m /* i : vector & matrix size */ + ); + + void Vr_subt( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 N /* i : Vector lenght */ + ); + + /* o: index of the winning codevector */ + Word16 vquant_ivas_fx( + Word32 x[], /* i: vector to quantize Q25 */ + const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ + Word32 xq[], /* o: quantized vector Q25 */ + const Word32 cb[], /* i: codebook Q25 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ + ); + + /* o: index of the winning codevector */ + Word16 vquant_fx( + Word16 x[], /* i: vector to quantize Q13 */ + const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ + Word16 xq[], /* o: quantized vector Q13 */ + const Word16 cb[], /* i: codebook Q13 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ + ); + + Word16 w_vquant_fx( + Word16 x[], /* i: vector to quantize in Q10 */ + Word16 Qx, + const Word16 weights[], /* i: error weights in Q0 */ + Word16 xq[], /* o: quantized vector in Q15 */ + const Word16 cb[], /* i: codebook in Q15 */ + const Word16 cbsize, /* i: codebook size */ + const Word16 rev_vect /* i: reverse codebook vectors */ + ); + + /* o : return index with max energy value in vector Q0 */ + Word16 emaximum_fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word16 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ + ); + + /* o : return index with max energy value in vector Q0 */ + Word16 emaximum_32fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word32 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ + ); + + /* o : mean of the elements of the vector */ + Word32 Mean32( + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ + ); + + /* o : sum of all vector elements Qx*/ + Word32 sum32_fx( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + /* o : sum of all vector elements Qx*/ + Word16 sum16_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ + ); + + Word16 own_random2_fx( + Word16 seed ); + + void iDiv_and_mod_32( + const Word32 Numer, /* i : 32 bits numerator */ + const Word16 Denom, /* i : 16 bits denominator */ + Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ + Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ + const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ + ); + + void pz_filter_sp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word16 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + + Word32 root_a_fx( + Word32 a, + Word16 Q_a, + Word16 *exp_out ); + + Word32 root_a_over_b_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + + Word32 root_a_over_b_ivas_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + + void fir_fx( + const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd, /* i : 1 = update the memory, 0 = not */ + Word16 shift /* i : difference between Q15 and scaling of h[] */ + ); + + void v_add_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_shr_32( + Word32 x1[], /* i : Input vector 1 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N, /* i : Vector length */ + Word16 shift /*shift value*/ + ); + + void v_sub_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_add_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_sub_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + /* o: index of the winning codeword */ + Word16 squant_fx( + const Word16 x, /* i: scalar value to quantize */ + Word16 *xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ + ); + + Word16 squant_int_fx( + UWord8 x, /* i : scalar value to quantize */ + UWord8 *xq, /* o : quantized value */ + const UWord8 *cb, /* i : codebook */ + const Word16 cbsize /* i : codebook size */ + ); + + void pz_filter_dp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word32 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + + void Copy_Scale_sig32_16( + const Word32 *src, /* i : signal to scale Qx */ + Word16 *dst, /* o : scaled signal Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ + + void v_multc_att( + const Word16 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word16 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_att32( + const Word32 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ + ); + + void v_multc_att3232( + const Word32 x[], /* i : Input vector Qx */ + const Word32 att, /* i : Constant Q32, <= MAX_32 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ + ); + + void v_L_mult_1616( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_L_mult_3216( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void add_vec_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 Qx1, /* i : SCaling of input 1 */ + const Word16 x2[], /* i : Input vector 2 */ + const Word16 Qx2, /* i : SCaling of input 1 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 Qy, /* i : SCaling of output 1 */ + const Word16 N /* i : Vector lenght */ + ); + + /* o: Result (Normalized) */ + Word32 Add_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ + ); + + /* o: Result (Normalized) */ + Word32 Mul_flt32_Q15( + Word32 value, /* i: Pseudo_float Value */ + Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i: Q15 value */ + ); + + /* o: Result (Normalized) */ + Word32 Div_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ + ); + + /* o: Result (Normalized) */ + Word32 Calc_Energy_Autoscaled( + const Word16 *signal, /* i: Signal */ + Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ + Word16 len, /* i: Frame Length */ + Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ + ); + + Word16 Find_Max_Norm16( + const Word16 *src, + Word16 len ); + + Word16 Find_Max_Norm32( + const Word32 *src, + Word16 len ); + + /* o: Result in Q31 */ + Word32 Sqrt_Ratio32( + Word32 L_val1, /* i: Mantisa of Val1 */ + Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ + ); + + /* result in Q'15 + 'exp' */ + Word16 Invert16( + Word16 val, + Word16 *exp ); + + Word16 find_rem( + Word16 n, + Word16 m, + Word16 *r ); + + Word32 find_remd( + Word32 n, + Word32 m, + Word32 *r ); + + Word16 rint_new_fx( + Word32 x /*Q16 */ + ); + + Word16 erb_diff_search_fx( + Word16 *prev_erb, + const Word16 *curr_erb, + Word16 *dif_erb, + Word16 *pow_spec, + const Word16 *cb_fx, + Word16 cb_size, + Word16 cb_dim, + Word16 offset ); + + void Acelp_dec_total_exc( + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + const Word16 gain_code16, /* i : Gain code Q0 */ + const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ + const Word16 i_subfr, /* i ; subfr */ + const Word16 *code_fx, /* i : code in Q9 */ + const Word16 L_subfr /* i : Subframne lenght */ + ); + + UWord32 UL_inverse( + const UWord32 UL_val, + Word16 *exp ); + + UWord32 UL_div( + const UWord32 UL_num, + const UWord32 UL_den ); + + Word16 ratio( + const Word32 numer, + const Word32 denom, + Word16 *expo ); + + void hp400_12k8_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ + ); + + void hp400_12k8_ivas_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ + ); + + Word16 dot_prod_satcontr( + const Word16 *x, + const Word16 *y, + Word16 qx, + Word16 qy, + Word16 *qo, + Word16 len ); + + void E_UTIL_f_convolve( + const Word16 x[], + const Word16 h[], + Word16 y[], + const Word16 size ); + + void floating_point_add( + Word32 *mx, /* io: mantissa of the addend Q31 */ + Word16 *ex, /* io: exponent of the addend Q0 */ + const Word32 my, /* i: mantissa of the adder Q31 */ + const Word16 ey /* i: exponent of the adder Q0 */ + ); + + void delay_signal_fx( + Word16 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word16 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ + ); + + void delay_signal32_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ + ); + + Word16 lin_interp_ivas_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ + ); + + Word16 lin_interp_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ + ); + + Word16 ceil_log_2( + UWord64 val ); + + Word32 imax_pos_fx( + const Word32 *y /* i : Input vector for peak interpolation Qx*/ + ); + + void msvq_enc_ivas_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ + const Word16 Q_cb, /* i : Codebook Q */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ + const Word16 u_e, /* i : Exponent for Vector to be encoded */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8 */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 applyDCT_flag, /* i : applyDCT flag */ + Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ + Word16 Idx[] /* o : Indices */ + ); + + void msvq_dec_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 Idx[], /* i : Indices */ + const Word16 applyIDCT_flag, /* i : applyIDCT flag */ + const Word32 *invTrfMatrix, /* i : synthesis matrix */ + Word32 *uq, /* o : quantized vector */ + Word16 *uq_ind, /* o : quantized vector (fixed point) */ + Word16 exp ); + + void dec_FDCNG_MSVQ_stage1_fx( + Word16 j_full, /* i : index full range */ + Word16 n, /* i : dimension to generate */ + const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ + const DCTTYPE idcttype, /* i : specify which IDCT */ + Word32 *uq, /* o : synthesized stage1 vector Q20 */ + Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ + ); + + void dctT2_N_apply_matrix_fx( + const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ + Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ + const Word16 dct_dim, /* i : dct processing dim possibly truncated */ + const Word16 fdcngvq_dim, /* i : fdcng domain length */ + const Word32 *matrix, /* i : IDCT matrix */ + const Word16 matrix_row_dim, /* i : */ + const DCTTYPE dcttype /* i : matrix operation type */ + ); + + Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + + Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + + void v_mult_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_sub_s16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void v_sub32_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ + ); + + void ivas_swb_tbe_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ + const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ + Word16 Q_exc, + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *Q_white_exc ); + + Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ + ); + + ivas_error acelp_core_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 output_fx[], /* o : synthesis @internal Fs */ + Word16 synth_fx16[], /* o : synthesis */ + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 *unbits, /* o : number of unused bits */ + Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const Word16 last_element_mode, /* i : last element mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 read_sid_info /* i : read SID info flag */ + ); + + void wtda_fx32( + const Word32 *new_audio, /* i : input audio Q11 */ + Word32 *wtda_audio, /* o : windowed audio Q11 */ + Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ + const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ + const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const Word16 L /* i : length */ + ); + + ivas_error core_switching_pre_dec_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 ); + + void hp20_fx_32( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + + void hp20_fx_32_opt( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + + void getTCXMode_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Decoder_State *st0, /* i : bitstream */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ + ); + + void getTCXWindowing_ivas_fx( + const Word16 core, /* i : current frame mode */ + const Word16 last_core, /* i : last frame mode */ + const Word16 element_mode, /* i : element mode */ + TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ + Decoder_State *st0 /* i : bitstream */ + ); + + Word16 ari_start_decoding_14bits_prm_ivas_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + + void generate_masking_noise_ivas_fx( + Word32 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 *exp_out, /* o : time-domain signal exp */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 length, /* i : frame size */ + const Word16 core, /* i : core */ + const Word16 return_noise, /* i : noise is returned instead of added */ + const Word16 secondary, /* i : flag to indicate secondary noise generation */ + const Word16 element_mode, /* i : element mode */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void SynthesisSTFT_dirac_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 samples_out, + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ + ); + + void generate_stereo_masking_noise_fx( + Word16 *syn, /* i/o: time-domain signal */ + Word16 Q_syn, + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 fadeOut, /* i : only fade out of previous state */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void SynthesisSTFT_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ + ); + + void FdCng_decodeSID_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ + ); + + void cldfb_restore_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + ivas_error cldfb_save_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ + ); + + Word16 sr2fscale( + const Word32 sr_core /* i : internal sampling rate */ + ); + + void Copy_Scale_sig32( + const Word32 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ + ); + + void swb_pre_proc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ + Word16 *Q_shb_spch, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ + ); + + void core_encode_update_ivas_fx( + Encoder_State *st /* i/o: Encoder state structure */ + ); + + void updt_enc_common_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 Q_new /* i : CUrrent frame scaling */ + ); + + /* o : Q(2x - 31 - gb) */ + Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb /* i : guard bits */ + ); + + Word32 sum2_16_exp_fx( + const Word16 *vec, /* i : input vector Q(15 - exp) */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ + ); + + Word32 sum2_32_exp_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ + ); + + Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + + void ProcessStereoIGF_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ + Word16 q_pITFMDCTSpectrum_1, + Word16 q_pITFMDCTSpectrum_2, + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + + void IGFEncApplyStereo_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + + void IGFSaveSpectrumForITF_ivas_fx( + IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word32 *pITFSpectrum, /* i : MDCT spectrum */ + Word16 exp_pITFSpectrum ); + + Word16 IGFEncWriteBitstream_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ + ); + + Word16 IGFSCFEncoderEncode_ivas_fx( + IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ + Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ + ); + + Word16 ari_encode_14bits_ext_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s, + Word32 symbol, /* Q0 */ + UWord16 const *cum_freq /* Q0 */ + ); + + Word16 ari_encode_14bits_sign_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word32 bits, /* Q0 */ + Tastat *s, + Word16 sign /* Q0 */ + ); + + Word16 ari_done_encoding_14bits_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s ); + + void IGFEncConcatenateBitstream( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + const Word16 bsBits, /* i : number of IGF bits written to list of indices */ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ + ); + + void hq_generic_hf_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ + Word16 length ); + + Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ); + + Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + + void lsf_syn_mem_backup_ivas_fx( + Encoder_State *st_fx, /* i: state structure */ + Word16 *btilt_code_fx, /* i: tilt code Q15 */ + Word32 *gc_threshold_fx, /* i: Q16 */ + Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 *next_force_sf_bck_fx, /* o: */ + Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ + Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *streaklimit, /* Q15 */ + Word16 *pstreaklen ); + + ivas_error config_acelp1_fx( + const Word16 enc_dec, /* i : encoder/decoder flag */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 core_brate_inp, /* i : core bitrate */ + const Word16 core, /* i : core */ + const Word16 extl, /* i : extension layer */ + const Word32 extl_brate, /* i : extension layer bitrate */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ + ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ + const Word16 signaling_bits, /* i : number of signaling bits */ + const Word16 coder_type, /* i : coder type */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 tc_subfr, /* i : TC subfr ID */ + const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ + Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ + Word16 *unbits, /* o : number of unused bits */ + const Word16 element_mode, /* i : element mode */ + Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 idchan, /* i : stereo channel ID */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) @@ -10732,749 +10737,749 @@ ivas_error config_acelp1_fx( #endif #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) -ivas_error push_next_indice_( - const char *caller, + ivas_error push_next_indice_( + const char *caller, #else ivas_error push_next_indice( #endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ + ); #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) -ivas_error push_next_bits_( - const char *caller, + ivas_error push_next_bits_( + const char *caller, #else ivas_error push_next_bits( #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ -); - -/*! r: index of next coefficient */ -Word16 get_next_coeff_mapped_ivas_fx( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ -); - -void RCcontextMapping_encode2_no_mem_s17_LCS_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - Word16 lastnz, /* Q0 */ - const Word16 nbbits, /* Q0 */ - const Word16 resQMaxBits, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg ); - -void writeTCXparam_fx( - Encoder_State *st, /* i/o: Encoder State handle */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ - Word16 param[], /* i : parameters */ - const Word16 nbits_header, - const Word16 nbits_start, - const Word16 nbits_lpc, - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ - Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ - const Word16 target_bitsTCX10[2], - const Word16 pre_past_flag ); - -void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ -); - -void init_coder_ace_plus_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ - const Word32 igf_brate, /* i : IGF configuration bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void core_coder_reconfig_ivas_fx( - Encoder_State *st, - const Word32 last_total_brate ); - -void core_coder_mode_switch_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word32 last_total_brate, /* i : last bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ -); - -void configureFdCngEnc_ivas_fx( - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, /* Q0 */ - const Word32 total_brate /* Q0 */ -); - -Word16 getTcxonly_ivas_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ -); - -void SetModeIndex_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ -); - -void IGFEncSetMode_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word32 total_brate, /* i : encoder total bitrate */ - const Word16 bwidth, /* i : encoder audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void init_tcx_cfg_ivas_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag ); - -Word16 msvq_stage1_dct_search_fx( - const Word32 *u_fx, /* i : target exp : u_e */ - const Word16 u_e, /* i : exp for target Q0 */ - const Word16 N, /* i : target length and IDCT synthesis length */ - const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ - const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ - Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ - const Word16 *midQ_truncQ_fx, /* i : midQ vector */ - const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ - const Word16 n_segm, /* i : number of segments */ - const Word16 *cols_per_segment, /* i : remaining length per segment */ - const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ - const Word16 *entries_per_segment, /* i : number of rows per segment */ - const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ - const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ - const Word16 npost_check, /* i : number of neigbours to check , should be even */ - Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ - Word16 *indices_st1_local, /* o : selected cand indices */ - Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ - Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ - Word16 *dist1_ptr_e ); - -Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( - const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ - const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ - const Word32 *u_fx, /* i : target signal */ - const Word16 u_e, /* i : exp for target signal */ - const Word16 maxC_st1, /* i : number of candidates in stage1 */ - Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ - Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ -); - -void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ -); - -ivas_error IGF_Reconfig_fx( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ + ); + + /*! r: index of next coefficient */ + Word16 get_next_coeff_mapped_ivas_fx( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ + ); + + void RCcontextMapping_encode2_no_mem_s17_LCS_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + Word16 lastnz, /* Q0 */ + const Word16 nbbits, /* Q0 */ + const Word16 resQMaxBits, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg ); + + void writeTCXparam_fx( + Encoder_State *st, /* i/o: Encoder State handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ + Word16 param[], /* i : parameters */ + const Word16 nbits_header, + const Word16 nbits_start, + const Word16 nbits_lpc, + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ + Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ + const Word16 target_bitsTCX10[2], + const Word16 pre_past_flag ); + + void calculate_hangover_attenuation_gain_ivas_fx( + Encoder_State *st, /* i : encoder state structure */ + Word16 *att, /* o : attenuation factor */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ + ); + + void init_coder_ace_plus_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ + ); + + void core_coder_reconfig_ivas_fx( + Encoder_State *st, + const Word32 last_total_brate ); + + void core_coder_mode_switch_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word32 last_total_brate, /* i : last bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ + ); + + void configureFdCngEnc_ivas_fx( + HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, /* Q0 */ + const Word32 total_brate /* Q0 */ + ); + + Word16 getTcxonly_ivas_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ + ); + + void SetModeIndex_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ + ); + + void IGFEncSetMode_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word32 total_brate, /* i : encoder total bitrate */ + const Word16 bwidth, /* i : encoder audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void init_tcx_cfg_ivas_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag ); + + Word16 msvq_stage1_dct_search_fx( + const Word32 *u_fx, /* i : target exp : u_e */ + const Word16 u_e, /* i : exp for target Q0 */ + const Word16 N, /* i : target length and IDCT synthesis length */ + const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ + Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ + const Word16 *midQ_truncQ_fx, /* i : midQ vector */ + const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ + const Word16 n_segm, /* i : number of segments */ + const Word16 *cols_per_segment, /* i : remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ + const Word16 *entries_per_segment, /* i : number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ + const Word16 npost_check, /* i : number of neigbours to check , should be even */ + Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ + Word16 *indices_st1_local, /* o : selected cand indices */ + Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ + Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ + Word16 *dist1_ptr_e ); + + Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( + const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ + const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ + const Word32 *u_fx, /* i : target signal */ + const Word16 u_e, /* i : exp for target signal */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ + Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ + Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ + ); + + void FEC_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ + const Word16 Q_synth /* i : input scaling */ + ); + + ivas_error IGF_Reconfig_fx( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void core_switching_post_enc_ivas_fx( + Encoder_State *st /* i/o: encoder state structure */ #ifndef CLEANUP_ACELP_ENC - , - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new + , + Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ + Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ + Word16 A_fx[], /* i : unquant. LP filter coefs. */ + Word16 Q_new #endif -); - -void residu_ivas_fx( - const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ - const Word16 a_exp, - const Word16 m, /* i : order of LP filter */ - const Word32 *x, /* i : input signal (usually speech) Qx*/ - Word32 *y, /* o : output signal (usually residual) Qx*/ - const Word16 l /* i : size of filtering */ -); - -void WriteToBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - -void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - -/*===========================================================================================*/ -/*----------------------------------------------------------------------------------* - * MODE1 prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: output random value */ -Word16 own_random( - Word16 *seed /* i/o: random seed */ -); - -/*! r: sum of all vector elements */ -Word16 sum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ -); - -void set_c( - Word8 y[], /* i/o: Vector to set */ - const Word8 a, /* i : Value to set the vector to */ - const Word32 N /* i : Length of the vector */ -); - -void set_s( - Word16 y[], /* i/o: Vector to set */ - const Word16 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ -); - -void set_l( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Length of the vector */ -); - -void set_zero_fx( - Word32 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void set_zero2_fx( - Word32 *vec, /* o : input vector */ - const Word32 lvec /* i : length of the vector */ -); - -void set16_zero_fx( - Word16 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ -); - -void mvs2s( - const Word16 x[], /* i : input vector */ - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - -void mvl2l( - const Word32 x[], /* i : input vector */ - Word32 y[], /* o : output vector */ - const Word16 n /* i : vector size */ -); - -Word16 maximumAbs_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ -); - -void sort_l( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 len /* i/o: vector length */ -); - -ivas_error push_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 id, /* i : ID of the indice */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); - -ivas_error push_next_indice_( + ); + + void residu_ivas_fx( + const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ + const Word16 a_exp, + const Word16 m, /* i : order of LP filter */ + const Word32 *x, /* i : input signal (usually speech) Qx*/ + Word32 *y, /* o : output signal (usually residual) Qx*/ + const Word16 l /* i : size of filtering */ + ); + + void WriteToBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + void WriteToBitstream_ivas_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + + /*===========================================================================================*/ + /*----------------------------------------------------------------------------------* + * MODE1 prototypes + *----------------------------------------------------------------------------------*/ + + /*! r: output random value */ + Word16 own_random( + Word16 *seed /* i/o: random seed */ + ); + + /*! r: sum of all vector elements */ + Word16 sum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ + ); + + void set_c( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word32 N /* i : Length of the vector */ + ); + + void set_s( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ + ); + + void set_l( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ + ); + + void set_zero_fx( + Word32 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ + ); + + void set_zero2_fx( + Word32 *vec, /* o : input vector */ + const Word32 lvec /* i : length of the vector */ + ); + + void set16_zero_fx( + Word16 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ + ); + + void mvs2s( + const Word16 x[], /* i : input vector */ + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ + ); + + void mvl2l( + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 n /* i : vector size */ + ); + + Word16 maximumAbs_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ + ); + + /*! r: index of the minimum value in the input vector */ + Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ + ); + + void sort_l( + Word32 *x, /* i/o: Vector to be sorted */ + Word16 len /* i/o: vector length */ + ); + + ivas_error push_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ + ); + + ivas_error push_next_indice_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -); + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ + ); -ivas_error push_next_bits_( + ivas_error push_next_bits_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -/*! r: maximum number of indices */ -Word16 get_BWE_max_num_indices( - const Word32 extl_brate /* i : extensiona layer bitrate */ -); - -/*! r: maximum number of indices */ -Word16 get_ivas_max_num_indices_metadata_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); -ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ -); - -ivas_error check_ind_list_limits( - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -); - -void move_indices( - INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ - INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const Word16 nb_indices /* i : number of moved indices */ -); - -/*! r: index of the indice in the list, -1 if not found */ -Word16 find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const Word16 id, /* i : ID of the indice */ - UWord16 *value, /* o : value of the quantized indice */ - Word16 *nb_bits /* o : number of bits used to quantize the indice */ -); - -/*! r: number of deleted indices */ -UWord16 delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 id /* i : ID of the indice */ -); - -/*! r: value of the indice */ -UWord16 get_indice_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -); - -void reset_indices_dec( - Decoder_State *st /* i/o: decoder state structure */ -); - -Word16 rate2EVSmode( - const Word32 brate, /* i : bitrate */ - Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ -); - -/*! r: 1 = OK, 0 = something wrong */ -ivas_error read_indices_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - UWord16 bit_stream[], /* i : bitstream buffer */ - UWord16 num_bits, /* i : number of bits in bitstream */ - Word16 *prev_ft_speech, - Word16 *CNG, - Word16 bfi /* i : bad frame indicator */ -); - -void ivas_set_bitstream_pointers( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -Decoder_State **reset_elements( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void convertSerialToBytestream_fx( - const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ - const UWord16 num_bits, /* i : number of bits in the input bitstream */ - UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ -); - -void mdct_switching_dec_fx( - Decoder_State *st /* i/o: decoder state structure */ -); - -Word16 print_disclaimer( - FILE *fPtr ); - -void preemph_ivas_fx( - Word32 *signal, /* i/o: signal Qx*/ - const Word16 mu, /* i : preemphasis factor Q15*/ - const Word16 L, /* i : vector size Q0*/ - Word32 *mem /* i/o: memory (x[-1]) Qx*/ -); - -void create_offset( - UWord32 *offset_scale1, - UWord32 *offset_scale2, - const Word16 mode, - const Word16 prediction_flag ); - -void BASOP_cfft_ivas( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - Word16 s, /* i : stride real and imag part */ - Word16 *scale /* i : scalefactor */ -); - -Word32 ar_div_ivas( - Word32 num, - Word32 denum ); - -Word32 Mult_32_16( - Word32 a, - Word16 b ); - -Word32 Mult_32_32( - Word32 a, - Word32 b ); + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ + ); + + /*! r: maximum number of indices */ + Word16 get_ivas_max_num_indices_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ + ); + + /*! r: maximum number of indices */ + Word16 get_BWE_max_num_indices( + const Word32 extl_brate /* i : extensiona layer bitrate */ + ); + + /*! r: maximum number of indices */ + Word16 get_ivas_max_num_indices_metadata_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ + ); + ivas_error ind_list_realloc( + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ + ); + + ivas_error check_ind_list_limits( + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ + ); + + void move_indices( + INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ + INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ + const Word16 nb_indices /* i : number of moved indices */ + ); + + /*! r: index of the indice in the list, -1 if not found */ + Word16 find_indice( + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + const Word16 id, /* i : ID of the indice */ + UWord16 *value, /* o : value of the quantized indice */ + Word16 *nb_bits /* o : number of bits used to quantize the indice */ + ); + + /*! r: number of deleted indices */ + UWord16 delete_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 id /* i : ID of the indice */ + ); + + /*! r: value of the indice */ + UWord16 get_indice_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ + ); + + void reset_indices_dec( + Decoder_State *st /* i/o: decoder state structure */ + ); + + Word16 rate2EVSmode( + const Word32 brate, /* i : bitrate */ + Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ + ); + + /*! r: 1 = OK, 0 = something wrong */ + ivas_error read_indices_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 bit_stream[], /* i : bitstream buffer */ + UWord16 num_bits, /* i : number of bits in bitstream */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ + ); + + void ivas_set_bitstream_pointers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + ); + + Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + ); + + void convertSerialToBytestream_fx( + const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ + const UWord16 num_bits, /* i : number of bits in the input bitstream */ + UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ + ); + + void mdct_switching_dec_fx( + Decoder_State *st /* i/o: decoder state structure */ + ); + + Word16 print_disclaimer( + FILE *fPtr ); + + void preemph_ivas_fx( + Word32 *signal, /* i/o: signal Qx*/ + const Word16 mu, /* i : preemphasis factor Q15*/ + const Word16 L, /* i : vector size Q0*/ + Word32 *mem /* i/o: memory (x[-1]) Qx*/ + ); + + void create_offset( + UWord32 *offset_scale1, + UWord32 *offset_scale2, + const Word16 mode, + const Word16 prediction_flag ); + + void BASOP_cfft_ivas( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ + ); + + Word32 ar_div_ivas( + Word32 num, + Word32 denum ); + + Word32 Mult_32_16( + Word32 a, + Word16 b ); + + Word32 Mult_32_32( + Word32 a, + Word32 b ); #ifdef DEBUGGING -void read_next_force( - int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ - FILE *f_force, /* i : force switching profile (0 if N/A) */ - int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ -); + void read_next_force( + int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ + FILE *f_force, /* i : force switching profile (0 if N/A) */ + int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ + ); #endif -ivas_error init_encoder_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ -); - -ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - const Word16 Q_new ); - -void flip_and_downmix_generic_fx32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ -); - -/* o : Q(2x - 31 - gb) */ -Word16 quant_2p_2N1_fx( - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ -); - -void bands_and_bit_alloc_ivas_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); - -void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ - Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ - const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ - const Word16 tilt_fact, /* i : tilt factor Q15 */ - Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ - Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ - const Word16 gamma, /* i : weighting factor Q15 */ - const Word16 L_look /* i : look-ahead Q0*/ -); - -Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - const Word16 target, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem ); - -Word16 RCcontextMapping_encode2_estimate_bandWise_fx( - Word16 *x, /* Q0 */ - const Word16 start_line, /* Q0 */ - const Word16 end_line, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ -); - -/*! r: Q15 */ -Word16 expfp_evs_fx( - const Word16 x, /* i : mantissa Q15-e */ - const Word16 x_e /* i : exponent Q0 */ -); - -void tcx_arith_render_envelope_ivas_fx( - const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i : number of spectral lines Q0*/ - const Word16 L_spec, /* i : length of the coded spectrum Q0*/ - const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o : shaped signal envelope Q16*/ -); - -void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ -); - -void UnmapIndex_fx( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word8 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ -); + ivas_error init_encoder_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ + ); + + ivas_error acelp_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + const Word16 Q_new ); + + void flip_and_downmix_generic_fx32( + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ + ); + + /* o : Q(2x - 31 - gb) */ + Word16 quant_2p_2N1_fx( + const Word16 pos1, /* i: position of the pulse 1 */ + const Word16 pos2, /* i: position of the pulse 2 */ + const Word16 N /* i: number of bits FOR position */ + ); + + void bands_and_bit_alloc_ivas_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ + ); + + void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ + Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ + const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ + const Word16 tilt_fact, /* i : tilt factor Q15 */ + Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ + Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 L_look /* i : look-ahead Q0*/ + ); + + Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + const Word16 target, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem ); + + Word16 RCcontextMapping_encode2_estimate_bandWise_fx( + Word16 *x, /* Q0 */ + const Word16 start_line, /* Q0 */ + const Word16 end_line, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ + ); + + /*! r: Q15 */ + Word16 expfp_evs_fx( + const Word16 x, /* i : mantissa Q15-e */ + const Word16 x_e /* i : exponent Q0 */ + ); + + void tcx_arith_render_envelope_ivas_fx( + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ + const Word16 L_spec, /* i : length of the coded spectrum Q0*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ + ); + + void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ + ); + + void UnmapIndex_fx( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word8 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ + ); #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) -Word32 tcx_hm_render_fx( - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ -); - -void tcx_hm_modify_envelope_fx( - const Word16 gain, /* i: HM gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - const Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ -); - -void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ -); - -void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ -); - -void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ -); - -void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ -); - -void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); -void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); -void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); -void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); - -Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); - -Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); -Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - -void ResetTnsData_flt( - STnsData *pTnsData ); - -void ClearTnsFilterCoefficients_flt( - STnsFilter *pTnsFilter ); - -void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - Word16 *pnBits /* o : number of written bits */ -); - -Word16 DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const Word16 *stream, - Word16 *pnSize, - STnsData *pTnsData ); - -void WriteTnsData( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const Word16 *stream, /* i : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - BSTR_ENC_HANDLE hBstr, /* o : bitstream */ - Word16 *pnBits /* o : number of written bits */ -); - -void ReadTnsData_ivas( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -void analysisCldfbEncoder_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *timeIn, /*q11*/ - Word16 timeInq, /*q0*/ - Word16 samplesToProcess, /*q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 *ppBuf_Ener, - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - -ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -); - -void resampleCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate /* i : new samplerate to operate */ -); - -ivas_error cldfb_save_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ -); - -/*! r: flag indicating a valid bitrate */ -Word16 is_EVS_bitrate( - const Word32 ivas_total_brate, /* i : EVS total bitrate */ - Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ -); - -ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ -); - -void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ -); - -/*===========================================================================================*/ + Word32 tcx_hm_render_fx( + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ + ); + + void tcx_hm_modify_envelope_fx( + const Word16 gain, /* i: HM gain Q11 */ + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + const Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + const Word16 L_frame /* i: number of spectral lines Q0 */ + ); + + void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ + ); + + void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ + ); + + void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ + ); + + void writeLPCparam( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ + ); + + void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); + void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); + void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); + void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); + + Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); + + Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); + Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + + void ResetTnsData_flt( + STnsData *pTnsData ); + + void ClearTnsFilterCoefficients_flt( + STnsFilter *pTnsFilter ); + + void EncodeTnsData( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + Word16 *pnBits /* o : number of written bits */ + ); + + Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + + void WriteTnsData( + const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ + const Word16 *stream, /* i : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + BSTR_ENC_HANDLE hBstr, /* o : bitstream */ + Word16 *pnBits /* o : number of written bits */ + ); + + void ReadTnsData_ivas( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + + void analysisCldfbEncoder_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *timeIn, /*q11*/ + Word16 timeInq, /*q0*/ + Word16 samplesToProcess, /*q0*/ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 *ppBuf_Ener, + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + + ivas_error openCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ + ); + + void resampleCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate /* i : new samplerate to operate */ + ); + + ivas_error cldfb_save_memory_ivas( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ + ); + + /*! r: flag indicating a valid bitrate */ + Word16 is_EVS_bitrate( + const Word32 ivas_total_brate, /* i : EVS total bitrate */ + Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ + ); + + ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ + ); + + void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ + ); + + /*===========================================================================================*/ #endif diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index c9d307ef2..7073ee69d 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -160,6 +160,7 @@ Word16 tbe_celp_exc_offset( * * Compute tbe bwe celp excitation *-------------------------------------------------------------------*/ +#ifndef CLEANUP_ACELP_ENC void tbe_celp_exc( const Word16 L_frame_fx, /* i : Frame lenght */ const Word16 i_subfr_fx, /* i : sub frame */ @@ -238,7 +239,13 @@ void tbe_celp_exc( * * Compute tbe bwe celp excitation *-------------------------------------------------------------------*/ +#endif + +#ifdef CLEANUP_ACELP_ENC +void tbe_celp_exc( +#else void tbe_celp_exc_ivas( +#endif const Word16 element_mode, /* i : element mode */ const Word16 idchan, /* i : channel ID */ const Word16 L_frame_fx, /* i : Frame lenght */ @@ -321,6 +328,8 @@ void tbe_celp_exc_ivas( *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ move16(); } + + return; } /*===========================================================================*/ @@ -349,6 +358,16 @@ void tbe_celp_exc_ivas( /* RETURN ARGUMENTS : */ /* _ None */ /*---------------------------------------------------------------------------*/ + +#ifdef CLEANUP_ACELP_ENC +static const Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, + -26319, -17530, -6393, 6393, 17530, 26319, + 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ +static const Word16 local_cos_table17[17] = { 32767, 30571, 24279, 14732, 3212, -8739, + -19519, -27683, -32137, -32137, -27683, + -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ +#endif + void flip_and_downmix_generic_fx( Word16 input[], /* i : input spectrum Qx*/ Word16 output[], /* o : output spectrum Qx*/ @@ -371,6 +390,7 @@ void flip_and_downmix_generic_fx( /*Word16 s_tmp[L_FRAME32k];*/ /*Word16 factor;*/ Word16 period; +#ifndef CLEANUP_ACELP_ENC Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, -26319, -17530, -6393, 6393, 17530, 26319, 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ @@ -378,14 +398,16 @@ void flip_and_downmix_generic_fx( -19519, -27683, -32137, -32137, -27683, -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ Word16 *local_negsin_table, *local_cos_table; +#endif Word32 L_tmp; /* 1850 Hz downmix */ period = 17; move16(); +#ifndef CLEANUP_ACELP_ENC local_negsin_table = local_negsin_table17; local_cos_table = local_cos_table17; - +#endif FOR( i = 0; i < length; i = i + 2 ) { @@ -467,9 +489,14 @@ void flip_and_downmix_generic_fx( { WHILE( ( j < period ) && ( i < length ) ) { +#ifdef CLEANUP_ACELP_ENC + L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ + L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ +#else L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ - output[i] = round_fx( L_tmp ); /*Qx */ +#endif + output[i] = round_fx( L_tmp ); /*Qx */ move16(); i++; j++; @@ -511,6 +538,7 @@ void flip_and_downmix_generic_fx32( /*Word16 s_tmp[L_FRAME32k];*/ /*Word16 factor;*/ Word16 period; +#ifndef CLEANUP_ACELP_ENC Word16 local_negsin_table17[17] = { 0, -11793, -22005, -29268, -32609, -31580, -26319, -17530, -6393, 6393, 17530, 26319, 31580, 32609, 29268, 22005, 11793 }; /* Q15 */ @@ -518,14 +546,16 @@ void flip_and_downmix_generic_fx32( -19519, -27683, -32137, -32137, -27683, -19519, -8739, 3212, 14732, 24279, 30571 }; /* Q15 */ Word16 *local_negsin_table, *local_cos_table; +#endif Word32 L_tmp; /* 1850 Hz downmix */ period = 17; move16(); +#ifndef CLEANUP_ACELP_ENC local_negsin_table = local_negsin_table17; local_cos_table = local_cos_table17; - +#endif FOR( i = 0; i < length; i = i + 2 ) { @@ -597,9 +627,14 @@ void flip_and_downmix_generic_fx32( WHILE( ( j < period ) && ( i < length ) ) { test(); +#ifdef CLEANUP_ACELP_ENC + L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table17[j] ); /*//Qx+16 */ + L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table17[j] ); /*Qx+16 */ +#else L_tmp = Mult_32_16( tmp_R[i + 4], local_cos_table[j] ); /*//Qx+16 */ L_tmp = Madd_32_16( L_tmp, tmp_I[i + 4], local_negsin_table[j] ); /*Qx+16 */ - output[i] = L_tmp; /*Qx */ +#endif + output[i] = L_tmp; /*Qx */ move32(); i++; j++; @@ -6136,7 +6171,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[0] ) ) ); /*Q23 */ #endif j = extract_l( L_shr( L_tmp, 23 ) ); @@ -6153,7 +6188,7 @@ void create_random_vector_fx( } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); @@ -6171,7 +6206,7 @@ void create_random_vector_fx( L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ } #else - L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ + L_tmp = L_abs( Mult_32_16( 2144047674, Random( &seed[1] ) ) ); /*Q23 */ #endif k = extract_l( L_shr( L_tmp, 23 ) ); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 0d867fd6f..9870d45cb 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -353,7 +353,11 @@ void decoder_acelp_fx( IF( st->igf != 0 ) { +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); +#else tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); +#endif } pitch_buffer[idx] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); // Q6 diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f08c5e767..983f6d8e6 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -164,6 +164,7 @@ ivas_error decod_gen_voic_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ + IF( st_fx->element_mode != EVS_MONO ) { pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -173,7 +174,11 @@ ivas_error decod_gen_voic_fx( pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#endif /*--------------------------------------------------------------* * LP filtering of the adaptive excitation diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index d897b116e..a25e259c0 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -267,7 +267,11 @@ void decod_gen_2sbfr_fx( test(); IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) ) { +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); +#else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); +#endif } /*--------------------------------------------------------------* diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 66819c4ac..3195a0b60 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -262,7 +262,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); +#else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); +#endif } pitch_buf[i_subfr / L_SUBFR] = shl( add( shl( T0, 2 ), T0_frac ), 4 ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index b7ceb81bc..28b3f2c02 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -240,8 +240,11 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ - +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#else tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); +#endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -617,7 +620,11 @@ void encod_gen_voic_ivas_fx( L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ move16(); +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); +#endif /*-----------------------------------------------------------------* * Find adaptive exitation diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 5290ecd22..5bb344a4d 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -288,7 +288,11 @@ void encod_gen_2sbfr( Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 +#ifdef CLEANUP_ACELP_ENC + tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); +#else tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); +#endif /*-----------------------------------------------------------------* * Find adaptive exitation -- GitLab From 08a75c40b44830e8c4b1126c9979ccacb6f06e3a Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jan 2026 22:06:37 +0100 Subject: [PATCH 10/14] harmonize encod_gen_voic_fx(), under CLEANUP_ACELP_ENC --- lib_enc/acelp_core_enc_fx.c | 18 ++++ lib_enc/enc_gen_voic_fx.c | 172 +++++++++++++++++++++++++----------- lib_enc/enc_pit_exc_fx.c | 14 +++ lib_enc/inov_enc_fx.c | 5 +- lib_enc/prot_fx_enc.h | 9 +- 5 files changed, 162 insertions(+), 56 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 716313065..324b7672f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -528,8 +528,13 @@ ivas_error acelp_core_enc_fx( hTdCngEnc->burst_ho_cnt = 0; move16(); /* VOICED frames in SC-VBR when bumped up*/ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, + exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#else encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#endif } } ELSE IF( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_24k40 ) ) ) @@ -541,8 +546,13 @@ ivas_error acelp_core_enc_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, + exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#else encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); +#endif } /* update st->mem_syn1 for ACELP core switching */ @@ -1385,7 +1395,11 @@ ivas_error acelp_core_enc_ivas_fx( move16(); /* VOICED frames in SC-VBR */ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#else encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } } ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) @@ -1400,7 +1414,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ +#ifdef CLEANUP_ACELP_ENC + encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#else encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); +#endif } /* update mem_syn1_flt for ACELP core switching */ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 28b3f2c02..639fdaffa 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -77,7 +77,7 @@ static void rem_offset( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================*/ - +#ifndef CLEANUP_ACELP_ENC void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -444,18 +444,22 @@ void encod_gen_voic_fx( return; } +#endif - +#ifdef CLEANUP_ACELP_ENC +void encod_gen_voic_fx( +#else void encod_gen_voic_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ - const Word16 speech_fx[], /* i : input speech Qnew -1 */ + const Word16 speech_fx[], /* i : input speech Q0 / Qnew -1 */ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q12*/ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* i/o: core synthesis Q_new - 1*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *exc2_fx, /* i/o: current enhanced excitation Q_new*/ + Word16 *syn_fx, /* i/o: core synthesis Qnew / Q_new - 1*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q0 / Q_new*/ + Word16 *exc2_fx, /* i/o: current enhanced excitation Q0 / Q_new*/ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ @@ -558,7 +562,12 @@ void encod_gen_voic_ivas_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) +#else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) +#endif { shift_wsp = sub( shift_wsp, 1 ); } @@ -595,21 +604,36 @@ void encod_gen_voic_ivas_fx( Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - q_h1 = sub( 14, norm_s( h1_fx[0] ) ); - Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn_fx, L_SUBFR, shift ); - test(); - test(); - IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn_fx, L_SUBFR, shift ); + } + ELSE +#endif { - /* During core transition, when the temporal correlation is non existent */ - rem_offset( xn_fx, xn_fx, L_SUBFR ); - rem_offset( cn_fx, cn_fx, L_SUBFR ); + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + + q_h1 = sub( 14, norm_s( h1_fx[0] ) ); + Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn_fx, L_SUBFR, shift ); + test(); + test(); + IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) + { + /* During core transition, when the temporal correlation is non existent */ + rem_offset( xn_fx, xn_fx, L_SUBFR ); + rem_offset( cn_fx, cn_fx, L_SUBFR ); + } } /*----------------------------------------------------------------* @@ -630,7 +654,16 @@ void encod_gen_voic_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE +#endif + { + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -721,7 +754,14 @@ void encod_gen_voic_ivas_fx( gcode16 = round_fx_sat( Lgcode ); #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ + IF( st_fx->element_mode == EVS_MONO ) + { + hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ + } + ELSE + { + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR ); /* Q15 */ + } #else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ #endif @@ -747,30 +787,47 @@ void encod_gen_voic_ivas_fx( * Update memory of the weighting filter *-----------------------------------------------------------------*/ - /*At this point - xn has to be in Qnew - yn has to be in Qnew - y2_fx has to be in Q9 - gcode16 in Q_new - gain_pit_fx in Q14 - */ - Scale_sig( xn_fx, L_SUBFR, 1 ); - Scale_sig( y1_fx, L_SUBFR, 1 ); - /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); - Ltmp = L_shl( Ltmp, add( 5, shift ) ); - Ltmp = L_negate( Ltmp ); - Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 ); - Ltmp = L_add( Ltmp, Ltmp2 ); - Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx ); - Ltmp = L_sub( Ltmp, Ltmp3 ); - - /*Ltmp is in Q14 + Qnew here - We need memWo in Qnew -1 */ +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ + Ltmp = L_mult( gcode16, y2_fx[L_SUBFR - 1] ); /*Q10*/ + Ltmp = L_shl( Ltmp, add( 5, shift ) ); /*Q15+shift*/ + Ltmp = L_negate( Ltmp ); + Ltmp = L_mac( Ltmp, xn_fx[L_SUBFR - 1], 16384 /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_msu( Ltmp, y1_fx[L_SUBFR - 1], gain_pit_fx /*Q14*/ ); /* Q_new-1+shift+14+1 */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* 15 + Q_new */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + } + ELSE +#endif + { + /*At this point + xn has to be in Qnew + yn has to be in Qnew + y2_fx has to be in Q9 + gcode16 in Q_new + gain_pit_fx in Q14 + */ + Scale_sig( xn_fx, L_SUBFR, 1 ); + Scale_sig( y1_fx, L_SUBFR, 1 ); + /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ + Ltmp = L_mult0( gcode16, y2_fx[L_SUBFR - 1] ); + Ltmp = L_shl( Ltmp, add( 5, shift ) ); + Ltmp = L_negate( Ltmp ); + Word32 Ltmp2 = L_mult0( xn_fx[L_SUBFR - 1], 16384 ); + Ltmp = L_add( Ltmp, Ltmp2 ); + Word32 Ltmp3 = L_mult0( y1_fx[L_SUBFR - 1], gain_pit_fx ); + Ltmp = L_sub( Ltmp, Ltmp3 ); + + /*Ltmp is in Q14 + Qnew here + We need memWo in Qnew -1 */ + + Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1 + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + move16(); + } - Ltmp = L_shl( Ltmp, sub( 1, shift ) ); // Q14 + Qnew + 1 - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ - move16(); IF( gain_preQ_fx != 0 ) { tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); @@ -787,10 +844,10 @@ void encod_gen_voic_ivas_fx( move16(); /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ - Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Q10 / Qnew + 9 + 1 */ + Ltmp = L_shl( Ltmp, 5 ); /*Q15 / Qnew + 9+ 1+5 */ + Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Q15 / Qnew + 14 + 1*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /*Q15 / Qnew + 14 + 1 +1 */ exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); move16(); } @@ -806,10 +863,10 @@ void encod_gen_voic_ivas_fx( { /* code in Q9, gain_pit in Q14 */ /*gcode16 in Qnew*/ - Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ - Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Q10 / Qnew + 9 + 1 */ + Ltmp = L_shl_sat( Ltmp, 5 ); /*Q15 / Qnew + 9+ 1+5 */ + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Q15 / Qnew + 14 + 1*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /*Q15 / Qnew + 14 + 1 +1 */ exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); } } @@ -828,7 +885,16 @@ void encod_gen_voic_ivas_fx( * Update A(z) filters *-----------------------------------------------------------------*/ - syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); + } + ELSE +#endif + { + syn_filt_fx( 1, p_Aq_fx, M, &exc_fx[i_subfr_fx], &syn_fx[i_subfr_fx], L_SUBFR, hLPDmem->mem_syn, 1 ); + } p_Aw_fx += ( M + 1 ); p_Aq_fx += ( M + 1 ); diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index b40bab692..f98b21729 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -374,6 +374,14 @@ void enc_pit_exc_fx( } ELSE IF( use_fcb == 2 ) { +#ifdef CLEANUP_ACELP_ENC + /*-----------------------------------------------------------------* + * Innovation encoding + *-----------------------------------------------------------------*/ + + inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); +#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -400,6 +408,7 @@ void enc_pit_exc_fx( gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); #endif } +#endif /*-----------------------------------------------------------------* * Gain encoding @@ -413,6 +422,10 @@ void enc_pit_exc_fx( * Innovation & gain encoding *-----------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); +#else #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -435,6 +448,7 @@ void enc_pit_exc_fx( gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); #endif } +#endif /*-----------------------------------------------------------------* * Gain encoding diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 4a9ba19fc..c5de16ceb 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -370,7 +370,7 @@ Word16 inov_encode_ivas_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ const Word16 shift, - const Word16 Q_new ) + Word16 Q_new ) { Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2; Word16 nBits, cmpl_flag; @@ -422,6 +422,9 @@ Word16 inov_encode_ivas_fx( #ifdef CLEANUP_ACELP_ENC ELSE { + Q_new = 0; + move16(); + Qxn = 0; move16(); Qcn = 0; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index bfc2228b9..edfb199fa 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2071,6 +2071,7 @@ ivas_error encod_ppp_ivas_fx( Word16 Q_new, Word16 shift ); +#ifndef CLEANUP_ACELP_ENC void encod_gen_voic_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : i speech Q0*/ @@ -2089,8 +2090,12 @@ void encod_gen_voic_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 shift, Word16 Q_new ); - +#endif +#ifdef CLEANUP_ACELP_ENC +void encod_gen_voic_fx( +#else void encod_gen_voic_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -3564,7 +3569,7 @@ Word16 inov_encode_fx( Word16 *unbits, /* o : number of unused bits for PI */ const Word16 L_subfr, /* i : subframe length */ const Word16 shift, - const Word16 Q_new ); + Word16 Q_new ); void gain_enc_mless_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ -- GitLab From ff8fe0545a08c0f750f3a31d22343fb4f17816ab Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 10:36:52 +0100 Subject: [PATCH 11/14] harmonize encod_tran_fx(), under CLEANUP_ACELP_ENC --- lib_com/ivas_prot_fx.h | 12 ++--- lib_enc/acelp_core_enc_fx.c | 9 +++- lib_enc/enc_gen_voic_fx.c | 9 +++- lib_enc/enc_ppp_fx.c | 14 +++--- lib_enc/enc_tran_fx.c | 80 +++++++++++++++++++++++-------- lib_enc/enc_uv_fx.c | 5 +- lib_enc/gs_enc_fx.c | 9 ++-- lib_enc/ivas_td_low_rate_enc_fx.c | 39 +++++++-------- lib_enc/prot_fx_enc.h | 35 ++++++++------ 9 files changed, 136 insertions(+), 76 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 85bbcb4b1..6b46e6b8d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2996,7 +2996,7 @@ Word16 ivas_acelp_tcx20_switching_fx( const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */ ); -void encod_gen_2sbfr( +void encod_gen_2sbfr_fx( Encoder_State *st, /* i/o: state structure */ const Word16 speech[], /* i : input speech */ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */ @@ -3010,8 +3010,8 @@ void encod_gen_2sbfr( Word16 *bwe_exc, /* o : excitation for SWB TBE */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel */ - Word16 Q_new, - Word16 shift + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); void acelp_fast_fx( @@ -4489,7 +4489,7 @@ ivas_error signaling_enc_secondary_fx( const Word16 tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag */ ); -void tdm_low_rate_enc( +void tdm_low_rate_enc_fx( Encoder_State *st, /* i/o: State structure */ const Word16 Aq[], /* i : 12k8 Lp coefficient */ const Word16 *res, /* i : residual signal Q_new*/ @@ -4500,8 +4500,8 @@ void tdm_low_rate_enc( Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ const Word16 attack_flag, /* i : attack flag */ const Word16 *lsf_new, /* i : current frame ISF vector x2.56 */ - Word16 *tmp_noise, /* o : long-term noise energy Q8 */ - Word16 Q_new + Word16 *tmp_noise, /* o : long-term noise energy Q8 */ + const Word16 Q_new /* i : Scaling factor */ ); void tdm_low_rate_dec_fx( diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 324b7672f..9fa47424f 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -499,8 +499,13 @@ ivas_error acelp_core_enc_fx( } ELSE IF( EQ_16( coder_type, TRANSITION ) ) { +#ifdef CLEANUP_ACELP_ENC + tc_subfr_fx = encod_tran_ivas_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, + exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ +#else tc_subfr_fx = encod_tran_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ +#endif } ELSE IF( hSC_VBR->ppp_mode ) { @@ -1344,11 +1349,11 @@ ivas_error acelp_core_enc_ivas_fx( { IF( LE_16( st->coder_type, UNVOICED ) ) { - tdm_low_rate_enc( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new ); + tdm_low_rate_enc_fx( st, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, 0 /*attack_flag*/, lsf_new_fx, &tmp_noise_fx, Q_new ); } ELSE /* GENERIC */ { - encod_gen_2sbfr( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); + encod_gen_2sbfr_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); } } ELSE IF( nelp_mode ) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 639fdaffa..e5e12159f 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -466,8 +466,9 @@ void encod_gen_voic_ivas_fx( Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 shift, - Word16 Q_new ) + const Word16 shift, /* i : Shift needed to obtain 12 bits vectors */ + const Word16 Q_new /* i : Scaling factor */ +) { Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ Word16 xn2_fx[L_SUBFR]; /* Target vector for codebook search */ @@ -612,6 +613,7 @@ void encod_gen_voic_ivas_fx( Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 ); /*Q11*/ Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/ + /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); } @@ -624,8 +626,10 @@ void encod_gen_voic_ivas_fx( q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ + /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); + test(); test(); IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) @@ -908,6 +912,7 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_UNUSED, 0, i ); unbits_PI_fx -= i; } + IF( st_fx->Opt_SC_VBR ) { /* SC-VBR */ diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 70360f9d2..66ce8e4e1 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -1,17 +1,15 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ + #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -//#include "prot_fx.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ #include "rom_com.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ -/*Temporary location to be move in prot* when merge is done */ -void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ); /*=======================================================================================*/ /* FUNCTION : encod_ppp_fx() */ @@ -51,6 +49,7 @@ void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ); /*---------------------------------------------------------------------------------------*/ /* CALLED FROM : TX */ /*=======================================================================================*/ + ivas_error encod_ppp_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q_new*/ @@ -63,8 +62,9 @@ ivas_error encod_ppp_fx( Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors, /* o : voicing factors Q15*/ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ Word16 h1_fx[L_SUBFR + ( M + 1 )]; /* Impulse response vector */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 9a371b5a0..0d0d7a2d2 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -43,7 +43,7 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*---------------------------------------------------------------------------------*/ - +#ifndef CLEANUP_ACELP_ENC Word16 encod_tran_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -422,9 +422,13 @@ Word16 encod_tran_fx( return tc_subfr; } +#endif - +#ifdef CLEANUP_ACELP_ENC Word16 encod_tran_ivas_fx( +#else +Word16 encod_tran_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -485,8 +489,9 @@ Word16 encod_tran_ivas_fx( L_frame_fx = st_fx->L_frame; move16(); +#ifndef CLEANUP_ACELP_ENC set16_fx( h1, 0, L_SUBFR + ( M + 1 ) ); - +#endif /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ @@ -528,7 +533,12 @@ Word16 encod_tran_ivas_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); +#ifdef CLEANUP_ACELP_ENC + test(); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) +#else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) +#endif { shift_wsp = sub( shift_wsp, 1 ); } @@ -547,22 +557,38 @@ Word16 encod_tran_ivas_fx( Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); + Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ - q_h1 = sub( 14, norm_s( h1[0] ) ); - tmp = sub( 14, norm_arr( h1, L_SUBFR ) ); - shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ - shift_wsp = add( Q_new, shift ); - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn, L_SUBFR, shift ); + } + ELSE +#endif { - shift_wsp = sub( shift_wsp, 1 ); + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + + q_h1 = sub( 14, norm_s( h1[0] ) ); + tmp = sub( 14, norm_arr( h1, L_SUBFR ) ); + shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ + shift_wsp = add( Q_new, shift ); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } + Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ + Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); + + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn, L_SUBFR, shift ); } - Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ - Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn, L_SUBFR, shift ); /*-----------------------------------------------------------------* * TC: subframe determination & @@ -646,7 +672,14 @@ Word16 encod_tran_ivas_fx( gcode16 = round_fx_sat( Lgcode ); #ifdef CLEANUP_ACELP_ENC - hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + IF( st_fx->element_mode == EVS_MONO ) + { + hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ + } + ELSE + { + hLPDmem->tilt_code = est_tilt_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR ); // Q15 + } move16(); #else hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 @@ -657,7 +690,16 @@ Word16 encod_tran_ivas_fx( *-----------------------------------------------------------------*/ /*st->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]);*/ - L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] ); +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + L_tmp = L_mult( gcode16, y2[L_SUBFR - 1] ); /* Q10 + Q_new */ + } + ELSE +#endif + { + L_tmp = L_mult0( gcode16, y2[L_SUBFR - 1] ); + } L_tmp = L_shl( L_tmp, add( 5, shift ) ); // Q_new+14+shift L_tmp = L_negate( L_tmp ); L_tmp = L_mac( L_tmp, xn[L_SUBFR - 1], 16384 ); // Q_new-1+15+shift @@ -680,7 +722,7 @@ Word16 encod_tran_ivas_fx( { FOR( i = 0; i < L_SUBFR; i++ ) { - exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_exc */ + exc2_fx[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult_sat( gain_pit, exc_fx[i + i_subfr] ), 1 ) ); /* Q_new / Q_exc */ } } ELSE @@ -688,7 +730,7 @@ Word16 encod_tran_ivas_fx( Gain_pitX2 = shl( gain_pit, 1 ); FOR( i = 0; i < L_SUBFR; i++ ) { - exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_exc */ + exc2_fx[i + i_subfr] = mult_r( Gain_pitX2, exc_fx[i + i_subfr] ); /* Q_new / Q_exc */ } } diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 3b81f4f5d..de7f281f2 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -267,8 +267,9 @@ void encod_unvoiced_ivas_fx( Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ - const Word16 Q_new, - const Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ Word16 h1_fx[L_SUBFR]; /* Impulse response vector */ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 23a9a84fa..0498c0c33 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -14,7 +14,7 @@ * Local function prototypes *-------------------------------------------------------------------*/ -static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, Word16 Qnew ); +static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, const Word16 Qnew ); /*-------------------------------------------------------------------* @@ -39,8 +39,9 @@ void encod_audio_fx( Word16 *tmp_noise, /* o : noise energy Q2 */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0 */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6 */ - const Word16 Q_new, - const Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { const Word16 *p_Aq; Word16 i, i_subfr, nb_subfr, last_pit_bin; @@ -1527,7 +1528,7 @@ void gsc_enc_ivas_fx( static Word16 edyn_fx( const Word16 *vec, /* i : input vector Qnew*/ const Word16 lvec, /* i : length of input vector */ - Word16 Qnew ) + const Word16 Qnew ) { Word16 j = 0; Word16 dyn; diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 5bb344a4d..970e5001f 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -47,20 +47,20 @@ * Encode secondary channel of TD Stereo with a low-bitrate encoder *-------------------------------------------------------------------*/ -void tdm_low_rate_enc( - Encoder_State *st, /* i/o: State structure */ - const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ - const Word16 *res, /* i : residual signal Q_new*/ - Word16 *synth, /* i/o: core synthesis Q_new*/ - Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ - Word16 *pitch_buf, - /* i/o: floating pitch values for each subframe */ // Q6 - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ - const Word16 attack_flag, /* i : GSC attack flag Q0*/ - const Word16 *lsf_new, /* i : current frame ISF vector Qx2.56*/ - Word16 *tmp_noise, /* o : long-term noise energy Q11*/ - Word16 Q_new ) +void tdm_low_rate_enc_fx( + Encoder_State *st, /* i/o: State structure */ + const Word16 Aq[], /* i : 12k8 Lp coefficient Q12*/ + const Word16 *res, /* i : residual signal Q_new*/ + Word16 *synth, /* i/o: core synthesis Q_new*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/ + const Word16 attack_flag, /* i : GSC attack flag Q0*/ + const Word16 *lsf_new, /* i : current frame ISF vector Qx2.56*/ + Word16 *tmp_noise, /* o : long-term noise energy Q11*/ + const Word16 Q_new /* i : Scaling factor */ +) { const Word16 *p_Aq; Word16 i_subfr, nb_subfr, last_pit_bin; @@ -183,8 +183,8 @@ void tdm_low_rate_enc( * Encode GC, 2 subframes mode *-------------------------------------------------------------------*/ -void encod_gen_2sbfr( - Encoder_State *st, /* i/o: state structure */ +void encod_gen_2sbfr_fx( + Encoder_State *st, /* i/o: state structure */ const Word16 speech[], /* i : input speech Q_new-1 */ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes e(norm_s(Aw[0]+1)*/ const Word16 Aq[], /* i : LP coefficients e(norm_s(Aw[0]+1)*/ @@ -195,10 +195,11 @@ void encod_gen_2sbfr( Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ Word16 *voice_factors, /* o : voicing factors Q15 */ Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel Q4 */ - Word16 Q_new, - Word16 shift ) + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +) { Word16 xn[2 * L_SUBFR]; /* Target vector for pitch search */ Word16 xn2[2 * L_SUBFR]; /* Target vector for codebook search */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index edfb199fa..dcfb5e4c0 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2007,9 +2007,11 @@ void encod_unvoiced_fx( Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ - const Word16 Q_new, - const Word16 shift ); + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE Q_exc*/ + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +); + #ifndef CLEANUP_ACELP_ENC void encod_unvoiced_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -2047,14 +2049,15 @@ ivas_error encod_ppp_fx( const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient Q14*/ Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *synth_fx, /* o : core synthesis Q-1*/ + Word16 *synth_fx, /* o : core synthesis Q-1*/ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ - Word16 Q_new, - Word16 shift ); + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +); ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -2109,14 +2112,15 @@ void encod_gen_voic_ivas_fx( Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q0*/ Word16 *unbits_fx, /* i/o: number of unused bits Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ - Word16 shift, - Word16 Q_new ); + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ + const Word16 shift, /* i : Shift needed to obtain 12 bits vectors */ + const Word16 Q_new /* i : Scaling factor */ +); void encod_audio_fx( Encoder_State *st_fx, /* i/o: State structure */ - const Word16 speech[], /* i : i speech Q_new */ + const Word16 speech[], /* i : input speech Q_new */ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */ const Word16 Aq[], /* i : 12k8 Lp coefficient */ const Word16 *res, /* i : residual signal Q_new */ @@ -2124,14 +2128,15 @@ void encod_audio_fx( Word16 *exc, /* i/o: current non-enhanced excitation Q_new */ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */ Word16 *voice_factors, /* o : voicing factors Q15 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */ const Word16 attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC)*/ Word16 *lsf_new, /* i : current frame ISF vector */ Word16 *tmp_noise, /* o : noise energy */ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer */ - const Word16 Q_new, - const Word16 shift ); + const Word16 Q_new, /* i : Scaling factor */ + const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ +); #ifndef CLEANUP_ACELP_ENC void encod_audio_ivas_fx( -- GitLab From b29da4431722e29f0c45c75fd1a92afa07839f1e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 11:11:30 +0100 Subject: [PATCH 12/14] final editorial --- lib_com/est_tilt_fx.c | 2 +- lib_com/prot_fx.h | 16979 +++++++++++++-------------- lib_com/swb_tbe_com_fx.c | 2 +- lib_dec/acelp_core_switch_dec_fx.c | 4 - lib_dec/dec_ace_fx.c | 2 +- lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/dec_tran_fx.c | 14 +- lib_dec/gain_dec_fx.c | 6 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 19 +- lib_enc/acelp_core_switch_enc_fx.c | 3 +- lib_enc/cod_ace_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 13 +- lib_enc/enc_pit_exc_fx.c | 20 - lib_enc/enc_tran_fx.c | 18 +- lib_enc/inov_enc_fx.c | 4 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 9 +- lib_enc/transition_enc_fx.c | 17 +- 19 files changed, 8532 insertions(+), 8588 deletions(-) diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c index 71a82089a..9d92d5d77 100644 --- a/lib_com/est_tilt_fx.c +++ b/lib_com/est_tilt_fx.c @@ -122,7 +122,7 @@ Word16 est_tilt_ivas_fx( #endif const Word16 *exc, /* i : adaptive excitation vector Qx */ const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ const Word32 gain_code, /* i : algebraic code gain Q16 */ Word16 *voice_fac, /* o : voicing factor Q15 */ const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f78f12025..8f3f5eca5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2910,7 +2910,9 @@ Word16 tbe_celp_exc_offset( const Word16 L_frame /* i : frame lenght */ ); -#ifndef CLEANUP_ACELP_ENC +#ifdef CLEANUP_ACELP_ENC +void tbe_celp_exc_fx( +#else void tbe_celp_exc( const Word16 L_frame_fx, /* i : Frame lenght */ const Word16 i_subfr_fx, /* i : sub frame */ @@ -2919,10 +2921,6 @@ void tbe_celp_exc( Word16 *error_fx, /* i/o: Error */ Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */ ); -#endif -#ifdef CLEANUP_ACELP_ENC -void tbe_celp_exc( -#else void tbe_celp_exc_ivas( #endif const Word16 element_mode, /* i : element mode */ @@ -2937,2195 +2935,2163 @@ void tbe_celp_exc_ivas( const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ ); - void flip_and_downmix_generic_fx( - Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ - ); - - void Calc_rc0_h( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ - ); - - void Calc_rc0_h_ivas_enc_fx( - Word16 *h, /* i : impulse response of composed filter */ - Word16 *rc0 /* o : 1st parcor */ - ); - - void PostShortTerm_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ - ); - - void PostShortTerm_ivas_enc_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ - ); - - void PostShortTerm_ivas_dec_fx( - Word16 *sig_in, /* i : i signal (pointer to current subframe */ - Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 *mem_stp, /* i/o: postfilter memory*/ - Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ - Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ - Word16 *mem_zero, /* i/o: null memory to compute h_st*/ - const Word16 formant_fac_fx /* i : Strength of post-filter*/ - ); - - void flip_spectrum_and_decimby4_fx( - const Word16 i[], /* i : i spectrum */ - Word16 output[], /* o : output spectrum */ - const Word16 length, /* i : vector length */ - Word16 mem1[], /* i/o : memory */ - Word16 mem2[], /* i/o : memory */ - const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ - ); - - void GenShapedWBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb exctiation */ - const Word16 *lpc_shb, /* i : lpc coefficients */ - Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ - Word32 *mem_csfilt, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ - Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ - Word16 *state_lpc_syn, /* i/o : memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_bwe_exc, - Word16 bwe_seed[], /* i/o : random number generator seed */ - const Word16 voice_factors[], /* i : voicing factor */ - const Word16 signal_type, - const Word16 igf_flag ); - - void GenWBSynth_fx( - const Word16 *input_synspeech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_16k, /* o : output highband compnent */ - Word16 *state_lsyn_filt_shb1, /* i/o: memory */ - Word16 *state_lsyn_filt_shb2 /* i/o: memory */ - ); - - void GenShapedSHBExcitation_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 element_mode, /* i : element mode */ - const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi ); - - void GenShapedSHBExcitation_ivas_enc_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word16 Q_EnvSHBres_4k, - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ - ); - - void GenShapedSHBExcitation_ivas_dec_fx( - Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ - const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ - Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ - Word32 *mem_csfilt, /* i/o: memory */ - Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ - Word16 *state_lpc_syn, /* i/o: memory */ - const Word16 coder_type, /* i : coding type */ - const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ - Word16 bwe_seed[], /* i/o: random number generator seed */ - Word16 voice_factors[], /* i : voicing factor*/ - const Word16 extl, /* i : extension layer */ - Word16 *tbe_demph, /* i/o: de-emphasis memory */ - Word16 *tbe_premph, /* i/o: pre-emphasis memory */ - Word16 *lpc_shb_sf, /* i: LP coefficients */ - const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ - Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ - Word16 *shb_res, - Word16 *vf_ind, - const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ - Word16 fb_state_lpc_syn[], /* i/o: memory */ - Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ - Word16 *Q_bwe_exc, - Word16 *Q_bwe_exc_fb, - const Word16 Q_shb, - Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ - Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ - const Word32 bitrate, - const Word16 prev_bfi, /* i : previous frame was concealed */ - const Word16 element_mode, /* i : element mode */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ - Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ - const Word32 extl_brate, /* i : extension layer bitarte */ - const Word16 MSFlag, /* i : Multi Source flag */ - Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ - Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ - Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ - Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ - Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ - ); - - void GenSHBSynth_fx( - const Word16 *shb_target_speech, /* i : i synthesized speech */ - Word16 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP Frame length */ - Word16 *syn_dm_phase ); - - void GenSHBSynth_fx32( - const Word32 *input_synspeech, /* i : input synthesized speech */ - Word32 *shb_syn_speech_32k, /* o : output highband component */ - Word32 Hilbert_Mem[], /* i/o: memory */ - Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ - const Word16 L_frame, /* i : ACELP frame length */ - Word16 *syn_dm_phase ); - - void ScaleShapedSHB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o: synthesized shb signal */ - Word16 *overlap, /* i/o: buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - Word16 *Q_bwe_exc, - Word16 *Qx, - Word16 n_mem3, - Word16 prev_Q_bwe_syn2 ); - - void ScaleShapedSHB_fx32( - const Word16 length, /* i : SHB overlap length */ - Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ - Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ - const Word16 *subgain_fx, /* i : subframe gain Q15 */ - const Word32 frame_gain_fx, /* i : frame gain */ - const Word16 *win_fx, /* i : window Q15 */ - const Word16 *subwin_fx, /* i : subframes window Q15 */ - Word16 *Q_inp, - Word16 *Q_new ); - - void ScaleShapedWB_fx( - const Word16 length, /* i : SHB overlap length */ - Word16 *synSHB, /* i/o : synthesized shb signal */ - Word16 *overlap, /* i/o : buffer for overlap-add */ - const Word16 *subgain, /* i : subframe gain */ - const Word32 frame_gain, /* i : frame gain */ - const Word16 *win, /* i : window */ - const Word16 *subwin, /* i : subframes window */ - const Word16 Q_bwe_exc, - Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ - Word16 *Qx, /* o : newly computed Q factor for synSHB */ - Word16 prev_Qx, /* i : prev_Qx for memory scaling */ - Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ - ); - - void non_linearity_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - ); - - void non_linearity_ivas_fx( - const Word16 i[], /* i : i signal Q_inp */ - Word32 output[], /* o : output signal 2*Q_inp */ - const Word16 length, /* i : i length */ - Word32 *prev_scale, /* i/o: memory Q30 */ - Word16 Q_inp, - Word16 coder_type, /* i : Coder Type */ - Word16 *voice_factors, /* i : Voice Factors */ - const Word16 L_frame /* i : ACELP frame length */ - ); - - void interp_code_5over2_fx( - const Word16 inp_code[], /* i : i vector */ - Word16 interp_code[], /* o : output vector */ - const Word16 inp_length /* i : length of i vector */ - ); - - void interp_code_4over2_fx( - const Word16 inp_code_fx[], /* i : i vector Qx */ - Word16 interp_code_fx[], /* o : output vector Qx */ - const Word16 inp_length /* i : length of i vector */ - ); - - void wb_tbe_extras_reset_synth_fx( - Word16 state_lsyn_filt_shb[], - Word16 state_lsyn_filt_dwn_shb[], - Word16 state_32and48k_WB_upsample[], - Word16 state_resamp_HB[] ); - - void elliptic_bpf_48k_generic_fx( - const Word16 element_mode, - Word16 IsUpsampled3, - Word16 input_fx[], /* i : input signal Q_input_fx*/ - Word16 *Q_input_fx, - Word16 output_fx[], /* o : output signal */ - Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ - Word16 memory_fx_Q[], - const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ - ); - - void synthesise_fb_high_band_fx( - const Word16 excitation_in[], /* i : full band excitation */ - Word16 Q_fb_exc, - Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ - const Word32 fb_exc_energy, /* i : full band excitation energy */ - const Word16 ratio, /* i : energy ratio */ - const Word16 L_frame, /* i : ACELP frame length */ - const Word16 bfi, /* i : fec flag */ - Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ - Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ - Word16 bpf_memory_Q[], - Word16 Qout, - Word16 element_mode ); - - void prep_tbe_exc_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - const Word16 T0, /* i : integer pitch variables Q0 */ - const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ - ); - - /*! r: Formant filter strength [0,1] */ - Word16 swb_formant_fac_fx( - const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ - Word16 *tilt_mem /* i/o: Tilt smoothing memory */ - ); - - void wb_tbe_extras_reset_fx( - Word16 mem_genSHBexc_filt_down_wb2[], - Word16 mem_genSHBexc_filt_down_wb3[] ); - - Word16 get_tbe_bits_fx( - const Word32 total_brate, /* o : TBE bit consumption per frame */ - const Word16 bwidth, /* i : overall bitrate */ - const Word16 rf_mode /* i : bandwidht mode */ - ); - - UWord32 intLimCDivPos_fx( - UWord32 NUM, /* Qx */ - Word16 DEN /* Q0 */ - ); - - Word16 shrtCDivSignedApprox( - const Word16 num, /* Q0 */ - const Word16 den /* Q0 */ - ); - - void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy Q0*/ - const Word16 R, /* i : right vector energy Q0*/ - Word16 *Density /* o : quantizer density Q0*/ - ); - - void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, /* Q0 */ - Word16 *diracs /* Q0 */ - ); - - void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ - const Word16 dsm, /* i : Conservative rounding flag Q0*/ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index Q0*/ - ); - - void QuantaPerDsDirac_fx( - const Word16 td, /* i : Length of vector segment Q0*/ - const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ - const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ - Word16 *Quanta /* i : Quanta Q0*/ - ); - - void conservativeL1Norm_fx( - const Word16 L, /* i : Length of vector segment Q0*/ - const Word16 Qvec, /* i : Assigned number of quanta Q0*/ - const Word16 Fcons, /* i : Conservative rounding flag Q0*/ - const Word16 Qavail, /* i : Input quanta remaining Q0*/ - const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ - const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ - Word16 *Dvec, /* o : actual number of diracs Q0*/ - Word16 *Qspare, /* o : Output quanta remaining Q0*/ - Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ - Word16 *Dspecplus /* o : Output number of diracs Q0*/ - ); - - void bandBitsAdjustment_fx( - const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ - const UWord32 INTrc, /* i : Range coder state Q0*/ - const Word16 Bavail, /* i : Available number of quanta Q3*/ - const Word16 Nbands, /* i : Number of bands Q0*/ - const Word16 D, /* i : Remaining number of bands to encode Q0*/ - const Word16 L, /* i : Size of current band Q0*/ - const Word16 Bband, /* i : Quanta allocation for current band Q0*/ - const Word16 Breserv, /* i : Quanta reservoir Q0*/ - Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ - Word16 *Brem, /* o : Quanta remaining Q0*/ - Word16 *Breservplus /* o : Quanta pool size Q0*/ - ); - - void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density Q0*/ - const Word16 indexphi, /* i : decoded index from AR dec Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ - ); - - void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density Q0*/ - const Word16 phiQ14uq, /* i : angle Q14*/ - Word16 *indexphi, /* o : index Q0*/ - Word16 *oppQ15, /* o : opposite Q15*/ - Word16 *nearQ15, /* o : near Q15*/ - Word16 *oppRatioQ3 /* o : ratio Q3*/ - ); - - void NearOppSplitAdjustment_fx( - const Word16 qband, /* i : quanta for current band Q0*/ - const Word16 qzero, /* i : range coder finalization quanta Q0*/ - const Word16 Qac, /* i : range coder current quanta Q0*/ - const UWord32 INTac, /* i : range coder state Q0*/ - const Word16 qglobal, /* i : quanta input Q0*/ - const Word16 FlagCons, /* i : conservative rounding flag Q0*/ - const Word16 Np, /* i : number of parts Q0*/ - const Word16 Nhead, /* i : first part Q0*/ - const Word16 Ntail, /* i : remaining parts Q0*/ - const Word16 Nnear, /* i : length of near component Q0*/ - const Word16 Nopp, /* i : length of opposite component Q0*/ - Word16 oppRQ3, /* i : ratio Q0*/ - Word16 *qnear, /* o : quantized near Q0*/ - Word16 *qopp, /* o : quantized opposite Q0*/ - Word16 *qglobalupd /* o : quanta remaining Q0*/ - ); - - void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 *band_start, /* i : Sub band start indices Q0 */ - const Word16 *band_end, /* i : Sub band end indices Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gains, /* i : Band gain vector Q12 */ - Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ - ); - - void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ - ); - - void srt_vec_ind16_fx( - const Word16 *linear, /* linear input Q3*/ - Word16 *srt, /* sorted output Q3*/ - Word16 *I, /* index for sorted output Q0*/ - Word16 length /* Q0 */ - ); - - /* o: Angle between 0 and PI/2 radian (Q14) */ - Word16 atan2_fx( - const Word32 y, /* i : near side (Argument must be positive) (Q15) */ - const Word32 x /* i : opposite side (Q15) */ - ); - - /* o: Number of bits needed Q0*/ - Word16 rc_get_bits2_fx( - const Word16 N, /* i: Number of bits currently used Q0*/ - const UWord32 range /* i: Range of range coder Q0*/ - ); - - void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits Q0*/ - UWord32 INTrc, /* i : Range coder state Q0*/ - Word16 *FBits /* i : Fractional finalization bits Q0*/ - ); - - ivas_error DTFS_new_fx( - DTFS_STRUCTURE **dtfs_out ); - - void DTFS_copy_fx( - DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ - DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ - ); - - void DTFS_sub_fx( - DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ - DTFS_STRUCTURE X1, /* i: DTFS i 1 */ - DTFS_STRUCTURE X2 /* i: DTFS i 2 */ - ); - - Word16 DTFS_alignment_full_fx( - DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ - DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ - Word16 ph_offset_fx, /* i : resolution */ - Word16 *S_fx, - Word16 *C_fx, - Word16 FR_flag ); - - void DTFS_phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - - void Q2phaseShift_fx( - DTFS_STRUCTURE *X_fx, - Word16 ph, - Word16 Lag, - Word16 *S_fx, - Word16 *C_fx ); - - void DTFS_zeroPadd_fx( - Word16 N_fx, - DTFS_STRUCTURE *X_fx ); - - void DTFS_to_fs_fx( - const Word16 *x, /* i : time domain signal */ - Word16 N, /* i : Length of i vector */ - DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ - const Word16 Fs, /* i : sampling rate */ - const Word16 FR_flag, /* i : FR flag */ - Word16 *S_fx, - Word16 *C_fx ); - - void DTFS_zeroFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - - void DTFS_poleFilter_fx_9( - DTFS_STRUCTURE *X_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - - void DTFS_adjustLag_fx( - DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ - Word16 N_fx /* i : Target lag */ - ); - - Word32 DTFS_getEngy_fx( - DTFS_STRUCTURE *X_fx ); - - Word32 DTFS_getEngy_P2A_fx( - DTFS_STRUCTURE *X_fx ); - - void DTFS_car2pol_fx( - DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ - ); - - Word32 DTFS_setEngyHarm_fx( - Word16 f1_fx, /* i : lower band freq of i to control energy */ - Word16 f2_fx, /* i : upper band freq of i to control energy */ - Word16 g1_fx, /* i : lower band freq of output to control energy */ - Word16 g2_fx, /* i : upper band freq of output to control energy */ - Word32 en2_fx, /* i : Target Energy to set the DTFS to */ - Word16 Qen2_fx, /* i : Input Q format for en2 */ - Word16 *Qa_fx, /* i : Output Q format for x->a */ - DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ - ); - - void DTFS_to_erb_fx( - const DTFS_STRUCTURE X_fx, /* i : DTFS i */ - Word16 *out_fx /* o : ERB output */ - ); - - void erb_slot_fx( - Word16 lag_fx, /* i : i lag */ - Word16 *out_fx, /* o : ERB slots */ - Word16 *mfreq_fx, /* i : ERB frequencies */ - Word16 num_erb_fx /* i : number of ERBs */ - ); - - void DTFS_erb_inv_fx( - Word16 *in_fx, /* i : ERB inpt */ - Word16 *slot_fx, /* i : ERB slots filled based on lag */ - Word16 *mfreq_fx, /* i : erb frequence edges */ - DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ - Word16 num_erb_fx /* i : Number of ERB bands */ - ); - - void erb_add_fx( - Word16 *curr_erb_fx, /* i/o: current ERB */ - Word16 l_fx, /* i : current lag */ - const Word16 *prev_erb_fx, /* i : previous ERB */ - Word16 pl_fx, /* i : previous lag */ - const Word16 *index_fx, /* i : ERB index */ - Word16 num_erb_fx /* i : number of ERBs */ - ); - - void quant_target_fx( - DTFS_STRUCTURE *X_fx, - const Word16 *curr_lpc, - Word16 *w, - Word16 *target, - Word16 *sin_tab, - Word16 *cos_tab ); - - ivas_error WIsyn_fx( - DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ - DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ - const Word16 *curr_lpc_fx, /* i : LPC */ - Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ - Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ - const Word16 N, /* i : Number of output samples to generate */ - const Word16 FR_flag, /* i : called for post-smoothing in FR */ - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2 ); - - Word16 ppp_extract_pitch_period_fx( - const Word16 *in, /* i : i residual */ - Word16 *out, /* o : output residual */ - Word16 l, /* i : lag */ - Word16 *out_of_bound, /* o : out of bound flag */ - Word16 Qres ); - - void DTFS_peaktoaverage_fx( - DTFS_STRUCTURE X_fx, /* i : DTFS */ - Word32 *pos_fx, /* o : positive peak to ave */ - Word16 *Qpos, /* o : positive peak to ave Q format */ - Word32 *neg_fx, /* o : negative peak to ave */ - Word16 *Qneg /* o : negative peak to ave Q format */ - ); - - void rshiftHarmBand_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband_fx, - Word16 hband_fx, - Word16 shift_fx ); - - void GetSinCosTab_fx( - Word16 L, - Word16 *sinTab, - Word16 *cosTab ); - - void r_fft_4_fx( - Word16 *farray_ptr_fx, - Word16 size, - Word16 stage, - Word16 isign ); - - void copy_phase_fx( - DTFS_STRUCTURE *X1_fx, - DTFS_STRUCTURE X2_fx, - DTFS_STRUCTURE *retX_fx ); - - Word32 getSpEngyFromResAmp_fx( - DTFS_STRUCTURE *X_fx, - Word16 lband, - Word16 hband, - const Word16 *curr_lpc, - Word16 *sin_tab, - Word16 *cos_tab ); - - void DTFS_poleFilter_fx( - DTFS_STRUCTURE *X_fx, - Word16 *LPC, - Word16 N, - Word16 *S_fx, - Word16 *C_fx ); - - void poleFilter_setup_fx( - const Word16 *LPC, - Word16 N, - DTFS_STRUCTURE X_fx, - Word16 *S_fx, - Word16 *C_fx, - Word16 *pf_temp1, - Word16 *pf_temp2, - Word16 *pf_temp, - Word16 *pf_n2_temp1 ); - - Word32 DTFS_getEngy_band_wb_fx( - DTFS_STRUCTURE X_fx, - Word16 lband, - Word16 hband ); - - void InitTnsConfiguration( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void InitTnsConfiguration_ivas_fx( - const Word16 bwidth, - const Word16 frameLength, - STnsConfig *pTnsConfig, - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void ApplyTnsFilter( - STnsConfig const *pTnsConfig, - STnsData const *pTnsData, - Word32 spectrum[], - const Word8 fIsAnalysis ); - - Word16 ITF_Detect_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); - - Word16 ITF_Detect_ivas_fx( - Word32 const pSpectrum[], - const Word16 startLine, - const Word16 stopLine, - const Word16 maxOrder, - Word16 *A, - Word16 *Q_A, - Word16 *predictionGain, - Word16 *curr_order, - Word16 Q ); +void flip_and_downmix_generic_fx( + Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory */ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ +); + +void Calc_rc0_h( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ +); + +void Calc_rc0_h_ivas_enc_fx( + Word16 *h, /* i : impulse response of composed filter */ + Word16 *rc0 /* o : 1st parcor */ +); + +void PostShortTerm_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ +); + +void PostShortTerm_ivas_enc_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ +); + +void PostShortTerm_ivas_dec_fx( + Word16 *sig_in, /* i : i signal (pointer to current subframe */ + Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 *mem_stp, /* i/o: postfilter memory*/ + Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/ + Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/ + Word16 *mem_zero, /* i/o: null memory to compute h_st*/ + const Word16 formant_fac_fx /* i : Strength of post-filter*/ +); + +void flip_spectrum_and_decimby4_fx( + const Word16 i[], /* i : i spectrum */ + Word16 output[], /* o : output spectrum */ + const Word16 length, /* i : vector length */ + Word16 mem1[], /* i/o : memory */ + Word16 mem2[], /* i/o : memory */ + const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */ +); + +void GenShapedWBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb exctiation */ + const Word16 *lpc_shb, /* i : lpc coefficients */ + Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */ + Word32 *mem_csfilt, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */ + Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */ + Word16 *state_lpc_syn, /* i/o : memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_bwe_exc, + Word16 bwe_seed[], /* i/o : random number generator seed */ + const Word16 voice_factors[], /* i : voicing factor */ + const Word16 signal_type, + const Word16 igf_flag ); + +void GenWBSynth_fx( + const Word16 *input_synspeech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_16k, /* o : output highband compnent */ + Word16 *state_lsyn_filt_shb1, /* i/o: memory */ + Word16 *state_lsyn_filt_shb2 /* i/o: memory */ +); + +void GenShapedSHBExcitation_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 element_mode, /* i : element mode */ + const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: i shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: i res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi ); + +void GenShapedSHBExcitation_ivas_enc_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc_fb */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *nlExc16k_e, /* i/o: exp of nlExc16k */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + Word16 *mixExc16k_e, /* i/o: exp of mixExc16k_fx */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word16 Q_EnvSHBres_4k, + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ +); + +void GenShapedSHBExcitation_ivas_dec_fx( + Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/ + const Word16 *lpc_shb, /* i : lpc coefficients Q12*/ + Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */ + Word32 *mem_csfilt, /* i/o: memory */ + Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */ + Word16 *state_lpc_syn, /* i/o: memory */ + const Word16 coder_type, /* i : coding type */ + const Word16 *bwe_exc_extended, /* i : bwidth extended excitation */ + Word16 bwe_seed[], /* i/o: random number generator seed */ + Word16 voice_factors[], /* i : voicing factor*/ + const Word16 extl, /* i : extension layer */ + Word16 *tbe_demph, /* i/o: de-emphasis memory */ + Word16 *tbe_premph, /* i/o: pre-emphasis memory */ + Word16 *lpc_shb_sf, /* i: LP coefficients */ + const Word32 shb_ener_sf_32, /* i: input shb ener, Q31 */ + Word16 *shb_res_gshape, /* i: input res gain shape, Q14 */ + Word16 *shb_res, + Word16 *vf_ind, + const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */ + Word16 fb_state_lpc_syn[], /* i/o: memory */ + Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */ + Word16 *Q_bwe_exc, + Word16 *Q_bwe_exc_fb, + const Word16 Q_shb, + Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */ + Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */ + const Word32 bitrate, + const Word16 prev_bfi, /* i : previous frame was concealed */ + const Word16 element_mode, /* i : element mode */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + Word16 *nlExc16k, /* i/o: NL exc for IC-BWE */ + Word16 *mixExc16k, /* i/o: exc spreading for IC-BWE */ + const Word32 extl_brate, /* i : extension layer bitarte */ + const Word16 MSFlag, /* i : Multi Source flag */ + Word16 EnvSHBres_4k[], /* i/o: TD envelope of the SHB residual signal */ + Word32 *prev_pow_exc16kWhtnd, /* i/o: power of the LB excitation signal in the previous frame */ + Word16 *prev_mix_factor, /* i/o: mixing factor in the previous frame */ + Word16 *Env_error, /* o : error in SHB residual envelope modelling*/ + Word16 Env_error_part[] /* o : per-segment error in SHB residual envelope modelling */ +); + +void GenSHBSynth_fx( + const Word16 *shb_target_speech, /* i : i synthesized speech */ + Word16 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word16 genSHBsynth_allpass_mem[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP Frame length */ + Word16 *syn_dm_phase ); + +void GenSHBSynth_fx32( + const Word32 *input_synspeech, /* i : input synthesized speech */ + Word32 *shb_syn_speech_32k, /* o : output highband component */ + Word32 Hilbert_Mem[], /* i/o: memory */ + Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ + const Word16 L_frame, /* i : ACELP frame length */ + Word16 *syn_dm_phase ); + +void ScaleShapedSHB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o: synthesized shb signal */ + Word16 *overlap, /* i/o: buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + Word16 *Q_bwe_exc, + Word16 *Qx, + Word16 n_mem3, + Word16 prev_Q_bwe_syn2 ); + +void ScaleShapedSHB_fx32( + const Word16 length, /* i : SHB overlap length */ + Word32 *synSHB_fx, /* i/o: synthesized shb signal Qx */ + Word32 *overlap_fx, /* i/o: buffer for overlap-add Qx */ + const Word16 *subgain_fx, /* i : subframe gain Q15 */ + const Word32 frame_gain_fx, /* i : frame gain */ + const Word16 *win_fx, /* i : window Q15 */ + const Word16 *subwin_fx, /* i : subframes window Q15 */ + Word16 *Q_inp, + Word16 *Q_new ); + +void ScaleShapedWB_fx( + const Word16 length, /* i : SHB overlap length */ + Word16 *synSHB, /* i/o : synthesized shb signal */ + Word16 *overlap, /* i/o : buffer for overlap-add */ + const Word16 *subgain, /* i : subframe gain */ + const Word32 frame_gain, /* i : frame gain */ + const Word16 *win, /* i : window */ + const Word16 *subwin, /* i : subframes window */ + const Word16 Q_bwe_exc, + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ + Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ +); + +void non_linearity_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ +); + +void non_linearity_ivas_fx( + const Word16 i[], /* i : i signal Q_inp */ + Word32 output[], /* o : output signal 2*Q_inp */ + const Word16 length, /* i : i length */ + Word32 *prev_scale, /* i/o: memory Q30 */ + Word16 Q_inp, + Word16 coder_type, /* i : Coder Type */ + Word16 *voice_factors, /* i : Voice Factors */ + const Word16 L_frame /* i : ACELP frame length */ +); + +void interp_code_5over2_fx( + const Word16 inp_code[], /* i : i vector */ + Word16 interp_code[], /* o : output vector */ + const Word16 inp_length /* i : length of i vector */ +); + +void interp_code_4over2_fx( + const Word16 inp_code_fx[], /* i : i vector Qx */ + Word16 interp_code_fx[], /* o : output vector Qx */ + const Word16 inp_length /* i : length of i vector */ +); + +void wb_tbe_extras_reset_synth_fx( + Word16 state_lsyn_filt_shb[], + Word16 state_lsyn_filt_dwn_shb[], + Word16 state_32and48k_WB_upsample[], + Word16 state_resamp_HB[] ); + +void elliptic_bpf_48k_generic_fx( + const Word16 element_mode, + Word16 IsUpsampled3, + Word16 input_fx[], /* i : input signal Q_input_fx*/ + Word16 *Q_input_fx, + Word16 output_fx[], /* o : output signal */ + Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ + Word16 memory_fx_Q[], + const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ +); + +void synthesise_fb_high_band_fx( + const Word16 excitation_in[], /* i : full band excitation */ + Word16 Q_fb_exc, + Word16 output[], /* o : high band speech - 14.0 to 20 kHz */ + const Word32 fb_exc_energy, /* i : full band excitation energy */ + const Word16 ratio, /* i : energy ratio */ + const Word16 L_frame, /* i : ACELP frame length */ + const Word16 bfi, /* i : fec flag */ + Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ + Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ + Word16 bpf_memory_Q[], + Word16 Qout, + Word16 element_mode ); + +void prep_tbe_exc_fx( + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : subframe index */ + const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ + const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 voice_fac_fx, /* i : voicing factor Q15*/ + Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ + Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ + const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ + const Word16 code_preQ_fx[], /* i : prequantizer excitation */ + const Word16 Q_code_preQ, /* i : Q, prequantizer excitation */ + const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ + const Word16 T0, /* i : integer pitch variables Q0 */ + const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ + const Word16 coder_type, /* i : coding type */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ +); + +/*! r: Formant filter strength [0,1] */ +Word16 swb_formant_fac_fx( + const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ + Word16 *tilt_mem /* i/o: Tilt smoothing memory */ +); + +void wb_tbe_extras_reset_fx( + Word16 mem_genSHBexc_filt_down_wb2[], + Word16 mem_genSHBexc_filt_down_wb3[] ); + +Word16 get_tbe_bits_fx( + const Word32 total_brate, /* o : TBE bit consumption per frame */ + const Word16 bwidth, /* i : overall bitrate */ + const Word16 rf_mode /* i : bandwidht mode */ +); + +UWord32 intLimCDivPos_fx( + UWord32 NUM, /* Qx */ + Word16 DEN /* Q0 */ +); + +Word16 shrtCDivSignedApprox( + const Word16 num, /* Q0 */ + const Word16 den /* Q0 */ +); + +void obtainEnergyQuantizerDensity_fx( + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ +); + +void dsDirac2Dirac_fx( + const Word16 dsDiracIndex, /* Q0 */ + Word16 *diracs /* Q0 */ +); + +void dsDiracPerQuanta_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ +); + +void QuantaPerDsDirac_fx( + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ + const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ + Word16 *Quanta /* i : Quanta Q0*/ +); + +void conservativeL1Norm_fx( + const Word16 L, /* i : Length of vector segment Q0*/ + const Word16 Qvec, /* i : Assigned number of quanta Q0*/ + const Word16 Fcons, /* i : Conservative rounding flag Q0*/ + const Word16 Qavail, /* i : Input quanta remaining Q0*/ + const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ + const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ + Word16 *Dvec, /* o : actual number of diracs Q0*/ + Word16 *Qspare, /* o : Output quanta remaining Q0*/ + Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ + Word16 *Dspecplus /* o : Output number of diracs Q0*/ +); + +void bandBitsAdjustment_fx( + const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ + const UWord32 INTrc, /* i : Range coder state Q0*/ + const Word16 Bavail, /* i : Available number of quanta Q3*/ + const Word16 Nbands, /* i : Number of bands Q0*/ + const Word16 D, /* i : Remaining number of bands to encode Q0*/ + const Word16 L, /* i : Size of current band Q0*/ + const Word16 Bband, /* i : Quanta allocation for current band Q0*/ + const Word16 Breserv, /* i : Quanta reservoir Q0*/ + Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ + Word16 *Brem, /* o : Quanta remaining Q0*/ + Word16 *Breservplus /* o : Quanta pool size Q0*/ +); + +void densityAngle2RmsProjDec_fx( + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ +); + +void densityAngle2RmsProjEnc_fx( + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ +); + +void NearOppSplitAdjustment_fx( + const Word16 qband, /* i : quanta for current band Q0*/ + const Word16 qzero, /* i : range coder finalization quanta Q0*/ + const Word16 Qac, /* i : range coder current quanta Q0*/ + const UWord32 INTac, /* i : range coder state Q0*/ + const Word16 qglobal, /* i : quanta input Q0*/ + const Word16 FlagCons, /* i : conservative rounding flag Q0*/ + const Word16 Np, /* i : number of parts Q0*/ + const Word16 Nhead, /* i : first part Q0*/ + const Word16 Ntail, /* i : remaining parts Q0*/ + const Word16 Nnear, /* i : length of near component Q0*/ + const Word16 Nopp, /* i : length of opposite component Q0*/ + Word16 oppRQ3, /* i : ratio Q0*/ + Word16 *qnear, /* o : quantized near Q0*/ + Word16 *qopp, /* o : quantized opposite Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ +); + +void apply_gain_fx( + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 *band_start, /* i : Sub band start indices Q0 */ + const Word16 *band_end, /* i : Sub band end indices Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gains, /* i : Band gain vector Q12 */ + Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */ +); + +void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ +); + +void srt_vec_ind16_fx( + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ + Word16 length /* Q0 */ +); + +/* o: Angle between 0 and PI/2 radian (Q14) */ +Word16 atan2_fx( + const Word32 y, /* i : near side (Argument must be positive) (Q15) */ + const Word32 x /* i : opposite side (Q15) */ +); + +/* o: Number of bits needed Q0*/ +Word16 rc_get_bits2_fx( + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ +); + +void rangeCoderFinalizationFBits_fx( + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ +); + +ivas_error DTFS_new_fx( + DTFS_STRUCTURE **dtfs_out ); + +void DTFS_copy_fx( + DTFS_STRUCTURE *Xout_fx, /* o: DTFS structure */ + DTFS_STRUCTURE Xinp_fx /* i: DTFS structure */ +); + +void DTFS_sub_fx( + DTFS_STRUCTURE *tmp, /* o: X1 - X2 */ + DTFS_STRUCTURE X1, /* i: DTFS i 1 */ + DTFS_STRUCTURE X2 /* i: DTFS i 2 */ +); + +Word16 DTFS_alignment_full_fx( + DTFS_STRUCTURE X1_DTFS_fx, /* i : reference DTFS */ + DTFS_STRUCTURE X2_DTFS_fx, /* i : DTFS to shift */ + Word16 ph_offset_fx, /* i : resolution */ + Word16 *S_fx, + Word16 *C_fx, + Word16 FR_flag ); + +void DTFS_phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + +void Q2phaseShift_fx( + DTFS_STRUCTURE *X_fx, + Word16 ph, + Word16 Lag, + Word16 *S_fx, + Word16 *C_fx ); + +void DTFS_zeroPadd_fx( + Word16 N_fx, + DTFS_STRUCTURE *X_fx ); + +void DTFS_to_fs_fx( + const Word16 *x, /* i : time domain signal */ + Word16 N, /* i : Length of i vector */ + DTFS_STRUCTURE *X_fx, /* o : DTFS structure with a, b, lag */ + const Word16 Fs, /* i : sampling rate */ + const Word16 FR_flag, /* i : FR flag */ + Word16 *S_fx, + Word16 *C_fx ); + +void DTFS_zeroFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + +void DTFS_poleFilter_fx_9( + DTFS_STRUCTURE *X_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + +void DTFS_adjustLag_fx( + DTFS_STRUCTURE *X_DTFS_FX, /* i/o : DTFS to adjust lag for */ + Word16 N_fx /* i : Target lag */ +); + +Word32 DTFS_getEngy_fx( + DTFS_STRUCTURE *X_fx ); + +Word32 DTFS_getEngy_P2A_fx( + DTFS_STRUCTURE *X_fx ); + +void DTFS_car2pol_fx( + DTFS_STRUCTURE *X_fx /* i/o : DTFS structure a, b, lag */ +); + +Word32 DTFS_setEngyHarm_fx( + Word16 f1_fx, /* i : lower band freq of i to control energy */ + Word16 f2_fx, /* i : upper band freq of i to control energy */ + Word16 g1_fx, /* i : lower band freq of output to control energy */ + Word16 g2_fx, /* i : upper band freq of output to control energy */ + Word32 en2_fx, /* i : Target Energy to set the DTFS to */ + Word16 Qen2_fx, /* i : Input Q format for en2 */ + Word16 *Qa_fx, /* i : Output Q format for x->a */ + DTFS_STRUCTURE *X_fx /* i/o: DTFS to adjust the energy of */ +); + +void DTFS_to_erb_fx( + const DTFS_STRUCTURE X_fx, /* i : DTFS i */ + Word16 *out_fx /* o : ERB output */ +); + +void erb_slot_fx( + Word16 lag_fx, /* i : i lag */ + Word16 *out_fx, /* o : ERB slots */ + Word16 *mfreq_fx, /* i : ERB frequencies */ + Word16 num_erb_fx /* i : number of ERBs */ +); + +void DTFS_erb_inv_fx( + Word16 *in_fx, /* i : ERB inpt */ + Word16 *slot_fx, /* i : ERB slots filled based on lag */ + Word16 *mfreq_fx, /* i : erb frequence edges */ + DTFS_STRUCTURE *X_fx, /* o : DTFS after erb-inv */ + Word16 num_erb_fx /* i : Number of ERB bands */ +); + +void erb_add_fx( + Word16 *curr_erb_fx, /* i/o: current ERB */ + Word16 l_fx, /* i : current lag */ + const Word16 *prev_erb_fx, /* i : previous ERB */ + Word16 pl_fx, /* i : previous lag */ + const Word16 *index_fx, /* i : ERB index */ + Word16 num_erb_fx /* i : number of ERBs */ +); + +void quant_target_fx( + DTFS_STRUCTURE *X_fx, + const Word16 *curr_lpc, + Word16 *w, + Word16 *target, + Word16 *sin_tab, + Word16 *cos_tab ); + +ivas_error WIsyn_fx( + DTFS_STRUCTURE PREVCW_FX, /* i : Prev frame DTFS */ + DTFS_STRUCTURE *CURR_CW_DTFS_FX, /* i/o: Curr frame DTFS */ + const Word16 *curr_lpc_fx, /* i : LPC */ + Word16 *ph_offset_fx, /* i/o: Phase offset to line up at end of frame */ + Word16 *out_fx, /* o : Waveform Interpolated time domain signal */ + const Word16 N, /* i : Number of output samples to generate */ + const Word16 FR_flag, /* i : called for post-smoothing in FR */ + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2 ); + +Word16 ppp_extract_pitch_period_fx( + const Word16 *in, /* i : i residual */ + Word16 *out, /* o : output residual */ + Word16 l, /* i : lag */ + Word16 *out_of_bound, /* o : out of bound flag */ + Word16 Qres ); + +void DTFS_peaktoaverage_fx( + DTFS_STRUCTURE X_fx, /* i : DTFS */ + Word32 *pos_fx, /* o : positive peak to ave */ + Word16 *Qpos, /* o : positive peak to ave Q format */ + Word32 *neg_fx, /* o : negative peak to ave */ + Word16 *Qneg /* o : negative peak to ave Q format */ +); + +void rshiftHarmBand_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband_fx, + Word16 hband_fx, + Word16 shift_fx ); + +void GetSinCosTab_fx( + Word16 L, + Word16 *sinTab, + Word16 *cosTab ); + +void r_fft_4_fx( + Word16 *farray_ptr_fx, + Word16 size, + Word16 stage, + Word16 isign ); + +void copy_phase_fx( + DTFS_STRUCTURE *X1_fx, + DTFS_STRUCTURE X2_fx, + DTFS_STRUCTURE *retX_fx ); + +Word32 getSpEngyFromResAmp_fx( + DTFS_STRUCTURE *X_fx, + Word16 lband, + Word16 hband, + const Word16 *curr_lpc, + Word16 *sin_tab, + Word16 *cos_tab ); + +void DTFS_poleFilter_fx( + DTFS_STRUCTURE *X_fx, + Word16 *LPC, + Word16 N, + Word16 *S_fx, + Word16 *C_fx ); + +void poleFilter_setup_fx( + const Word16 *LPC, + Word16 N, + DTFS_STRUCTURE X_fx, + Word16 *S_fx, + Word16 *C_fx, + Word16 *pf_temp1, + Word16 *pf_temp2, + Word16 *pf_temp, + Word16 *pf_n2_temp1 ); + +Word32 DTFS_getEngy_band_wb_fx( + DTFS_STRUCTURE X_fx, + Word16 lband, + Word16 hband ); + +void InitTnsConfiguration( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void InitTnsConfiguration_ivas_fx( + const Word16 bwidth, + const Word16 frameLength, + STnsConfig *pTnsConfig, + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void ApplyTnsFilter( + STnsConfig const *pTnsConfig, + STnsData const *pTnsData, + Word32 spectrum[], + const Word8 fIsAnalysis ); + +Word16 ITF_Detect_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + +Word16 ITF_Detect_ivas_fx( + Word32 const pSpectrum[], + const Word16 startLine, + const Word16 stopLine, + const Word16 maxOrder, + Word16 *A, + Word16 *Q_A, + Word16 *predictionGain, + Word16 *curr_order, + Word16 Q ); + +void ITF_Apply_fx( + Word32 spectrum[], + Word16 startLine, + Word16 stopLine, + const Word16 *A, + Word16 Q_A, + Word16 curr_order ); + +void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); + +Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + +Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + +Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); + +Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); + +Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); + +Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); + +Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); + +void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); + +Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); + +Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); + +Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); + +Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); + +Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); + +Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); + +Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); + +void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); + +void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); + +void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); + +void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); + +void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); + +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); + +void ResetTnsData( STnsData *pTnsData ); + +void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); + +/*========================================================================================================/ +gp_clips_fx.c +/========================================================================================================*/ + +void init_gp_clip_fx( + Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ +); + +Word16 gp_clip_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ + const Word16 i_subfr, /* i : subframe index Q0*/ + const Word16 coder_type, /* i : type of coder Q0*/ + const Word16 xn[], /* i : target vector Q_new*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Q_new /* i : scaling factor */ +); + +void gp_clip_test_isf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ +); + +void gp_clip_test_gain_pit_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ + Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ +); + +Word16 Mode2_gp_clip_fx( + const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 coder_type, /* i : type of coder Q0 */ + const Word16 xn[], /* i : target vector Q_xn */ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ + /* mem[0]: Q0 */ + /* mem[1]: 1Q14 */ + /* mem[2]: 8Q7 */ + /* mem[3]: Q0 (integer) */ + /* mem[4]: Q14 */ + /* mem[5]: Q14 */ + const Word16 L_subfr, /* Q0 */ + const Word16 Q_xn /* i : scaling factor of vector xn[] */ +); + +void gp_clip_test_lsf_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 m /* i : dimension of lsf Q0*/ +); + +void gp_clip_test_lsf_ivas_fx( + const Word16 element_mode, /* i : element mode Q0*/ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ + Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ +); + +/*========================================================================================================/ +nelp_enc_fx.c +/========================================================================================================*/ + +void quantize_uvg_fx( + Word16 *G, + Word16 *iG1, + Word16 *iG2, + Word16 *quantG, + Word16 bandwidth ); + +void nelp_encoder_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + +void nelp_encoder_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state */ + Word16 *in_fx, /* i : residual signal */ + Word16 *exc_fx, /* o : NELP quantized excitation signal */ + Word16 *qIn1, + Word16 reduce_gains ); + +void swb_bwe_enc_lr_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ +); + +void swb_bwe_enc_lr_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis */ + Word16 QsL, + const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ + Word16 *band_start_fx, /* i : band start of each SB */ + Word16 *band_end_fx, /* i : band end of each SB */ + Word32 *L_band_energy, /* i : band_energy of each SB */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal indicator */ + const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ + Word16 lowlength_fx, /* i : lowband length */ + Word16 highlength_fx, /* i : highband length */ + Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ + Word16 *prev_frm_hfe2, /* i/o: */ + Word16 *prev_stab_hfe2, /* i/o: */ + const Word16 band_width_fx[], /* i : band_width information */ + const Word32 L_y2_ni[], /* i : band_width information */ + Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ +); + +void isf_enc_amr_wb_fx( + Encoder_State *st, /* i/o: state structure */ + Word16 *isf_new, /* i/o: quantized ISF vector */ + Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ + Word16 *Aq /* o : quantized A(z) for 4 subframes */ +); + +Word16 detect_transient_fx( + const Word16 *in_fx, /*Q_new */ + const Word16 L, /*Q0*/ + Word16 Q_new, + Encoder_State *st_fx ); + +Word16 tcxGetNoiseFillingTilt( + const Word16 A[], + const Word16 lpcorder, + const Word16 L_frame, + const Word16 mode, + Word16 *noiseTiltFactor ); + +void tcxFormantEnhancement( + Word16 xn_buf[], + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + +void tcxFormantEnhancement_with_shift( + Word16 xn_buf[], + Word16 *xn_buf_e, + const Word16 gainlpc[], + const Word16 gainlpc_e[], + Word32 spectrum[], + Word16 *spectrum_e, + const Word16 L_frame, + const Word16 L_frameTCX ); + +void tcxInvertWindowGrouping( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word32 xn_buf[], + Word32 spectrum[], + const Word16 L_frame, + const Word8 fUseTns, + const Word16 last_core, + const Word16 index, + const Word16 frame_cnt, + const Word16 bfi ); + +void permute_fx( + Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ + const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ +); + +void init_lvq_fx( + Word32 offset_scale1[][MAX_NO_SCALES + 1], + Word32 offset_scale2[][MAX_NO_SCALES + 1], + Word32 offset_scale1_p[][MAX_NO_SCALES + 1], + Word32 offset_scale2_p[][MAX_NO_SCALES + 1], + Word16 no_scales[][2], + Word16 no_scales_p[][2] ); + +Word16 deindex_lvq_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ + Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, /* i : offset for first subvector */ + Word32 *p_offset_scale2, /* i : offset for the second subvector */ + Word16 *p_no_scales ); + +Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ +); + +Word16 deindex_lvq_cng_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o : decoded codevector Q9*/ + Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ + Word16 no_bits, /* i : number of bits for lattice */ + Word32 *p_offset_scale1, + Word32 *p_offset_scale2, + Word16 *p_no_scales ); + +Word16 deindex_lvq_cng_ivas_fx( + Word16 *index, /* i: index to be decoded, as an array of 3 short */ + Word16 *x_lvq, /* o: decoded codevector Q9 */ + Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ + Word16 no_bits /* i: number of bits for lattice */ +); + +Word16 lsp_convert_poly_fx( + Word16 w[], /* i/o: LSP or ISP parameters */ + const Word16 L_frame, /* i : flag for up or down conversion */ + const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ +); + +void CNG_exc_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 L_frame, /* i : length of the frame */ + Word32 *Enew, /* i/o: decoded SID energy Q6 */ + Word16 *seed, /* i/o: random generator seed */ + Word16 exc[], /* o : current non-enhanced excitation Q_new */ + Word16 exc2[], /* o : current enhanced excitation Q_new */ + Word32 *lp_ener, /* i/o: LP filtered E */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ + Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ + Word16 bwe_exc[], /* o : excitation for SWB TBE */ + const Word16 allow_cn_step, /* i : allow CN step */ + Word16 *last_allow_cn_step, /* i/o: last allow step */ + const Word16 OldQ_exc, /* i : Old excitation scaling */ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 num_ho, /* i : number of selected hangover frames */ + Word32 q_env[], + Word32 *lp_env, + Word32 *old_env, + Word16 *exc_mem, + Word16 *exc_mem1, + Word16 *sid_bw, + Word16 *cng_ener_seed1, + Word16 exc3[], + Word16 Opt_AMR_WB, + const Word16 element_mode /* i : IVAS Element mode */ +); + +void cng_params_postupd_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[] /* i/o: Envelope buffer */ +); + +void cng_params_postupd_ivas_fx( + const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ + Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ + const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ + const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ + const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ +); + +void cng_params_upd_fx( + const Word16 lsp_new[], /* i : LSP parameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate /* i : Last active bit rate Q0 */ +); + +void cng_params_upd_ivas_fx( + const Word16 lsp_new[], /* i : LSP aprameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate, /* i : Last active bit rate Q0 */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ +); + +Word16 get_cng_mode( + const Word32 last_active_brate /* i : last active bitrate */ +); + +/*! r: codec mode */ +Word16 get_codec_mode( + const Word32 total_brate /* i : total bitrate */ +); + +Word16 getTcxonly( + const Word32 total_brate /* i : total bitrate */ +); + +Word16 getTcxonly_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ +); + +Word16 getCtxHm( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_flag /* i : flag to signal the RF mode */ +); + +Word16 getResq( + const Word32 total_brate /* i : total bitrate */ +); + +Word16 getTnsAllowed( + const Word32 total_brate, /* i : total bitrate */ + const Word16 igf, /* i : flag indicating IGF activity*/ + const Word16 element_mode /* i : IVAS element mode */ +); + +Word16 getRestrictedMode( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ +); + +Word16 getMdctWindowLength_fx( + const Word16 fscale ); + +Word16 sr2fscale_fx( + const Word32 sr_core /* i : internal sampling rate */ +); + +Word32 getCoreSamplerateMode2( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ +); + +Word16 getTcxBandwidth( + const Word16 bandwidth ); + +Word16 getIgfPresent_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 getCnaPresent_fx( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bwidth /* i : audio bandwidth */ +); + +Word16 getTcxLtp( + const Word32 sr_core /* i : internal sampling rate */ +); + +Word16 initPitchLagParameters( + const Word32 sr_core, + Word16 *pit_min, + Word16 *pit_fr1, + Word16 *pit_fr1b, + Word16 *pit_fr2, + Word16 *pit_max ); + +Word16 getNumTcxCodedLines( + const Word16 bwidth ); + +Word16 getTcxLpcShapedAri( + const Word32 total_brate, /* i : total bitrate */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const Word16 element_mode /* i : IVAS element mode */ +); + +void mdct_window_sine( + PWord16 *window, /* Qx */ + Word16 n /* Q0 */ +); + +void mdct_window_sine_IVAS_updated( + PWord16 *window, /* Qx */ + const Word32 Fs, /* Q0 */ + const Word16 n, /* Q0 */ + const Word16 window_type, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void mdct_window_aldo( + Word16 *window1, /* Q15 */ + PWord16 *window1_trunc, /* Q15 */ + PWord16 *window2, /* Q15 */ + Word16 n /* Q0 */ +); + +Word16 getInvFrameLen( + const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ + +void tcx_get_windows( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ + const Word16 left_mode, /* i: overlap mode of left window half */ + const Word16 right_mode, /* i: overlap mode of right window half */ + Word16 *left_overlap, /* o: left overlap length */ + const PWord16 **left_win, /* o: left overlap window */ + Word16 *right_overlap, /* o: right overlap length */ + const PWord16 **right_win, /* o: right overlap window */ + const Word8 fullband /* i: fullband flag */ +); + +void WindowSignal( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + Word16 offset, /* i : left folding point offset relative to the i signal pointer */ + const Word16 left_overlap_mode, /* i : overlap mode of left window half */ + Word16 right_overlap_mode, /* i : overlap mode of right window half */ + Word16 *left_overlap_length, /* o : TCX window left overlap length */ + Word16 *right_overlap_length, /* o : TCX window right overlap length */ + const Word16 in[], /* i : i signal */ + Word16 *L_frame, /* i/o: frame length */ + Word16 out[], /* o : output windowed signal */ + const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ + const Word8 fullband /* i : fullband flag */ +); + +void tcx_windowing_synthesis_current_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 left_rect, /* i: left part is rectangular */ + const Word16 left_mode, /* i: overlap mode of left window half */ + Word16 *acelp_zir, /* i: acelp ZIR */ + const Word16 *old_syn, + const Word16 *syn_overl, + const Word16 *A_zir, + const PWord16 *window_trans, + Word16 acelp_zir_len, + const Word16 acelp_mem_len, + const Word16 last_core_bfi, /* i : last core */ + const Word8 last_is_cng, + const Word16 fullbandScale ); + +void tcx_windowing_synthesis_past_frame( + Word16 *signal, /* i/o: signal vector */ + const PWord16 *window, /* i: TCX window vector */ + const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ + const PWord16 *window_min, /* i: TCX minimum overlap window */ + const Word16 window_length, /* i: TCX window length */ + const Word16 window_half_length, /* i: TCX half window length */ + const Word16 window_min_length, /* i: TCX minimum overlap length */ + const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ +); + +void lpc2mdct( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 *mdct_gains, + Word16 *mdct_gains_exp, + Word16 *mdct_inv_gains, + Word16 *mdct_inv_gains_exp, + const Word16 length, + const Word16 noInverse ); + +void lpc2mdct_2( + Word16 *lpcCoeffs, + const Word16 lpcOrder, + Word16 mdct_gains_fx[], + Word16 mdct_gains_e[], + Word16 mdct_inv_gains_fx[], + Word16 mdct_inv_gains_e[], + const Word16 length ); + +void mdct_shaping( + Word32 x[], + const Word16 lg, + const Word16 gains[], + const Word16 gains_exp[] ); + +void mdct_shaping_16( + const Word16 x[], + const Word16 lg, + const Word16 lg_total, + const Word16 gains[], + const Word16 gains_exp[], + Word16 gains_max_exp, + Word32 y[] ); + +void mdct_noiseShaping_ivas_fx( + Word32 x_fx[], + Word16 *x_e, + const Word16 lg, + const Word16 gains_fx[], + const Word16 gains_exp[] ); + +void mdct_noiseShaping_interp( + Word32 x[], + const Word16 lg, + Word16 gains[], + Word16 gains_exp[] ); + +void PsychAdaptLowFreqDeemph( + Word32 x[], + const Word16 lpcGains[], + const Word16 lpcGains_e[], + Word16 lf_deemph_factors[] ); + +void AdaptLowFreqDeemph( + Word32 x[], + Word16 x_e, + Word16 tcx_lpc_shaped_ari, + Word16 lpcGains[], + Word16 lpcGains_e[], + const Word16 lg, + Word16 lf_deemph_factors[] ); + +void tcx_noise_filling( + Word32 *Q, + Word16 Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ +); + +void tcx_noise_filling_with_shift( + Word32 *Q, + Word16 *Q_e, + Word16 seed, + const Word16 iFirstLine, + const Word16 lowpassLine, + const Word16 nTransWidth, + const Word16 L_frame, + const Word16 tiltCompFactor, + Word16 fac_ns, + Word16 *infoTCXNoise, + const Word16 element_mode /* i : IVAS element mode */ +); + +void InitTnsConfigs( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void InitTnsConfigs_ivas_fx( + const Word16 bwidth, + const Word16 L_frame, + STnsConfig tnsConfig[2][2], + const Word16 igfStopFreq, + const Word32 total_brate, + const Word16 element_mode, + const Word16 is_mct ); + +void SetAllowTnsOnWhite( + STnsConfig tnsConfig[2][2], + const Word8 allowTnsOnWhite ); + +void SetTnsConfig( + TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ + const Word16 isTCX20, + const Word16 isAfterACELP ); + +void tcx_get_gain( + Word32 *x, /* i: spectrum 1 */ + Word16 x_e, /* i: spectrum 1 exponent */ + Word32 *y, /* i: spectrum 2 */ + Word16 y_e, /* i: spectrum 2 exponent */ + Word16 n, /* i: length */ + Word16 *gain, /* o: gain */ + Word16 *gain_e, /* o: gain exponent */ + Word32 *en_y, /* o: energy of y (optional) */ + Word16 *en_y_e /* o: energy of y exponent (optional) */ +); + +void init_TCX_config( + TCX_CONFIG_HANDLE hTcxCfg, + Word16 L_frame, + Word16 fscale, + Word16 L_frameTCX, + Word16 fscaleFB ); + +void resetTecDec_Fx( + TEC_DEC_HANDLE hTecDec ); + +void resetTecEnc_Fx( + TEC_ENC_HANDLE hTECEnc, + Word16 flag ); + +void calcGainTemp_TBE_Fx( + Word32 **pCldfbRealSrc_Fx, + Word32 **pCldfbImagSrc_Fx, + Word16 cldfb_exp, + Word16 *loBuffer_Fx, + const Word16 startPos, /*!< Start position of the current envelope. */ + const Word16 stopPos, /*!< Stop position of the current envelope. */ + const Word16 lowSubband, /* lowSubband */ + Word16 *pGainTemp_m, + Word16 *pGainTemp_e, + const Word16 code ); + +Word16 procTecTfa_TBE_Fx( + Word16 *hb_synth_Fx, + Word16 hb_synth_fx_exp, + Word16 *gain_m, + Word16 *gain_e, + Word16 flat_flag, + Word16 last_core, + Word16 l_subfr, + Word16 code ); + +void calcHiEnvLoBuff_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + const Word16 nSfb, /*!< Number of scalefactors. */ + Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 pCldfbPow_FixScale ); + +void calcLoEnvCheckCorrHiLo_Fix( + const Word16 noCols, + const Word16 *pFreqBandTable, /*!< freqbandTable. */ + Word16 *loBuffer_Fix /*float* loBuffer Q8*/, + Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, + Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, + Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, + Word16 *corrFlag /*int* corrFlag*/ +); + +void tecEnc_TBE_fx( + Word16 *corrFlag, + const Word16 *voicing, + const Word16 coder_type ); + +void set_TEC_TFA_code_fx( + const Word16 corrFlag, + Word16 *tec_flag, + Word16 *tfa_flag ); + +void TCX_MDCT( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void TCX_MDST( + const Word16 *x, /* Qx */ + Word32 *y, /* exp(y_e) */ + Word16 *y_e, + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void TCX_MDCT_Inverse( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode /* Q0 */ +); + +void TCX_MDST_Inverse_fx( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r /* Q0 */ +); + +void TCX_MDXT_Inverse_fx( + const Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type /* Q0 */ +); + +void edct_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ +); + +void edct_ivas_fx( + const Word32 *x, /* i : input signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length Q0*/ + Word16 *q /* i : Q value of input signal */ +); + +void edst_fx( + const Word32 *x, /* i : i signal Qq */ + Word32 *y, /* o : output transform Qq */ + Word16 length, /* i : length */ + Word16 *q /* i : Q value of i signal */ +); + +void edct_16fx( + const Word16 *x, /* i : i signal Qx */ + Word16 *y, /* o : output transform Qx */ + Word16 length, /* i : length */ + Word16 bh, /* bit-headroom */ + const Word16 element_mode ); + +void iedct_short_fx( + const Word32 *in, /* i : i vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 segment_length /* i : length */ +); + +void edxt_fx( + const Word32 *x, /* i : input signal */ + Word32 *y, /* o : output transform */ + const Word16 length, /* i : length */ + const UWord16 kernelType, /* i : kernel type (0 - 3) */ + const UWord16 synthesis /* i : nonzero for inverse */ +); + +void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); +void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); +void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); + +void DoRTFTn_fx( + Word32 *x, /* i/o : real part of i and output data */ + Word32 *y, /* i/o : imaginary part of i and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ +); + +void DoRTFT480_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT320_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT160_fx( + Word32 x[], /* i/o: real part of input and output data */ + Word32 y[] /* i/o: imaginary part of input and output data */ +); + +void DoRTFT128_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT120_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT80_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT40_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +void DoRTFT20_fx( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y /* i/o: imaginary part of input and output data */ +); + +Word16 RFFTN_fx( + Word32 *data, + const Word16 *sine_table, + const Word16 len, + const Word16 sign ); + +void DoFFT_fx( + Word32 *re2, + Word32 *im2, + const Word16 length ); + +void fft_fx( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + const Word16 length, /* i : length of fft */ + const Word16 s /* i : sign */ +); + +void rfft_fx( + Word32 *x, /* i/o: values */ + const Word16 *w, /* i : window */ + const Word16 length, /* i : length of fft */ + const Word16 isign /* i : sign */ +); + +void DoRTFTn_fx_ivas( + Word32 *x, /* i/o: real part of input and output data */ + Word32 *y, /* i/o: imaginary part of input and output data */ + const Word16 n /* i : size of the FFT up to 1024 */ +); + + +Word16 find_guarded_bits_fx( const Word32 n ); - void ITF_Apply_fx( - Word32 spectrum[], - Word16 startLine, - Word16 stopLine, - const Word16 *A, - Word16 Q_A, - Word16 curr_order ); - - void const *GetTnsFilterCoeff( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsFilterCoeff( void *p, const Word16 index, const Word16 value ); - - Word16 GetSWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - - Word16 EncodeSWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - - Word16 DecodeSWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetSWBTCX10TnsFilterCoeffBits( const Word16 value, const Word16 index ); - - Word16 EncodeSWBTCX10TnsFilterCoeff( const Word16 value, const Word16 index ); - - Word16 DecodeSWBTCX10TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetWBTCX20TnsFilterCoeffBits( const Word16 value, const Word16 index ); - - Word16 EncodeWBTCX20TnsFilterCoeff( const Word16 value, const Word16 index ); - - Word16 DecodeWBTCX20TnsFilterCoeff( Decoder_State *st, const Word16 index, Word16 *pValue ); - - void const *GetTnsFilterOrder( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsFilterOrder( void *p, const Word16 index, const Word16 value ); - - Word16 GetTnsFilterOrderBitsSWBTCX20( const Word16 value, const Word16 index ); - - Word16 EncodeTnsFilterOrderSWBTCX20( const Word16 value, const Word16 index ); - - Word16 DecodeTnsFilterOrderSWBTCX20( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetTnsFilterOrderBitsSWBTCX10( const Word16 value, const Word16 index ); - - Word16 EncodeTnsFilterOrderSWBTCX10( const Word16 value, const Word16 index ); - - Word16 DecodeTnsFilterOrderSWBTCX10( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 GetTnsFilterOrderBits( const Word16 value, const Word16 index ); - - Word16 EncodeTnsFilterOrder( const Word16 value, const Word16 index ); - - Word16 DecodeTnsFilterOrder( Decoder_State *st, const Word16 index, Word16 *pValue ); - - void const *GetNumOfTnsFilters( void const *p, const Word16 index, Word16 *pValue ); - - void *SetNumOfTnsFilters( void *p, const Word16 index, Word16 value ); - - void const *GetTnsEnabled( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ); - - void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ); - - void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); - - void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); - void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); - - void ResetTnsData( STnsData *pTnsData ); - - void ClearTnsFilterCoefficients( STnsFilter *pTnsFilter ); - - /*========================================================================================================/ - gp_clips_fx.c - /========================================================================================================*/ - - void init_gp_clip_fx( - Word16 mem[] /* o : memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - ); - - Word16 gp_clip_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 *voicing, /* i : normalized correlations (from OL pitch) Q15*/ - const Word16 i_subfr, /* i : subframe index Q0*/ - const Word16 coder_type, /* i : type of coder Q0*/ - const Word16 xn[], /* i : target vector Q_new*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Q_new /* i : scaling factor */ - ); - - void gp_clip_test_isf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 isf[], /* i : isf values (in frequency domain) Q2.56*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm Q15*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ - ); - - void gp_clip_test_gain_pit_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 gain_pit, /* i : gain of quantized pitch Q14*/ - Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm 1Q14*/ - ); - - Word16 Mode2_gp_clip_fx( - const Word16 *voicing, /* i : normalized correlations from OL pitch Q15 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 coder_type, /* i : type of coder Q0 */ - const Word16 xn[], /* i : target vector Q_xn */ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */ - /* mem[0]: Q0 */ - /* mem[1]: 1Q14 */ - /* mem[2]: 8Q7 */ - /* mem[3]: Q0 (integer) */ - /* mem[4]: Q14 */ - /* mem[5]: Q14 */ - const Word16 L_subfr, /* Q0 */ - const Word16 Q_xn /* i : scaling factor of vector xn[] */ - ); - - void gp_clip_test_lsf_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word16 lsf[], /* i : lsf values (in frequency domain) 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 m /* i : dimension of lsf Q0*/ - ); - - void gp_clip_test_lsf_ivas_fx( - const Word16 element_mode, /* i : element mode Q0*/ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 lsf[], /* i : LSF vector 14Q1*1.28*/ - Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm [2.56x,Q14,Q8,Q0,Q14,Q14]*/ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode Q0*/ - ); - - /*========================================================================================================/ - nelp_enc_fx.c - /========================================================================================================*/ - - void quantize_uvg_fx( - Word16 *G, - Word16 *iG1, - Word16 *iG2, - Word16 *quantG, - Word16 bandwidth ); - - void nelp_encoder_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - - void nelp_encoder_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state */ - Word16 *in_fx, /* i : residual signal */ - Word16 *exc_fx, /* o : NELP quantized excitation signal */ - Word16 *qIn1, - Word16 reduce_gains ); - - void swb_bwe_enc_lr_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ - ); - - void swb_bwe_enc_lr_ivas_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis */ - Word16 QsL, - const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Total number of Subbands in a frame */ - Word16 *band_start_fx, /* i : band start of each SB */ - Word16 *band_end_fx, /* i : band end of each SB */ - Word32 *L_band_energy, /* i : band_energy of each SB */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal indicator */ - const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */ - Word16 lowlength_fx, /* i : lowband length */ - Word16 highlength_fx, /* i : highband length */ - Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands */ - Word16 *prev_frm_hfe2, /* i/o: */ - Word16 *prev_stab_hfe2, /* i/o: */ - const Word16 band_width_fx[], /* i : band_width information */ - const Word32 L_y2_ni[], /* i : band_width information */ - Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */ - ); - - void isf_enc_amr_wb_fx( - Encoder_State *st, /* i/o: state structure */ - Word16 *isf_new, /* i/o: quantized ISF vector */ - Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */ - Word16 *Aq /* o : quantized A(z) for 4 subframes */ - ); - - Word16 detect_transient_fx( - const Word16 *in_fx, /*Q_new */ - const Word16 L, /*Q0*/ - Word16 Q_new, - Encoder_State *st_fx ); - - Word16 tcxGetNoiseFillingTilt( - const Word16 A[], - const Word16 lpcorder, - const Word16 L_frame, - const Word16 mode, - Word16 *noiseTiltFactor ); - - void tcxFormantEnhancement( - Word16 xn_buf[], - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - - void tcxFormantEnhancement_with_shift( - Word16 xn_buf[], - Word16 *xn_buf_e, - const Word16 gainlpc[], - const Word16 gainlpc_e[], - Word32 spectrum[], - Word16 *spectrum_e, - const Word16 L_frame, - const Word16 L_frameTCX ); - - void tcxInvertWindowGrouping( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word32 xn_buf[], - Word32 spectrum[], - const Word16 L_frame, - const Word8 fUseTns, - const Word16 last_core, - const Word16 index, - const Word16 frame_cnt, - const Word16 bfi ); - - void permute_fx( - Word16 *pTmp1, /* i/o: vector whose components are to be permuted */ - const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */ - ); - - void init_lvq_fx( - Word32 offset_scale1[][MAX_NO_SCALES + 1], - Word32 offset_scale2[][MAX_NO_SCALES + 1], - Word32 offset_scale1_p[][MAX_NO_SCALES + 1], - Word32 offset_scale2_p[][MAX_NO_SCALES + 1], - Word16 no_scales[][2], - Word16 no_scales_p[][2] ); - - Word16 deindex_lvq_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/ - Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, /* i : offset for first subvector */ - Word32 *p_offset_scale2, /* i : offset for the second subvector */ - Word16 *p_no_scales ); - - Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ - ); - - Word16 deindex_lvq_cng_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o : decoded codevector Q9*/ - Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */ - Word16 no_bits, /* i : number of bits for lattice */ - Word32 *p_offset_scale1, - Word32 *p_offset_scale2, - Word16 *p_no_scales ); - - Word16 deindex_lvq_cng_ivas_fx( - Word16 *index, /* i: index to be decoded, as an array of 3 short */ - Word16 *x_lvq, /* o: decoded codevector Q9 */ - Word16 idx_cv, /* i: relative mode_lvq, wrt START_CNG */ - Word16 no_bits /* i: number of bits for lattice */ - ); - - Word16 lsp_convert_poly_fx( - Word16 w[], /* i/o: LSP or ISP parameters */ - const Word16 L_frame, /* i : flag for up or down conversion */ - const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */ - ); - - void CNG_exc_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 L_frame, /* i : length of the frame */ - Word32 *Enew, /* i/o: decoded SID energy Q6 */ - Word16 *seed, /* i/o: random generator seed */ - Word16 exc[], /* o : current non-enhanced excitation Q_new */ - Word16 exc2[], /* o : current enhanced excitation Q_new */ - Word32 *lp_ener, /* i/o: LP filtered E */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */ - Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */ - Word16 bwe_exc[], /* o : excitation for SWB TBE */ - const Word16 allow_cn_step, /* i : allow CN step */ - Word16 *last_allow_cn_step, /* i/o: last allow step */ - const Word16 OldQ_exc, /* i : Old excitation scaling */ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 num_ho, /* i : number of selected hangover frames */ - Word32 q_env[], - Word32 *lp_env, - Word32 *old_env, - Word16 *exc_mem, - Word16 *exc_mem1, - Word16 *sid_bw, - Word16 *cng_ener_seed1, - Word16 exc3[], - Word16 Opt_AMR_WB, - const Word16 element_mode /* i : IVAS Element mode */ - ); - - void cng_params_postupd_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[] /* i/o: Envelope buffer */ - ); - - void cng_params_postupd_ivas_fx( - const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */ - Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */ - const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */ - const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */ - const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ - ); - - void cng_params_upd_fx( - const Word16 lsp_new[], /* i : LSP parameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ - ); - - void cng_params_upd_ivas_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate, /* i : Last active bit rate Q0 */ - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ - ); - - Word16 get_cng_mode( - const Word32 last_active_brate /* i : last active bitrate */ - ); - - /*! r: codec mode */ - Word16 get_codec_mode( - const Word32 total_brate /* i : total bitrate */ - ); - - Word16 getTcxonly( - const Word32 total_brate /* i : total bitrate */ - ); - - Word16 getTcxonly_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ - ); - - Word16 getCtxHm( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_flag /* i : flag to signal the RF mode */ - ); - - Word16 getResq( - const Word32 total_brate /* i : total bitrate */ - ); - - Word16 getTnsAllowed( - const Word32 total_brate, /* i : total bitrate */ - const Word16 igf, /* i : flag indicating IGF activity*/ - const Word16 element_mode /* i : IVAS element mode */ - ); - - Word16 getRestrictedMode( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ - ); - - Word16 getMdctWindowLength_fx( - const Word16 fscale ); - - Word16 sr2fscale_fx( - const Word32 sr_core /* i : internal sampling rate */ - ); - - Word32 getCoreSamplerateMode2( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ - ); - - Word16 getTcxBandwidth( - const Word16 bandwidth ); - - Word16 getIgfPresent_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - Word16 getCnaPresent_fx( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 bwidth /* i : audio bandwidth */ - ); - - Word16 getTcxLtp( - const Word32 sr_core /* i : internal sampling rate */ - ); - - Word16 initPitchLagParameters( - const Word32 sr_core, - Word16 *pit_min, - Word16 *pit_fr1, - Word16 *pit_fr1b, - Word16 *pit_fr2, - Word16 *pit_max ); - - Word16 getNumTcxCodedLines( - const Word16 bwidth ); - - Word16 getTcxLpcShapedAri( - const Word32 total_brate, /* i : total bitrate */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const Word16 element_mode /* i : IVAS element mode */ - ); - - void mdct_window_sine( - PWord16 *window, /* Qx */ - Word16 n /* Q0 */ - ); - - void mdct_window_sine_IVAS_updated( - PWord16 *window, /* Qx */ - const Word32 Fs, /* Q0 */ - const Word16 n, /* Q0 */ - const Word16 window_type, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void mdct_window_aldo( - Word16 *window1, /* Q15 */ - PWord16 *window1_trunc, /* Q15 */ - PWord16 *window2, /* Q15 */ - Word16 n /* Q0 */ - ); - - Word16 getInvFrameLen( - const Word16 L_frame ); /* returns 1/L_frame in Q21 format */ - - void tcx_get_windows( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX configuration */ - const Word16 left_mode, /* i: overlap mode of left window half */ - const Word16 right_mode, /* i: overlap mode of right window half */ - Word16 *left_overlap, /* o: left overlap length */ - const PWord16 **left_win, /* o: left overlap window */ - Word16 *right_overlap, /* o: right overlap length */ - const PWord16 **right_win, /* o: right overlap window */ - const Word8 fullband /* i: fullband flag */ - ); - - void WindowSignal( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - Word16 offset, /* i : left folding point offset relative to the i signal pointer */ - const Word16 left_overlap_mode, /* i : overlap mode of left window half */ - Word16 right_overlap_mode, /* i : overlap mode of right window half */ - Word16 *left_overlap_length, /* o : TCX window left overlap length */ - Word16 *right_overlap_length, /* o : TCX window right overlap length */ - const Word16 in[], /* i : i signal */ - Word16 *L_frame, /* i/o: frame length */ - Word16 out[], /* o : output windowed signal */ - const Word16 truncate_aldo, /* i : nonzero to truncate long ALDO slope */ - const Word8 fullband /* i : fullband flag */ - ); - - void tcx_windowing_synthesis_current_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 left_rect, /* i: left part is rectangular */ - const Word16 left_mode, /* i: overlap mode of left window half */ - Word16 *acelp_zir, /* i: acelp ZIR */ - const Word16 *old_syn, - const Word16 *syn_overl, - const Word16 *A_zir, - const PWord16 *window_trans, - Word16 acelp_zir_len, - const Word16 acelp_mem_len, - const Word16 last_core_bfi, /* i : last core */ - const Word8 last_is_cng, - const Word16 fullbandScale ); - - void tcx_windowing_synthesis_past_frame( - Word16 *signal, /* i/o: signal vector */ - const PWord16 *window, /* i: TCX window vector */ - const PWord16 *window_half, /* i: TCX window vector for half-overlap window */ - const PWord16 *window_min, /* i: TCX minimum overlap window */ - const Word16 window_length, /* i: TCX window length */ - const Word16 window_half_length, /* i: TCX half window length */ - const Word16 window_min_length, /* i: TCX minimum overlap length */ - const Word16 right_mode /* i: overlap mode (left_mode of current frame) */ - ); - - void lpc2mdct( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 *mdct_gains, - Word16 *mdct_gains_exp, - Word16 *mdct_inv_gains, - Word16 *mdct_inv_gains_exp, - const Word16 length, - const Word16 noInverse ); - - void lpc2mdct_2( - Word16 *lpcCoeffs, - const Word16 lpcOrder, - Word16 mdct_gains_fx[], - Word16 mdct_gains_e[], - Word16 mdct_inv_gains_fx[], - Word16 mdct_inv_gains_e[], - const Word16 length ); - - void mdct_shaping( - Word32 x[], - const Word16 lg, - const Word16 gains[], - const Word16 gains_exp[] ); - - void mdct_shaping_16( - const Word16 x[], - const Word16 lg, - const Word16 lg_total, - const Word16 gains[], - const Word16 gains_exp[], - Word16 gains_max_exp, - Word32 y[] ); - - void mdct_noiseShaping_ivas_fx( - Word32 x_fx[], - Word16 *x_e, - const Word16 lg, - const Word16 gains_fx[], - const Word16 gains_exp[] ); - - void mdct_noiseShaping_interp( - Word32 x[], - const Word16 lg, - Word16 gains[], - Word16 gains_exp[] ); - - void PsychAdaptLowFreqDeemph( - Word32 x[], - const Word16 lpcGains[], - const Word16 lpcGains_e[], - Word16 lf_deemph_factors[] ); - - void AdaptLowFreqDeemph( - Word32 x[], - Word16 x_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], - Word16 lpcGains_e[], - const Word16 lg, - Word16 lf_deemph_factors[] ); - - void tcx_noise_filling( - Word32 *Q, - Word16 Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ - ); - - void tcx_noise_filling_with_shift( - Word32 *Q, - Word16 *Q_e, - Word16 seed, - const Word16 iFirstLine, - const Word16 lowpassLine, - const Word16 nTransWidth, - const Word16 L_frame, - const Word16 tiltCompFactor, - Word16 fac_ns, - Word16 *infoTCXNoise, - const Word16 element_mode /* i : IVAS element mode */ - ); - - void InitTnsConfigs( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void InitTnsConfigs_ivas_fx( - const Word16 bwidth, - const Word16 L_frame, - STnsConfig tnsConfig[2][2], - const Word16 igfStopFreq, - const Word32 total_brate, - const Word16 element_mode, - const Word16 is_mct ); - - void SetAllowTnsOnWhite( - STnsConfig tnsConfig[2][2], - const Word8 allowTnsOnWhite ); - - void SetTnsConfig( - TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ - const Word16 isTCX20, - const Word16 isAfterACELP ); - - void tcx_get_gain( - Word32 *x, /* i: spectrum 1 */ - Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 */ - Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length */ - Word16 *gain, /* o: gain */ - Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) */ - Word16 *en_y_e /* o: energy of y exponent (optional) */ - ); - - void init_TCX_config( - TCX_CONFIG_HANDLE hTcxCfg, - Word16 L_frame, - Word16 fscale, - Word16 L_frameTCX, - Word16 fscaleFB ); - - void resetTecDec_Fx( - TEC_DEC_HANDLE hTecDec ); - - void resetTecEnc_Fx( - TEC_ENC_HANDLE hTECEnc, - Word16 flag ); - - void calcGainTemp_TBE_Fx( - Word32 **pCldfbRealSrc_Fx, - Word32 **pCldfbImagSrc_Fx, - Word16 cldfb_exp, - Word16 *loBuffer_Fx, - const Word16 startPos, /*!< Start position of the current envelope. */ - const Word16 stopPos, /*!< Stop position of the current envelope. */ - const Word16 lowSubband, /* lowSubband */ - Word16 *pGainTemp_m, - Word16 *pGainTemp_e, - const Word16 code ); - - Word16 procTecTfa_TBE_Fx( - Word16 *hb_synth_Fx, - Word16 hb_synth_fx_exp, - Word16 *gain_m, - Word16 *gain_e, - Word16 flat_flag, - Word16 last_core, - Word16 l_subfr, - Word16 code ); - - void calcHiEnvLoBuff_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - const Word16 nSfb, /*!< Number of scalefactors. */ - Word32 **pCldfbPow_Fix /*float** pCldfbPow*/, - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 pCldfbPow_FixScale ); - - void calcLoEnvCheckCorrHiLo_Fix( - const Word16 noCols, - const Word16 *pFreqBandTable, /*!< freqbandTable. */ - Word16 *loBuffer_Fix /*float* loBuffer Q8*/, - Word16 *loTempEnv_Fix /*float* loTempEnv Q7*/, - Word16 *loTempEnv_ns_Fix /* float* loTempEnv_ns*/, - Word16 *hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/, - Word16 *corrFlag /*int* corrFlag*/ - ); - - void tecEnc_TBE_fx( - Word16 *corrFlag, - const Word16 *voicing, - const Word16 coder_type ); - - void set_TEC_TFA_code_fx( - const Word16 corrFlag, - Word16 *tec_flag, - Word16 *tfa_flag ); - - void TCX_MDCT( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void TCX_MDST( - const Word16 *x, /* Qx */ - Word32 *y, /* exp(y_e) */ - Word16 *y_e, - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void TCX_MDCT_Inverse( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qy */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode /* Q0 */ - ); - - void TCX_MDST_Inverse_fx( - Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r /* Q0 */ - ); - - void TCX_MDXT_Inverse_fx( - const Word32 *x, /* exp(x_e) */ - Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const UWord16 kernel_type /* Q0 */ - ); - - void edct_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ - ); - - void edct_ivas_fx( - const Word32 *x, /* i : input signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length Q0*/ - Word16 *q /* i : Q value of input signal */ - ); - - void edst_fx( - const Word32 *x, /* i : i signal Qq */ - Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ - Word16 *q /* i : Q value of i signal */ - ); - - void edct_16fx( - const Word16 *x, /* i : i signal Qx */ - Word16 *y, /* o : output transform Qx */ - Word16 length, /* i : length */ - Word16 bh, /* bit-headroom */ - const Word16 element_mode ); - - void iedct_short_fx( - const Word32 *in, /* i : i vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 segment_length /* i : length */ - ); - - void edxt_fx( - const Word32 *x, /* i : input signal */ - Word32 *y, /* o : output transform */ - const Word16 length, /* i : length */ - const UWord16 kernelType, /* i : kernel type (0 - 3) */ - const UWord16 synthesis /* i : nonzero for inverse */ - ); - - void fft16( Word32 *re, Word32 *im, Word16 s, Word16 bScale ); - void BASOP_cfft( cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH] ); - void BASOP_rfft( Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign ); - - void DoRTFTn_fx( - Word32 *x, /* i/o : real part of i and output data */ - Word32 *y, /* i/o : imaginary part of i and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ - ); - - void DoRTFT480_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT320_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT160_fx( - Word32 x[], /* i/o: real part of input and output data */ - Word32 y[] /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT128_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT120_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT80_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT40_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - void DoRTFT20_fx( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y /* i/o: imaginary part of input and output data */ - ); - - Word16 RFFTN_fx( - Word32 *data, - const Word16 *sine_table, - const Word16 len, - const Word16 sign ); - - void DoFFT_fx( - Word32 *re2, - Word32 *im2, - const Word16 length ); - - void fft_fx( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - const Word16 length, /* i : length of fft */ - const Word16 s /* i : sign */ - ); - - void rfft_fx( - Word32 *x, /* i/o: values */ - const Word16 *w, /* i : window */ - const Word16 length, /* i : length of fft */ - const Word16 isign /* i : sign */ - ); - - void DoRTFTn_fx_ivas( - Word32 *x, /* i/o: real part of input and output data */ - Word32 *y, /* i/o: imaginary part of input and output data */ - const Word16 n /* i : size of the FFT up to 1024 */ - ); - - - Word16 find_guarded_bits_fx( const Word32 n ); - - Word16 L_norm_arr( const Word32 *arr, Word16 size ); - Word16 norm_arr( Word16 *arr, Word16 size ); - Word16 W_norm_arr( Word64 *arr, Word16 size ); - - Word16 get_min_scalefactor( Word32 x, Word32 y ); - - Flag is_zero_arr( Word32 *arr, Word16 size ); - Flag is_zero_arr16( Word16 *arr, Word16 size ); - Flag is_zero_arr64( Word64 *arr, Word16 size ); - - void edct2_fx_ivas( - const Word16 n, - const Word16 isgn, - Word32 *in, - Word32 *a, - const Word16 *ip, - const Word16 *w ); - - void edct2_fx( - Word16 n, - Word16 isgn, - Word16 *in, - Word32 *a, - Word16 *q, - const Word16 *ip, - const Word16 *w ); - - void DoRTFT160_16fx( - Word16 x[], /* i/o : real part of i and output data */ - Word16 y[] /* i/o : imaginary part of i and output data */ - ); - - void DoRTFT320_16fx( - Word16 *x, /* i/o : real part of i and output data */ - Word16 *y /* i/o : imaginary part of i and output data */ - ); - - void DoRTFT128_16fx( - Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ - Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ - ); - - void fft3_fx( - const Word16[], - Word16[], - const Word16 ); - - void ifft3_fx( - const Word16[], - Word16[], - const Word16 ); - - void fft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); - void ifft3_fx_ivas( - const Word32 X[], - Word32 Y[], - const Word16 n ); - - void r_fft_fx_lc( - const Word16 *phs_tbl, /* i : Table of phase */ - const Word16 SIZE, /* i : Size of the FFT */ - const Word16 SIZE2, /* i : Size / 2 */ - const Word16 NUM_STAGE, /* i : Number of stage */ - const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ - const Word16 isign /* i : 1=fft, otherwize it's ifft */ - ); - - void cldfbAnalysis_fx( - HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ - Word32 **cldfbReal, /*!< Pointer to real subband slots */ - Word32 **cldfbImag, /*!< Pointer to imag subband slots */ - CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - const Word16 *timeIn, /*!< Time signal */ - const Word16 timeIn_e, /*!< Time signal */ - const Word16 nTimeSlots, /*!< Time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ - ); - - void cldfbSynthesis_fx( - HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ - Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ - Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ - const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ - Word16 *timeOut, /*!< Time signal */ - const Word16 timeOut_e, /*!< Target exponent for output signal */ - const Word16 nTimeSlots, /*!< number of time slots to be processed */ - Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ - ); - - void configureCldfb( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ - const Word32 sampling_rate /* i : sampling rate */ - ); - - ivas_error openCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ - const Word16 type, /* i : analysis or synthesis */ - const Word32 sampling_rate /* i : sampling rate */ - ); - - void resampleCldfb( - HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 frameSize, /*!< FrameSize */ - const Word8 firstFrame ); - - Word16 AnalysisPostSpectrumScaling_Fx( - HANDLE_CLDFB_FILTER_BANK cldfbBank, - Word32 **rSubband32, - Word32 **iSubband32, - Word16 **rSubband16, - Word16 **iSubband16, - Word16 *cldfbScale ); - - void analysisCldfbEncoder_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *timeIn, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - - void GetEnergyCldfb( - Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ - Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ - const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ - Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ - Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ - Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ - Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ - Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ - Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ - Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ - Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ - Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ - TEC_ENC_HANDLE hTECEnc ); - - void deleteCldfb( - HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ - - ivas_error cldfb_save_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - - void cldfb_restore_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - - void cldfb_reset_memory( - HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ - - void BITS_ALLOC_init_config_acelp( - const Word32 bit_rate, - const Word16 narrowBand, - const Word16 nb_subfr, - ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ - ); - - Word16 BITS_ALLOC_config_acelp( - const Word16 bits_frame, /*i: remaining bit budget for the frame */ - const Word16 coder_type, /*i: coder type */ - ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ - const Word16 narrowband, - const Word16 nb_subfr ); - - Word16 set_ACELP_flag( - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 total_brate, /* i : total bitrate per channel */ - const Word16 idchan, /* i : Channel id */ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 cng_type /* i : CNG type */ - ); - - void syn_12k8_fx( - Word16 L_frame, - const Word16 *Aq, /* i : LP filter coefficients Q12 */ - const Word16 *exc, /* i : i signal Q_exc */ - Word16 *synth, /* o : output signal Q_syn */ - Word16 *mem, /* i/o: initial filter states Q_syn */ - const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ - /* 1 --> update of memory */ - const Word16 Q_exc, /* i : Excitation scaling Q0 */ - const Word16 Q_syn /* i : Synthesis scaling Q0 */ - ); - - /* o : tilt of the code Q15 */ - Word16 est_tilt_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ +Word16 L_norm_arr( const Word32 *arr, Word16 size ); +Word16 norm_arr( Word16 *arr, Word16 size ); +Word16 W_norm_arr( Word64 *arr, Word16 size ); + +Word16 get_min_scalefactor( Word32 x, Word32 y ); + +Flag is_zero_arr( Word32 *arr, Word16 size ); +Flag is_zero_arr16( Word16 *arr, Word16 size ); +Flag is_zero_arr64( Word64 *arr, Word16 size ); + +void edct2_fx_ivas( + const Word16 n, + const Word16 isgn, + Word32 *in, + Word32 *a, + const Word16 *ip, + const Word16 *w ); + +void edct2_fx( + Word16 n, + Word16 isgn, + Word16 *in, + Word32 *a, + Word16 *q, + const Word16 *ip, + const Word16 *w ); + +void DoRTFT160_16fx( + Word16 x[], /* i/o : real part of i and output data */ + Word16 y[] /* i/o : imaginary part of i and output data */ +); + +void DoRTFT320_16fx( + Word16 *x, /* i/o : real part of i and output data */ + Word16 *y /* i/o : imaginary part of i and output data */ +); + +void DoRTFT128_16fx( + Word16 *x, /* i/o : real part of i and output data Q(Qx+Q_edct)*/ + Word16 *y /* i/o : imaginary part of i and output data Q(Qx+Q_edct)*/ +); + +void fft3_fx( + const Word16[], + Word16[], + const Word16 ); + +void ifft3_fx( + const Word16[], + Word16[], + const Word16 ); + +void fft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); +void ifft3_fx_ivas( + const Word32 X[], + Word32 Y[], + const Word16 n ); + +void r_fft_fx_lc( + const Word16 *phs_tbl, /* i : Table of phase */ + const Word16 SIZE, /* i : Size of the FFT */ + const Word16 SIZE2, /* i : Size / 2 */ + const Word16 NUM_STAGE, /* i : Number of stage */ + const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */ + const Word16 isign /* i : 1=fft, otherwize it's ifft */ +); + +void cldfbAnalysis_fx( + HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */ + Word32 **cldfbReal, /*!< Pointer to real subband slots */ + Word32 **cldfbImag, /*!< Pointer to imag subband slots */ + CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + const Word16 *timeIn, /*!< Time signal */ + const Word16 timeIn_e, /*!< Time signal */ + const Word16 nTimeSlots, /*!< Time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ +); + +void cldfbSynthesis_fx( + HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */ + Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */ + Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */ + const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */ + Word16 *timeOut, /*!< Time signal */ + const Word16 timeOut_e, /*!< Target exponent for output signal */ + const Word16 nTimeSlots, /*!< number of time slots to be processed */ + Word32 *pWorkBuffer /*!< pointer to temporal working buffer */ +); + +void configureCldfb( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: Returns handle */ + const Word32 sampling_rate /* i : sampling rate */ +); + +ivas_error openCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: Returns handle */ + const Word16 type, /* i : analysis or synthesis */ + const Word32 sampling_rate /* i : sampling rate */ +); + +void resampleCldfb( + HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 frameSize, /*!< FrameSize */ + const Word8 firstFrame ); + +Word16 AnalysisPostSpectrumScaling_Fx( + HANDLE_CLDFB_FILTER_BANK cldfbBank, + Word32 **rSubband32, + Word32 **iSubband32, + Word16 **rSubband16, + Word16 **iSubband16, + Word16 *cldfbScale ); + +void analysisCldfbEncoder_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *timeIn, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX], + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + +void GetEnergyCldfb( + Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */ + Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/ + const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */ + Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */ + Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */ + Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */ + Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */ + Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */ + Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */ + Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */ + Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/ + Word16 *energyValuesSum_Exp, /*!< o: pointer to exponents of energyValuesSum, not initialized */ + TEC_ENC_HANDLE hTECEnc ); + +void deleteCldfb( + HANDLE_CLDFB_FILTER_BANK *h_cldfb ); /*!< CLDFB Handle */ + +ivas_error cldfb_save_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + +void cldfb_restore_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + +void cldfb_reset_memory( + HANDLE_CLDFB_FILTER_BANK hs ); /* i/o: cldfb handle */ + +void BITS_ALLOC_init_config_acelp( + const Word32 bit_rate, + const Word16 narrowBand, + const Word16 nb_subfr, + ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/ +); + +Word16 BITS_ALLOC_config_acelp( + const Word16 bits_frame, /*i: remaining bit budget for the frame */ + const Word16 coder_type, /*i: coder type */ + ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/ + const Word16 narrowband, + const Word16 nb_subfr ); + +Word16 set_ACELP_flag( + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 total_brate, /* i : total bitrate per channel */ + const Word16 idchan, /* i : Channel id */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 cng_type /* i : CNG type */ +); + +void syn_12k8_fx( + Word16 L_frame, + const Word16 *Aq, /* i : LP filter coefficients Q12 */ + const Word16 *exc, /* i : i signal Q_exc */ + Word16 *synth, /* o : output signal Q_syn */ + Word16 *mem, /* i/o: initial filter states Q_syn */ + const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */ + /* 1 --> update of memory */ + const Word16 Q_exc, /* i : Excitation scaling Q0 */ + const Word16 Q_syn /* i : Synthesis scaling Q0 */ +); + +/* o : tilt of the code Q15 */ +Word16 est_tilt_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ #ifdef CLEANUP_ACELP_ENC - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #else const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ #endif - ); +); #ifndef CLEANUP_ACELP_ENC - /* o : tilt of the code Q15 */ - Word16 est_tilt_ivas_fx( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic excitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ - const Word16 L_subfr /* i : Sub frame length */ +/* o : tilt of the code Q15 */ +Word16 est_tilt_ivas_fx( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic excitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc, /* i : Scaling factor of excitation Q0 */ + const Word16 L_subfr /* i : Sub frame length */ #ifndef CLEANUP_ACELP_ENC - , - const Word16 flag_tilt /* i : flag for special tilt */ + , + const Word16 flag_tilt /* i : flag for special tilt */ #endif - ); +); #endif - /* o : tilt of the code */ - Word16 Est_tilt2( - const Word16 *exc, /* i : adaptive excitation vector Qx */ - const Word16 gain_pit, /* i : adaptive gain Q14 */ - const Word16 *code, /* i : algebraic exctitation vector Q9 */ - const Word32 gain_code, /* i : algebraic code gain Q16 */ - Word16 *voice_fac, /* o : voicing factor Q15 */ - const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ - ); - - void E_UTIL_voice_factor( - Word16 *exc, /* i : pointer to the excitation frame Q_new */ - Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* i : innovative codebook Q9 */ - Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ - Word16 *tilt_code, /* o : tilt factor Q15 */ - Word16 L_subfr, /* i : subframe length */ - Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ - Word16 Q_new, /* i : excitation buffer format */ - Word16 shift /* i : scaling to get 12bit */ - ); - - void sinq_fx( - const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ - const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ - const Word16 N, /* i : size of output */ - Word16 x[] /* o : output vector Q15*/ - ); - - void window_ola_fx( - Word32 *ImdctOut, - Word16 *auOut, - Word16 *Q_sig, - Word16 *OldauOut, - Word16 *Q_old, - const Word16 L, - const Word16 right_mode, - const Word16 left_mode, - const Word16 old_bfi, - const Word16 oldHqVoicing, - Word16 *oldgapsynth ); - - void core_switching_OLA_fx( - Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ - const Word16 last_L_frame, /* i : last L_frame lengthture */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ - Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ - Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ - const Word16 output_frame, /* i : output frame length */ - const Word16 bwidth, /* i : output bandwidth */ - Word16 *Qsynth, - Word16 *Qsubfr ); - - void window_ola_ext_fx( - const Word32 *ImdstOut, /* i : input */ - Word32 *auOut, /* o : output audio */ - Word32 *OldauOut, /* i/o: audio from previous frame */ - const Word16 L, /* i : length */ - const Word16 right_mode, - const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const UWord16 kernel_type /* i : transform kernel type */ - ); - - void cb_shape_fx( - const Word16 preemphFlag, /* i : flag for pre-emphasis */ - const Word16 pitchFlag, /* i : flag for pitch sharpening */ - const Word16 scramblingFlag, /* i : flag for phase scrambling */ - const Word16 sharpFlag, /* i : flag for formant sharpening */ - const Word16 formantTiltFlag, /* i : flag for formant tilt */ - const Word16 g1, /* i : formant sharpening numerator weighting */ - const Word16 g2, /* i : formant sharpening denominator weighting */ - const Word16 *p_Aq, /* i : LP filter coefficients */ - Word16 *code, /* i/o: signal to shape */ - const Word16 tilt_code, /* i : tilt of code */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ - const Word16 shift, - const Word16 L_subfr /* i : subframe lenght */ - ); - - void longadd( - UWord16 a[], /* i/o: vector of the length lena */ - const UWord16 b[], /* i/o: vector of the length lenb */ - const Word16 lena, /* i/o: length of vector a[] */ - const Word16 lenb /* i/o: length of vector b[] */ - ); - - void longshiftright( - UWord16 a[], /* i : vector of the length lena */ - const Word16 b, /* i : number of bit positions to shift right */ - UWord16 d[], /* o : vector of the length lend */ - Word16 lena, /* i : length of vector a[] */ - const Word16 lend /* i : length of vector d[] */ - ); - - void longshiftleft( - const UWord16 a[], /* i : vector of the length len */ - const Word16 b, /* i : number of bit positions to shift left */ - UWord16 d[], /* o : vector of the length len */ - const Word16 len /* i : length of vector a[] and d[] */ - ); - - void longshr( - UWord32 a[], - Word16 bits, - Word16 len ); - - void bands_and_bit_alloc_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : i signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - - void fine_gain_pred_fx( - const Word16 *sfm_start, /* i : Sub band start indices */ - const Word16 *sfm_end, /* i : Sub band end indices */ - const Word16 *sfm_size, /* i : Sub band bandwidths */ - const Word16 *i_sort, /* i : Energy sorting indices */ - const Word16 *K, /* i : Number of pulses per band */ - const Word16 *maxpulse, /* i : Maximum pulse per band */ - const Word16 *R, /* i : Bits per sub band Q3 */ - const Word16 num_sfm, /* i : Number of sub bands */ - Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ - Word16 *y, /* i/o: Quantized vector (int) */ - Word16 *fg_pred, /* o : Predicted fine gains Q12 */ - const Word16 core /* i : Core */ - ); - - void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order Q0 */ - const Word16 num_sfm, /* i : Number of bands Q0 */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ - Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ - const Word16 *gopt /* i : Optimal gains Q12 */ - ); - - void get_max_pulses_fx( - const Word16 *band_start, /* i : Sub band start indices */ - const Word16 *band_end, /* i : Sub band end indices */ - const Word16 *k_sort, /* i : Indices for sorting by energy */ - const Word16 *npulses, /* i : Pulses per sub band */ - const Word16 BANDS, /* i : Number of bands */ - Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ - Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ - ); - - void fine_gain_dec_fx( - Decoder_State *st, - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ - Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ - ); - - /* o : Number of assigned gain bits */ - Word16 assign_gain_bits_fx( - const Word16 core, /* i : HQ core */ - const Word16 BANDS, /* i : Number of bands */ - const Word16 *band_width, /* i : Sub band bandwidth */ - Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *gain_bits_array, /* o : Assigned gain bits */ - Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ - ); - - void freq_dnw_scaling_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 coder_type, /* i : coder type */ - const Word16 noise_lev, /* i : Noise level */ - const Word32 core_brate, /* i : Core bitrate */ - Word16 fy_norm[], /* i/o: Frequency quantized parameter */ - Word16 Qx, /* Q format of fy_norm*/ - const Word16 L_frame /* i : frame length */ - ); +/* o : tilt of the code */ +Word16 Est_tilt2( + const Word16 *exc, /* i : adaptive excitation vector Qx */ + const Word16 gain_pit, /* i : adaptive gain Q14 */ + const Word16 *code, /* i : algebraic exctitation vector Q9 */ + const Word32 gain_code, /* i : algebraic code gain Q16 */ + Word16 *voice_fac, /* o : voicing factor Q15 */ + const Word16 Q_exc /* i : Scaling factor of excitation Q0 */ +); + +void E_UTIL_voice_factor( + Word16 *exc, /* i : pointer to the excitation frame Q_new */ + Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* i : innovative codebook Q9 */ + Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 *voice_fac, /* o : subframe voicing estimation Q15 */ + Word16 *tilt_code, /* o : tilt factor Q15 */ + Word16 L_subfr, /* i : subframe length */ + Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/ + Word16 Q_new, /* i : excitation buffer format */ + Word16 shift /* i : scaling to get 12bit */ +); + +void sinq_fx( + const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/ + const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/ + const Word16 N, /* i : size of output */ + Word16 x[] /* o : output vector Q15*/ +); + +void window_ola_fx( + Word32 *ImdctOut, + Word16 *auOut, + Word16 *Q_sig, + Word16 *OldauOut, + Word16 *Q_old, + const Word16 L, + const Word16 right_mode, + const Word16 left_mode, + const Word16 old_bfi, + const Word16 oldHqVoicing, + Word16 *oldgapsynth ); + +void core_switching_OLA_fx( + Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */ + const Word16 last_L_frame, /* i : last L_frame lengthture */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */ + Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */ + Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */ + const Word16 output_frame, /* i : output frame length */ + const Word16 bwidth, /* i : output bandwidth */ + Word16 *Qsynth, + Word16 *Qsubfr ); + +void window_ola_ext_fx( + const Word32 *ImdstOut, /* i : input */ + Word32 *auOut, /* o : output audio */ + Word32 *OldauOut, /* i/o: audio from previous frame */ + const Word16 L, /* i : length */ + const Word16 right_mode, + const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const UWord16 kernel_type /* i : transform kernel type */ +); + +void cb_shape_fx( + const Word16 preemphFlag, /* i : flag for pre-emphasis */ + const Word16 pitchFlag, /* i : flag for pitch sharpening */ + const Word16 scramblingFlag, /* i : flag for phase scrambling */ + const Word16 sharpFlag, /* i : flag for formant sharpening */ + const Word16 formantTiltFlag, /* i : flag for formant tilt */ + const Word16 g1, /* i : formant sharpening numerator weighting */ + const Word16 g2, /* i : formant sharpening denominator weighting */ + const Word16 *p_Aq, /* i : LP filter coefficients */ + Word16 *code, /* i/o: signal to shape */ + const Word16 tilt_code, /* i : tilt of code */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */ + const Word16 shift, + const Word16 L_subfr /* i : subframe lenght */ +); + +void longadd( + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ +); + +void longshiftright( + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ +); + +void longshiftleft( + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ +); + +void longshr( + UWord32 a[], + Word16 bits, + Word16 len ); + +void bands_and_bit_alloc_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's i vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : i signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +void fine_gain_pred_fx( + const Word16 *sfm_start, /* i : Sub band start indices */ + const Word16 *sfm_end, /* i : Sub band end indices */ + const Word16 *sfm_size, /* i : Sub band bandwidths */ + const Word16 *i_sort, /* i : Energy sorting indices */ + const Word16 *K, /* i : Number of pulses per band */ + const Word16 *maxpulse, /* i : Maximum pulse per band */ + const Word16 *R, /* i : Bits per sub band Q3 */ + const Word16 num_sfm, /* i : Number of sub bands */ + Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/ + Word16 *y, /* i/o: Quantized vector (int) */ + Word16 *fg_pred, /* o : Predicted fine gains Q12 */ + const Word16 core /* i : Core */ +); + +void fine_gain_quant_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ + Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ + const Word16 *gopt /* i : Optimal gains Q12 */ +); + +void get_max_pulses_fx( + const Word16 *band_start, /* i : Sub band start indices */ + const Word16 *band_end, /* i : Sub band end indices */ + const Word16 *k_sort, /* i : Indices for sorting by energy */ + const Word16 *npulses, /* i : Pulses per sub band */ + const Word16 BANDS, /* i : Number of bands */ + Word16 *inp_vector, /* i/o: Encoded shape vectors (int)Q0*/ + Word16 *maxpulse /* o : Maximum pulse height per band Q0*/ +); + +void fine_gain_dec_fx( + Decoder_State *st, + const Word16 *ord, /* i : Indices for energy order */ + const Word16 num_sfm, /* i : Number of bands */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + Word16 *fg_pred /* i/o: Predicted gains / Corrected gains Q12*/ +); + +/* o : Number of assigned gain bits */ +Word16 assign_gain_bits_fx( + const Word16 core, /* i : HQ core */ + const Word16 BANDS, /* i : Number of bands */ + const Word16 *band_width, /* i : Sub band bandwidth */ + Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *gain_bits_array, /* o : Assigned gain bits */ + Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ +); + +void freq_dnw_scaling_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 coder_type, /* i : coder type */ + const Word16 noise_lev, /* i : Noise level */ + const Word32 core_brate, /* i : Core bitrate */ + Word16 fy_norm[], /* i/o: Frequency quantized parameter */ + Word16 Qx, /* Q format of fy_norm*/ + const Word16 L_frame /* i : frame length */ +); #ifndef FIX_1904_HARM_GSC_ENC - void highband_exc_dct_in_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 *mfreq_bindiv, /* i : bin per bands tables */ - Word16 last_bin, /* i : last bin of bit allocation */ - Word16 Diff_len, /* i : number of bin before cut-off frequency */ - Word16 noise_lev, /* i : pulses dynamic */ - Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - Word16 *exc_diffQ, /* i : frequency coefficients of per band */ - Word16 *seed_tcx, /* i : Seed for noise */ - Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ - Word16 nb_subfr, /* i : Number of subframe considered */ - Word16 *exc_dct_in, /* o : dct of residual signal */ - Word16 last_coder_type, /* i : coding type of last frame */ - Word16 *bitallocation_band, /* i : bit allocation flag of each band */ - const Word16 *lsf_new, /* i : LSFs at the end of the frame */ - Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ - Word16 *last_ener, /* i : frequency energy of last frame */ - Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ - Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ - Word16 bfi, /* i : bad frame indicator */ - const Word16 coder_type, /* i : coder type */ - Word16 bwidth, - Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ - Word16 Qexc_diffQ, - Word16 Q_exc, - const Word16 GSC_noisy_speech, - Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - void highband_exc_dct_in_ivas_fx( - const Word32 core_brate, /* i : core bitrate */ - const Word16 *mfreq_bindiv, /* i : bin per bands tables */ - Word16 last_bin, /* i : last bin of bit allocation */ - Word16 Diff_len, /* i : number of bin before cut-off frequency */ - Word16 noise_lev, /* i : pulses dynamic */ - Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - Word16 *exc_diffQ, /* i : frequency coefficients of per band */ - Word16 *seed_tcx, /* i : Seed for noise */ - Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ - Word16 nb_subfr, /* i : Number of subframe considered */ - Word16 *exc_dct_in, /* o : dct of residual signal */ - Word16 last_coder_type, /* i : coding type of last frame */ - Word16 *bitallocation_band, /* i : bit allocation flag of each band */ - const Word16 *lsf_new, /* i : LSFs at the end of the frame */ - Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ - Word16 *last_ener, /* i : frequency energy of last frame */ - Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ - Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ - Word16 bfi, /* i : bad frame indicator */ - const Word16 coder_type, /* i : coder type */ - Word16 bwidth, - Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ - Word16 Qexc_diffQ, - Word16 *Q_exc, - const Word16 GSC_noisy_speech, - Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); -#else void highband_exc_dct_in_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 *mfreq_bindiv, /* i : bin per bands tables */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 Diff_len, /* i : number of bin before cut-off frequency */ + Word16 noise_lev, /* i : pulses dynamic */ + Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 *exc_diffQ, /* i : frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ + Word16 nb_subfr, /* i : Number of subframe considered */ + Word16 *exc_dct_in, /* o : dct of residual signal */ + Word16 last_coder_type, /* i : coding type of last frame */ + Word16 *bitallocation_band, /* i : bit allocation flag of each band */ + const Word16 *lsf_new, /* i : LSFs at the end of the frame */ + Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ + Word16 *last_ener, /* i : frequency energy of last frame */ + Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ + Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ + Word16 bfi, /* i : bad frame indicator */ + const Word16 coder_type, /* i : coder type */ + Word16 bwidth, + Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ + Word16 Qexc_diffQ, + Word16 Q_exc, + const Word16 GSC_noisy_speech, + Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); +void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ Word16 last_bin, /* i : last bin of bit allocation */ @@ -5156,6330 +5122,6359 @@ void highband_exc_dct_in_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); -#endif - - void lsf_dec_bfi( - const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ - Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ - const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ - Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ - const Word16 lsfBase[], /* i : base for differential lsf coding */ - Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ - Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ - const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ - Word16 L_frame, - const Word16 last_good, /*!< i : last good received frame */ - const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ - const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ - Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ - Word16 *lsf_cng, /* Q2.56 */ - Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ - const Word16 Last_GSC_pit_band_idx, - const Word16 Opt_AMR_WB, /* i : IO flag */ - const Word8 tcxonly, - const short bwidth /* i: coded bandwidth */ - ); - - Word16 const *PlcGetLsfBase( - Word16 const lpcQuantization, - Word16 const narrowBand, - Word32 const sr_core ); - - /* Create an instance of type FD_CNG */ - ivas_error createFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - - void initFdCngCom( - HANDLE_FD_CNG_COM hFdCngCom, - Word16 scale ); - - /* Delete the instance of type FD_CNG */ - void deleteFdCngCom_fx( - HANDLE_FD_CNG_COM *hFdCngCom ); - - /* Initialize the spectral partitioning */ - void initPartitions( - const Word16 *part_in, - const Word16 npart_in, - const Word16 startBand, - const Word16 stopBand, - Word16 *part_out, - Word16 *npart_out, - Word16 *midband, - Word16 *psize, - Word16 *psize_norm, - Word16 *psize_norm_exp, - Word16 *psize_inv, - const Word16 stopBandFR ); - - /* Noise estimation using Minimum Statistics (MS) */ - void compress_range( - Word32 *in, - Word16 in_exp, - Word16 *out, - const Word16 len ); - - void expand_range( - Word16 *in, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - - void expand_range_fx( - Word32 *in, // Q25 - Word32 *out, // exp:out_exp - Word16 *out_exp, - const Word16 len ); - - void expand_range_var_exp( - Word16 *in, - Word16 in_exp, - Word32 *out, - Word16 *out_exp, - const Word16 len ); - - void minimum_statistics( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ - ); - - void minimum_statistics_fx( - Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ - Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ - Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ - Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ - Word32 *msAlpha, /* i/o: Forgetting factors */ - Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ - Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ - Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ - Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ - Word32 *msBminWin, /* o : Bias correction factors */ - Word32 *msBminSubWin, /* o : Bias correction factors */ - Word32 *msCurrentMin, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ - Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ - Word16 *msLocalMinFlag, /* i : Binary flag */ - Word16 *msNewMinFlag, /* i : Binary flag */ - Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ - Word16 *msPeriodogBufPtr, /* i/o: Counter */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 enc_dec, /* i : encoder/decoder indicator */ - const Word16 element_mode /* i : IVAS element mode type */ - ); - - /* Apply bitrate-dependant scale */ - void apply_scale( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ - ); - - Word16 apply_scale_ind( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize /* i : Size of scale table */ - ); - void apply_scale_ivas_fx( - Word32 *scale, /* o : scalefactor */ - const Word16 bwmode, /* i : audio bandwidth */ - const Word32 bitrate, /* i : Bit rate */ - const SCALE_SETUP *scaleTable, /* i : Scale table */ - const Word16 scaleTableSize, /* i : Size of scale table */ - Word16 *index ); - - /* Compute the power for each partition */ - void bandcombinepow( - const Word32 *bandpow, /* i : Power for each band */ - const Word16 exp_bandpow, /* i : exponent of bandpow */ - const Word16 nband, /* i : Number of bands */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - const Word16 *psize_inv, /* i : Inverse partition sizes */ - Word32 *partpow, /* o : Power for each partition */ - Word16 *exp_partpow ); - - /* Scale partitions (with smoothing) */ - void scalebands( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - - void scalebands_fx( - const Word32 *partpow, /* i : Power for each partition */ - Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ - const Word16 npart, /* i : Number of partitions */ - Word16 *midband, /* i : Central band of each partition */ - const Word16 nFFTpart, /* i : Number of FFT partitions */ - const Word16 nband, /* i : Number of bands */ - Word32 *bandpow, /* o : Power for each band */ - const Word16 flag_fft_en ); - - /* STFT analysis filterbank */ - void AnalysisSTFT( - const Word16 *timeDomainInput, /* i : pointer to time signal */ - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - void AnalysisSTFT_fx( - const Word16 *timeDomainInput, - Word16 Q, - Word32 *fftBuffer, /* o : FFT bins */ - Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - /* STFT synthesis filterbank */ - void SynthesisSTFT( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void SynthesisSTFT_ivas_fx( - Word32 *fftBuffer, /* i : pointer to FFT bins */ - Word16 fftBufferExp, /* i : exponent of FFT bins */ - Word16 *timeDomainOutput, /* o : pointer to time domain signal */ - Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ - const PWord16 *olapWin, /* i : pointer to overlap window */ - Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ - Word16 gen_exc, - Word16 *Q_new, - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - Word32 sign_l( - const Word32 x /* i : input value of x */ - ); - - void ivas_updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word32 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ - ); - - /* Random generator with Gaussian distribution with mean 0 and std 1 */ - Word32 rand_gauss( - Word16 *seed ); - - Word16 rand_gauss_fix( - Word16 *x, - Word16 *seed ); - - void lpc_from_spectrum( - HANDLE_FD_CNG_COM hFdCngCom, - const Word16 start, /*i : start band*/ - const Word16 stop, /*i : stop band*/ - const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ - ); - - void msvq_decoder( - const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook vector dimension */ - const Word16 Idx[], /* i : Indices */ - Word16 *uq /* o : quantized vector */ - ); - - void FdCng_exc( - HANDLE_FD_CNG_COM hs, - Word16 *CNG_mode, - Word16 L_frame, - Word16 *lsp_old, - Word16 first_CNG, - Word16 *lsp_CNG, - Word16 *Aq, /* o: LPC coeffs */ - Word16 *lsp_new, /* o: lsp */ - Word16 *lsf_new, /* o: lsf */ - Word16 *exc, /* o: LP excitation */ - Word16 *exc2, /* o: LP excitation */ - Word16 *bwe_exc /* o: LP excitation for BWE */ - ); - - void direct_transform_fx( - const Word32 in32_fx[], - Word32 out32_fx[], - const Word16 is_transient, - const Word16 L, - Word16 *Q, - const Word16 element_mode ); - - void preecho_sb_fx( - const Word32 brate, /* i Q0 : core bit-rate */ - Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ - Word16 q_sig32, /* i Q value for wtda_audio_fx */ - Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ - Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ - const Word16 framelength, /* i Q0 : frame length */ - Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ - Word16 *smoothmem_fx, /* i/o Q15 : memory */ - Word32 *mean_prev_fx, /* i/o Q0 : memory */ - Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ - Word16 *wmold_hb_fx, /* i/o Q15 : memory */ - Word16 *prevflag, /* i/o Q0 : flag */ - Word16 *pastpre, /* i/o Q0 : flag */ - const Word16 bwidth /* i Q0 : bandwidth */ - ); - - void Inverse_Transform( - const Word32 *in_mdct, /* i : i MDCT vector */ - Word16 *Q, /* i/o: Q value of i */ - Word32 *out, /* o : output vector */ - const Word16 is_transient, /* i : transient flag */ - const Word16 L, /* i : output frame length */ - const Word16 L_inner, /* i : length of the transform */ - const Word16 element_mode /* i : IVAS element mode */ - ); - - void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ - Word16 *ynrm, /* o : recovered quantization indices Q0*/ - Word16 *normqlg2, /* o : recovered quantized norms Q0*/ - const Word16 nb_sfm /* i : number of SFMs Q0*/ - ); - - Word32 ar_div( Word32 num, Word32 denum ); - - void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); - void ar_encoder_done_fx( PARCODEC arInst ); - void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); - void ar_decoder_done_fx( PARCODEC arInst ); - Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); - - void TCQLSB_fx( - Word16 bcount, - Word32 *abuffer_fx, - Word16 *mbuffer_fx, - Word32 *sbuffer_fx, - Word16 *dpath ); - - void TCQLSBdec_fx( - Word16 *dpath, - Word16 *mbuffer, - Word16 bcount ); - - void RestoreTCQ_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - - void RestoreTCQdec_fx( - Word16 *magn, - Word16 size, - Word16 *bcount, - Word16 *mbuffer ); - - void InitLSBTCQ_fx( - Word16 *bcount ); - - void SaveTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - - void LoadTCQdata_fx( - PARCODEC arInst, - Word16 *dpath, - Word16 bcount ); - - Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); - Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); - Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); - - Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); - - void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); - void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); - void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); - void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); - - Word16 GetScale_fx( - Word16 blen, - Word32 bits_fx, - Word32 *surplus_fx ); - - void srt_vec_ind_fx( - const Word32 *linear, - Word32 *srt, - Word16 *I, - Word16 length ); - - void fill_spectrum_fx( - Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ - Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ - const Word16 *R, /* i : number of pulses per band Q0 */ - const Word16 is_transient, /* i : transient flag Q0 */ - Word16 norm[], /* i : quantization indices for norms Q0 */ - const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ - const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ - const Word16 nf_idx, /* i : noise fill index Q0 */ - const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ - const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ - Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ - Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ - Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ - const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ - const Word16 core_sfm, /* i : index of the end band for core Q0 */ - const Word16 HQ_mode, /* i : HQ mode Q0 */ - Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ - const Word32 L_core_brate, /* i : target bit-rate Q0 */ - Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ - Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ - Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ - const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ - const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ - const Word16 *npulses, /* i : number of pulses per band Q0 */ - const Word16 prev_is_transient, /* i : previous transient flag Q0 */ - Word32 *prev_normq, /* i/o: previous norms Q14 */ - Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ - const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ - const Word16 *sfmsize, /* i : Length of bands Q0 */ - const Word16 *sfm_start, /* i : Start of bands Q0 */ - const Word16 *sfm_end, /* i : End of bands Q0 */ - Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ - const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ - const Word16 num_sfm, /* i : Total number of bands Q0 */ - Word16 *prev_env_Q, - const Word16 num_env_bands, - const Word16 element_mode ); - - void hq_bit_allocation_fx( - const Word32 core_brate, /* i : Core bit-rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - const Word16 hqswb_clas, /* i : HQ class Q0 */ - Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ - const Word16 *normqlg2, /* i : Quantized norms Q0 */ - const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ - const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ - Word16 *noise_level, /* o : HVQ noise level Q15 */ - Word16 *R, /* o : Bit allocation per sub band Q0 */ - Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ - Word16 *sum, /* o : Sum of allocated shape bits Q0 */ - Word16 *core_sfm, /* o : Last coded band in core Q0 */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ - ); - - void map_quant_weight_fx( - const Word16 normqlg2[], /* i : quantized norms Q0*/ - Word16 wnorm[], /* o : weighted norm Q0*/ - const Word16 is_transient /* i : transient flag Q0*/ - ); - - void bitalloc_fx( - Word16 *y, /* i : reordered norm of sub-vectors Q0 */ - Word16 *idx, /* i : reordered sub-vector indices Q0 */ - Word16 sum, /* i : number of available bits Q0 */ - Word16 N, /* i : number of norms Q0 */ - Word16 K, /* i : maximum number of bits per dimension Q0 */ - Word16 *r, /* o : bit-allacation vector Q0 */ - const Word16 *sfmsize, /* i : band length Q0 */ - const Word16 hqswb_clas /* i : signal classification flag Q0 */ - ); - - Word16 BitAllocF_fx( - Word16 *y, /* i : norm of sub-vectors :Q0 */ - Word32 bit_rate, /* i : bitrate :Q0 */ - Word16 B, /* i : number of available bits :Q0 */ - Word16 N, /* i : number of sub-vectors :Q0 */ - Word16 *R, /* o : bit-allocation indicator :Q0 */ - Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ - const Word16 hqswb_clas, /* i : hq swb class */ - const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ - ); - - Word16 BitAllocWB_fx( - Word16 *y, /* i : norm of sub-vectors Q0*/ - Word16 B, /* i : number of available bits Q0*/ - Word16 N, /* i : number of sub-vectors Q0*/ - Word16 *R, /* o : bit-allocation indicator Q0*/ - Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ - ); - - void bitallocsum_fx( - Word16 *R, /* i : bit-allocation vector Q0 */ - const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ - Word16 *sum, /* o : total number of bits allocated Q0 */ - Word16 *Rsubband, /* o : rate per subband Q3 */ - const Word16 num_bits, /* i : number of bits Q0 */ - const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ - const Word16 *sfmsize /* i : band length Q0 */ - ); - - Word16 stab_est_fx( - Word16 etot, /* i : Total energy of the current frame Q8*/ - Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ - Word16 *mem_etot, /* i/o : Total energy memory Q8*/ - Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ - Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ - Word16 *thresh, /* i/o : Detection thresold Q11*/ - Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ - const Word16 vad_flag /* i : VAD flag */ - ); - - void enhancer_fx( - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ - ); - - void enhancer_ivas_fx( - const Word16 codec_mode, /* i : flag indicating Codec Mode */ - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 cbk_index, /* i : */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 coder_type, /* i : coder type */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ - ); - - Word16 E_UTIL_enhancer( - Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - Word16 stab_fac, /* i : LP filter stability measure Q15 */ - Word32 gain_code, /* i : innovative cb. gain 15Q16 */ - Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ - Word16 *code, /* i/o: innovation(in: Q9) code_exp */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ - Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ - Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ - Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ - Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ - Word16 coder_type, /* i : coder type */ - Word16 cdk_index, /* i : */ - Word16 L_subfr, /* i : */ - Word16 L_frame, /* i : frame size */ - Word16 Q_new ); - - void phase_dispersion( - const Word32 gain_code, /* i : gain of code 15Q16 */ - const Word16 gain_pit, /* i : gain of pitch Q14 */ - Word16 code[], /* i/o: code vector */ - Word16 *code_e, /* i/o: exponent of code */ - const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ - Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ - Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ - Word16 *prev_state, /* i/o: static memory Q0 */ - Word16 L_subfr /* i : subframe length [40,64] */ - ); - - void tcx_ltp_get_lpc( - Word16 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word16 *A, /* Qx */ - const Word16 order /* Q0 */ - ); - - void tcx_ltp_get_lpc_fx( - Word32 *x, /* Qx */ - const Word16 L, /* Q0 */ - Word32 *A, /* Qx */ - const Word16 order /* Q0 */ - ); - - void predict_signal( - const Word16 excI[], /* i : input excitation buffer Qx*/ - Word16 excO[], /* o : output excitation buffer Qx*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i : fraction of lag Q0*/ - const Word16 frac_max, /* i : max fraction Q0*/ - const Word16 L_subfr /* i : subframe size Q0*/ - ); - - Word16 tcx_ltp_decode_params( - Word16 *ltp_param, /* Q0 */ - Word16 *pitch_int, /* Q0 */ - Word16 *pitch_fr, /* Q0 */ - Word16 *gain, /* Q13 */ - const Word16 pitmin, /* Q0 */ - const Word16 pitfr1, /* Q0 */ - const Word16 pitfr2, /* Q0 */ - const Word16 pitmax, /* Q0 */ - const Word16 pitres /* Q0 */ - ); - - void tcx_ltp_post_fx( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word16 *sig, /* Qx */ - Word16 *tcx_buf /* Qx */ - ); - - void tcx_ltp_post_fx32( - Decoder_State *st, - TCX_LTP_DEC_HANDLE hTcxLtpDec, - Word16 core, /* Q0 */ - Word16 output_frame, /* Q0 */ - Word16 delay, /* Q0 */ - Word32 *sig, /* sig_q */ - Word32 *tcx_buf, /* sig_q */ - Word16 sig_q ); - - void Inac_switch_ematch_fx( - Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ - Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ - const Word16 coder_type, /* i : Coding mode */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 L_frame, /* i : Frame lenght */ - const Word16 Q_exc, /* i : input and output format of exc2 */ - const Word16 bfi, /* i : frame lost indicator */ - const Word16 last_core, /* i : Last core used */ - const Word16 last_codec_mode, /* i : Last codec mode */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 element_mode /* i : element mode */ - ); - - /**< out: Q0 | multiplication factor */ - Word16 IGF_ApplyTransFac( - const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ - const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ - ); - - Word16 IGF_MapBitRateToIndex( - const Word32 brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void IGFCommonFuncsCalcSfbEnergyPowerSpec( - const Word16 startSfb, /**< in: Q0 | start sfb index */ - const Word16 stopSfb, /**< in: Q0 | stop sfb index */ - const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ - Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ - Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ - Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ - Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ - ); - - void IGFCommonFuncsMDCTSquareSpec( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ - ); - - void IGFCommonFuncsMDCTSquareSpec_ivas( - const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ - const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ - const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ - const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ - Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ - Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ - Word16 indexOffset /**< in: Q0 | index offset */ - ); - - Word16 IGFCommonFuncsIGFConfiguration( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - H_IGF_INFO hIGFInfo, /* o : IGF info handle */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - Word16 IGFCommonFuncsIGFGetCFTables_fx( - const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : element mode */ - const Word16 rf_mode, /* i : flag to signal the RF mode */ - const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ - const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ - Word16 *cf_off_se01, /* o : offset for CF table above */ - const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ - const Word16 **cf_off_se02, /* o : offsets for CF tables above */ - const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ - Word16 *cf_off_se10, /* o : offset for CF table above */ - const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ - const Word16 **cf_off_se11 /* o : offsets for CF tables above */ - ); - - Word32 L_multi31x16_X2( - Word16 xh, - Word16 xl, - Word16 y ); - - Word32 mul_sbc_14bits( - Word32 r, /* Q0 */ - Word16 c /* Q0 */ - ); - - void ham_cos_window( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - - void ham_cos_window_ivas( - Word16 *fh, - const Word16 n1, - const Word16 n2 ); - - /* o: Q31 */ - Word32 expfp( - const Word16 x, /* i: mantissa Q-e */ - const Word16 x_e ); /* i: exponent Q0 */ - - void powfp_odd2( - const Word16 base, /* Q15 */ - const Word16 exp, /* Q0 */ - Word16 *pout1, /* Q15 */ - Word16 *pout2 ); /* Q15 */ - - void tcx_arith_scale_envelope( - const Word16 L_spec_core, /* i: number of lines to scale Q0 */ - Word16 L_frame, /* i: number of lines Q0 */ - const Word32 env[], /* i: unscaled envelope Q16 */ - Word16 target_bits, /* i: number of available bits Q0 */ - const Word16 low_complexity, /* i: low-complexity flag Q0 */ - Word16 s_env[], /* o: scaled envelope Q15-e */ - Word16 *s_env_e /* o: scaled envelope exponent Q0 */ - ); - - void tcx_arith_render_envelope( - const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i: number of spectral lines Q0*/ - const Word16 L_spec, /* Q0 */ - const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o: shaped signal envelope Q16*/ - ); - - /* returns innovation gain Q16 */ - Word32 calc_gain_inov( - const Word16 *code, /* i : algebraic excitation Q9 */ - const Word16 lcode, /* i : Subframe size Q0 */ - Word32 *dotp, /* o : intermediate result Q31-e */ - Word16 *dotp_e /* o : intermediate result exponent Q0 */ - ); - - /////////////////////////////////// - /* Lib_dec */ - ////////////////////////////////// - - void ResetSHBbuffer_Dec_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl /* i : BWE extension layer */ - ); - - void wb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ - const Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ - Word16 *Q_synth ); - - void swb_tbe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ - Word16 Q_exc, - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ - Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ - Word16 *Q_white_exc, - Word16 *synth, /* o : SHB synthesis/final synthesis */ - Word16 *Q_synth, - Word16 *pitch_buf ); - - void ivas_dequantizeSHBparams_fx_9_1( - Decoder_State *st_fx, - const Word16 extl, /* i : extension layer */ - Word32 extl_brate, /* i : extensiuon layer bitrate */ - Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ - Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ - Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ - Word16 *uv_flag, /* o : unvoiced flag*/ - Word32 *Q_shb_ener_sf, /* o : Q15 */ - Word16 *Q_shb_res_gshape, /* o : Q14 */ - Word16 *Q_mixFactors, /* o : Q15 */ - Word16 *MSFlag ); - - void fb_tbe_dec_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word16 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp ); - - void fb_tbe_dec_ivas_fx( - Decoder_State *st, /* i/o: encoder state structure */ - const Word16 fb_exc[], /* i : FB excitation from the SWB part */ - Word16 Q_fb_exc, - Word32 *hb_synth, /* o : high-band synthesis */ - Word16 hb_synth_exp, - Word16 *fb_synth_ref, - Word16 Q_fb_synth_ref, - Word16 output_frame ); - - void tbe_read_bitstream_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ - ); - - void GenTransition_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ - const Word32 output_Fs, /* i : output sampling rate */ - Word16 rf_flag, /* i : RF flag */ - Word32 total_bitrate /* i : total bitrate */ - ); - - void GenTransition_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs, /* i : output sampling rate : Q0 */ - const Word16 L_frame, /* i : ACELP frame length : Q0 */ - const Word16 prev_Qx ); - - void GenTransition_WB_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word16 *output, /* o : synthesized transitions signal */ - const Word32 output_Fs /* i : output sampling rate */ - ); - - void GenTransition_WB_fx32( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ - const Word32 output_Fs /* i : output sampling rate */ - ); - - void TBEreset_dec_fx( - Decoder_State *st_fx /* i/o: decoder state structure */ - ); - - void td_bwe_dec_init_fx( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word16 extl, /* i : BWE extension layer */ - const Word32 output_Fs /* i : output sampling rate */ - ); - - void lsf_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ - ); - - /*! r: index of the maximum value in the input vector */ - Word16 maximum_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /*! r: index of the minimum value in the input vector */ - Word16 minimum_l( - const Word32 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word32 *min_val /* o : minimum value in the input vector */ - ); - - void v_multc_fx( - const Word32 x[], /* i : Input vector */ - const Word32 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_fx_16( - const Word32 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word32 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_fx_16_16( - const Word16 x[], /* i : Input vector */ - const Word16 c, /* i : Constant */ - Word16 y[], /* o : Output vector that contains c*x */ - const Word16 N /* i : Vector length */ - ); - - void v_add_fx_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_add_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_add_fx_me( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x1_e, /* i : Exponent for input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - const Word16 x2_e, /* i : Exponent for input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 *y_e, /* i : Exponent for output vector */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_add_w64( - const Word64 x1[], /* i : Input vector 1 */ - const Word64 x2[], /* i : Input vector 2 */ - Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_sub_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N, /* i : Vector length */ - const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ - ); - - void v_sub_fx_no_hdrm( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - /*! r: dot product of x[] and y[] */ - Word32 dotp_fx32( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ - ); - - /*! r: dot product of x[] and y[] in case of overflow*/ - Word32 dotp_fx32_o( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q ); - - Word32 dotp_fx32_fac( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ - Word16 *res_q /*stores resultant Q*/ - ); - - Word32 dotp_fx_ivas_fx( - const Word32 x[], /* i : vector x[] */ - Word16 x_e, - const Word32 y[], /* i : vector y[] */ - Word16 y_e, - const Word16 n, /* i : vector length */ - Word16 *out_e ); - - Word32 dotp_fx_guarded( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n /* i : vector length */ - ); - - Word32 dotp_me_fx( - const Word32 x[], /* i : vector x[] */ - const Word32 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 exp_x, - Word16 exp_y, - Word16 *exp_suma ); - - void lsf_end_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 mode2_flag, /* Q0 */ - const Word16 coder_type_org, /* i : coding type Q0*/ - const Word16 bwidth, /* i : input signal bandwidth Q0*/ - const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ - Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ - Word16 *lpc_param, /* i : LPC parameters Q0*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices, /* o : number of indices Q0*/ - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ - ); - - void lsf_mid_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ - Word16 coder_type, /* i : Coder type Q0*/ - Word16 lsp_mid[] /* o : quantized LSPs Q15*/ - ); - - void CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ - Word16 Aq[], /* o : LP coefficients Q12 */ - Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ - Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ - Word32 *q_env ); - - void swb_CNG_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ - ); - - void swb_CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ - Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ - const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ - const Word16 Qsyn /* i : Q value of ACELP core synthesis */ - ); - - void td_cng_dec_init_fx( - DEC_CORE_HANDLE st /* i/o: decoder state structure */ - ); - - void set_state( - Word16 *state, - Word16 num, - Word16 N ); - - void concealment_init_x( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - - void concealment_init_ivas_fx( - const Word16 L_frameTCX, - T_PLCInfo_HANDLE hPlcInfo ); - - void concealment_update_x( - const Word16 bfi, - const Word16 core, - const Word16 tonality, - Word32 *invkoef /*Qinvkoef_scale*/, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - - Word16 Sqrt_x_fast( - Word32 value ); - - Word32 dot_w32_accuracy_x( - Word16 *s1, - Word16 *s2, - Word16 nbits, - Word16 N ); - - Word16 int_div_s_x( - Word16 a, - Word16 b ); - - Word16 GetW32Norm_x( - Word32 *s, - Word16 N ); - - Word16 harmo_x( - Word32 *X, - Word16 Framesize, - Word16 pitch ); - - void LpFilter2_x( - Word16 *x, - Word16 *y, - Word16 N ); - - void sig_tilt_x( - Word16 *s, - Word16 FrameSize, - Word32 *enr1, - Word32 *enr2 ); - - void get_maxConv_and_pitch_x( - Word16 *s_LP, - Word16 s, - Word16 e, - Word16 N, - Word32 *maxConv, - Word16 *maxConv_bits, - Word16 *pitch ); - - Word16 get_voicing_x( - Word16 *s_LP, - Word16 pitch, - Word32 covMax, - Word16 maxConv_bits, - Word16 Framesize ); - - void pitch_modify_x( - Word16 *s_LP, - Word16 *voicing, - Word16 *pitch, - Word16 FrameSize ); - - Word16 Is_Periodic_x( - Word32 *mdct_data, - Word16 cov_max, - Word16 zp, - Word32 ener, - Word32 ener_mean, - Word16 pitch, - Word16 Framesize ); - - Word16 get_conv_relation_x( - Word16 *s_LP, - Word16 shift, - Word16 N ); - - void concealment_decode_fix( - Word16 curr_mode, - Word32 *invkoef, - Word16 *invkoef_scale, - T_PLCInfo_HANDLE hPlcInfo ); - - Word32 Spl_Energy_x( - const Word16 *vector, - const Word16 vector_length, - Word16 *scale_factor ); - - void Log10OfEnergy_x( - const Word16 *s, - Word32 *enerlogval, - const Word16 len ); - - void concealment_update2_x( - const Word16 *outx_new, - T_PLCInfo_HANDLE hPlcInfo, - const Word16 FrameSize ); - - Word16 ffr_getSfWord16( - Word16 *vector, /*!< Pointer to i vector */ - Word16 len ); - - void waveform_adj2_fix( - T_PLCInfo_HANDLE hPlcInfo, - Word16 *overlapbuf, - Word16 *outx_new, - const Word16 delay, - const Word16 bfi_cnt, - const Word16 bfi ); - - void concealment_signal_tuning_fx( - Decoder_State *st, - const Word16 bfi, - Word16 *outx_new_fx /*Qoutx_new_fx*/, - const Word16 past_core ); - - void DetectTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - - void RefineTonalComponents( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode ); - - void ivas_RefineTonalComponents_fx( - Word16 indexOfTonalPeak[], - Word16 lowerIndex[], - Word16 upperIndex[], - Word16 phaseDiff[], - Word16 phases[], - Word16 *pNumIndexes, - const Word32 lastPitchLag, - const Word32 currentPitchLag, - const Word16 lastMDCTSpectrum[], - const Word16 lastMDCTSpectrum_exp, - const Word16 scaleFactors[], - const Word16 scaleFactors_exp[], - const Word16 scaleFactors_max_e, - const Word32 secondLastPowerSpectrum[], - const Word16 secondLastPowerSpectrum_e, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ - Word16 element_mode, - const PsychoacousticParameters *psychParamsCurrent ); - - ivas_error PsychoacousticParameters_Init( - const Word32 sr_core, /* i : sampling rate of core-coder */ - const Word16 nBins, /* i : Number of bins (spectral lines) */ - const Word8 nBands, /* i : Number of spectrum subbands */ - const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); - - ivas_error TonalMDCTConceal_Init( - TonalMDCTConcealPtr self, - const Word16 nSamples, - const Word16 nSamplesCore, - const Word16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ - ); - - ivas_error TonalMDCTConceal_Init_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const UWord16 nSamples, - const UWord16 nSamplesCore, - const UWord16 nScaleFactors, - TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ - ); - - /* Must be called only when a good frame is recieved - concealment is inactive */ - void TonalMDCTConceal_SaveFreqSignal( - TonalMDCTConcealPtr self, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - Word16 nNewSamples, - Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp ); - - void TonalMDCTConceal_SaveFreqSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - const Word32 *mdctSpectrum, - const Word16 mdctSpectrum_exp, - const Word16 nNewSamples, - const Word16 nNewSamplesCore, - const Word16 *scaleFactors, - const Word16 *scaleFactors_exp, - const Word16 gain_tcx_exp, - const Word16 infoIGFStartLine ); - - void TonalMDCTConceal_UpdateState( - TonalMDCTConcealPtr self, - Word16 nNewSamples, - Word32 pitchLag, - Word16 badBlock, - Word8 tonalConcealmentActive ); - - void TonalMDCTConceal_Detect( - const TonalMDCTConcealPtr self, /*IN */ - const Word32 pitchLag, /*IN */ - Word16 *umIndices, /*OUT*/ - Word16 element_mode /* IN */ - ); - - void TonalMDCTConceal_Apply( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 *mdctSpectrum_exp /*IN */ - ); - - void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ - Word16 mdctSpectrum_exp, /*IN */ - const PsychoacousticParameters *psychParamsCurrent ); - - void TonalMDCTConceal_InsertNoise_ivas_fx( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, - Word16 *mdctSpectrum_exp, - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - const Word16 crossfadeGain, - const Word32 concealment_noise[L_FRAME48k], - const Word16 concealment_noise_e, - const Word32 cngLevelBackgroundTrace_bfi, - const Word16 cngLevelBackgroundTrace_e, - const Word16 crossOverFreq ); - - void TonalMDCTConceal_InsertNoise( - const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*OUT*/ - Word16 *mdctSpectrum_exp, /*OUT*/ - const Word16 tonalConcealmentActive, - Word16 *pSeed, /*IN/OUT*/ - const Word16 tiltCompFactor, - Word16 crossfadeGain, - const Word16 crossOverFreq ); - - void TonalMDCTConceal_SaveTimeSignal( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 nNewSamples ); - - void TonalMDCTConceal_SaveTimeSignal_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, - Word16 *timeSignal, - Word16 q_timeSignal, - Word16 nNewSamples ); - - void decision_matrix_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ - Word16 *hq_core_type, /* o : HQ core type Q0 */ - Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ - ); - - void hf_synth_init_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ - ); - - void hf_synth_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ - ); - - void hf_synth_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ - ); - - void hf_synth_ivas_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ - Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ - Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ - ); - - void hf_synth_amr_wb_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ - ); - - void hf_synth_amr_wb_reset_fx( - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ - ); - - void hf_synth_amr_wb_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ - const Word32 core_brate, /* i : core bitrate Q0*/ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 *Aq, /* i : quantized Az : Q12*/ - const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ - Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ - Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ - Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ - Word16 fmerit, /* i : classify parameter from FEC : Q14*/ - const Word16 *hf_gain, /* i : decoded HF gain Q0*/ - const Word16 *voice_factors, /* i : voicing factors : Q15*/ - const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ - const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ - const Word16 *lsf_new, /* i : ISF vector : Q2*/ - const Word16 Q_exc, /* i : exc scaling */ - const Word16 Q_out /* i : Q_syn2-1 */ - ); - - void Init_post_filter_fx( - PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ - ); /* i : core decoder parameters */ - - void nb_post_filt_fx( - const Word16 L_frame, /* i : frame length */ - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *psf_lp_noise, /* i : Long term noise Q8 */ - const Word16 tmp_noise, /* i : noise energy Q0 */ - Word16 *Synth, /* i : 12k8 synthesis Qsyn */ - const Word16 *Aq, /* i : LP filter coefficient Q12 */ - const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ - const Word16 coder_type, /* i : coder_type */ - const Word16 BER_detect, /* i : BER detect flag */ - const Word16 disable_hpf /* i : flag to diabled HPF */ - ); - - void formant_post_filt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient Q12 */ - Word16 *synth_out, /* i/o: input signal */ - const Word16 L_frame, /* i : frame length */ - const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - const Word32 brate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ - ); - - void Filt_mu_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr /* i : the length of subframe */ - ); - - void Filt_mu_ivas_fx( - Word16 *sig_in, /* i : signal (beginning at sample -1) */ - Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ - Word16 L_subfr, /* i : the length of subframe */ - const Word16 extl ); - - void scale_st_fx( - const Word16 *sig_in, /* i : postfilter i signal */ - Word16 *sig_out, /* i/o: postfilter o signal */ - Word16 *gain_prec, /* i/o: last value of gain for subframe */ - Word16 L_subfr ); - - void blend_subfr2_fx( - Word16 *sigIn1, /* i : i signal for fade-out */ - Word16 *sigIn2, /* i : i signal for fade-in */ - Word16 *sigOut /* o : output signal */ - ); - - void init_tcx_window_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ - const Word32 sr_core, /* i : SR core */ - const Word32 input_Fs, /* i : input/output SR */ - const Word16 L_frame, /* i : L_frame at sr_core */ - const Word16 L_frameTCX, /* i : L_frame at i/o SR */ - const Word16 mdctWindowLength, /* i : window length at sr_core */ - const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ - const Word16 element_mode /* i : mode of CPE/SCE */ - ); - - void init_tcx_cfg_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, /*Q15*/ - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, - const Word16 fscaleFB ); - - void syn_output_fx( - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ - const Word16 output_frame, /* i : output frame length */ - Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ - const Word16 Q_syn2 /* i : Synthesis scaling factor */ - ); - - void unscale_AGC( - const Word16 x[], /* i: 16kHz synthesis Qx */ - const Word16 Qx, /* i: scale factor of x */ - Word16 y[], /* o: output vector Q0 */ - Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ - const Word16 n /* i: vector size */ - ); - - void bass_psfilter_init_fx( - BPF_DEC_HANDLE hBPF /* o : BPF data handle */ - ); - - void bass_psfilter_fx( - BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ - const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ - Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ - const Word16 L_frame, /* i : length of the last frame Q0*/ - Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ - const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ - Word16 v_stab_fx, /* i : stability factor Q15*/ - Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ - const Word16 coder_type, /* i : coder_type Q0*/ - Word16 Q_syn, - Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ - ); - - void addBassPostFilter_fx( - const Word16 *harm_timeIn_Fx, /* timeIn_e */ - Word32 **rAnalysis_Fx, /* Qx - 5 */ - Word32 **iAnalysis_Fx, /* Qx - 5 */ - HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, - Word32 *workBuffer, /* Qx */ - const Word16 timeIn_e, - const Word16 nTimeSlots, /* Q0 */ - const Word16 nTimeSlotsTotal, /* Q0 */ - const Word16 nBandsTotal, /* Q0 */ - CLDFB_SCALE_FACTOR *cldfb_scale ); - - void FEC_exc_estim_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* o : pointer to excitation buffer (with past) */ - Word16 *exc2, /* o : total excitation (for synthesis) */ - Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ - Word16 *pitch_buf, /* o : Floating pitch for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *tmp_tc, /* o : FEC pitch Q6 */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *Q_exc, - Word16 *tmp_noise /* o : long-term noise energy Q0 */ - ); - - void pitch_pred_linear_fit( - const Word16 bfi_cnt, /* i: bfi counter Q0 */ - const Word16 last_good, /* i: last classification type Q0 */ - Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ - Word32 *old_fpitch, /* i: Q16*/ - Word32 *T0_out, /* o: estimated close loop pitch Q16*/ - Word16 pit_min, /* i: Minimum pitch lag Q0 */ - Word16 pit_max, /* i: Maximum pitch lag Q0 */ - Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ - Word16 limitation, - Word16 plc_use_future_lag, /* i: Q0 */ - Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ - Word16 nb_subfr /* i: number of ACELP subframes */ - ); - - void get_subframe_pitch( - Word16 nSubframes, /* i: number of subframes Q0 */ - Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ - Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ - Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ - ); - - void PulseResynchronization_fx( - Word16 const *const src_exc, /*i Q15*/ - Word16 *const dst_exc, /*o Q15*/ - Word16 const nFrameLength, /*i Q0 */ - Word16 const nSubframes, /*i Q0 */ - Word32 const pitchStart, /*i Q16*/ - Word32 const pitchEnd /*i Q16*/ - ); - - void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ - ); - - void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ - Word16 *Q_exc ); - - void GSC_dec_init_fx( - GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ - ); - - void Es_pred_dec_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ - const Word16 enr_idx, /* i : indice */ - const Word16 nb_bits, /* i : number of bits */ - const Word16 no_ltp /* i : no LTP flag */ - ); - - void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ - ); - - void gain_dec_tc_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : pitch gain */ - Word32 *gain_code_fx, /* o : Quantized codeebook gain */ - Word16 *gain_inov_fx, /* o : unscaled innovation gain */ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ - ); - - void gain_dec_mless_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr_fx, /* i : subframe number */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *code_fx, /* i : algebraic code excitation */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ - ); - - void gain_dec_lbr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 *code_fx, /* i : algebraic excitation Q9 */ - Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes */ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ - const Word16 L_subfr /* i : subfr lenght */ - ); - -#ifndef CLEANUP_ACELP_ENC - void lp_gain_updt_fx( - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ - ); -#endif -#ifdef CLEANUP_ACELP_ENC - void lp_gain_updt_fx( - const Word16 element_mode, /* i : element mode */ -#else -void lp_gain_updt_ivas_fx( -#endif - const Word16 i_subfr, /* i : subframe number Q0 */ - const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ - const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ - Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ - Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ - const Word16 L_frame /* i : length of the frame */ - ); - - /*! r: quantized codebook gain Q16 */ - Word32 gain_dec_gaus_fx( - Word16 index, /* i : quantization index */ - const Word16 bits, /* i : number of bits to quantize */ - const Word16 lowBound, /* i : lower bound of quantizer (dB) */ - const Word16 topBound, /* i : upper bound of quantizer (dB) */ - const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ - ); - - void gain_dec_SQ_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 i_subfr, /* i : subframe number */ - const Word16 *code, /* i : algebraic code excitation Q9*/ - const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ - Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ - Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ - Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ - ); - - void gain_dec_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - Word16 *gain_pit, /* o : Quantized pitch gain */ - Word32 *gain_code, /* o : Quantized codeebook gain */ - Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ - Word16 *gain_inov, /* o : unscaled innovation gain */ - const Word16 *code, /* i : algebraic code excitation */ - Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ - ); - - void transf_cdbk_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ - const Word32 gain_code, /* i : innovative excitation gain (Q16) */ - Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ - Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ - Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ - Word16 *unbits /* o : number of AVQ unused bits */ - ); - - /* o: decoded gain */ - Word16 gain_dequant_fx( - Word16 index, /* i: quantization index */ - const Word16 min, /* i: value of lower limit */ - const Word16 max, /* i: value of upper limit */ - const Word16 bits, /* i: number of bits to dequantize */ - Word16 *expg ); - - void AVQ_demuxdec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ - Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ - const Word16 Nsv, /* i : number of subvectors Q0*/ - Word16 nq[], /* i/o: AVQ nq index Q0*/ - Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ - Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ - ); - - void AVQ_dec_lpc( - Word16 *indx, /* input: index[] (4 bits per words) Q0*/ - Word16 *nvecq, /* output: vector quantized Q0*/ - Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ - - void re8_dec_fx( - Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ - const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ - const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ - ); - - void re8_decode_base_index_fx( - const Word16 n, - UWord16 I, - Word16 *x ); - - void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ - ); - - void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ - Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ - ); - - void re8_PPV_fx( - const Word32 x[], /* i : point in R^8 Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ - ); - - void dec_pit_exc_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ - ); - - /* o: pitch value Q16 */ - Word32 Mode2_pit_decode( - const Word16 coder_type, /* i: coding model */ - Word16 i_subfr, /* i: subframe index */ - Word16 L_subfr, - Word16 **pt_indice, /* i/o: quantization indices pointer */ - Word16 *T0, /* i/o: close loop integer pitch Q0 */ - Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ - Word16 *T0_res, /* i/o: pitch resolution Q0 */ - Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ - Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ - Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr1b, - Word16 pit_fr2, - Word16 pit_max, - Word16 pit_res_max ); - - void Mode2_abs_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 *T0_res, /* o: pitch resolution Q0 */ - Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ - Word16 pit_min, - Word16 pit_fr1, - Word16 pit_fr2, - Word16 pit_res_max ); - - void Mode2_delta_pit_dec( - Word16 *T0, /* o: integer pitch lag Q0 */ - Word16 *T0_frac, /* o: pitch fraction Q0 */ - Word16 T0_res, /* i: pitch resolution Q0 */ - Word16 *T0_min, /* i: delta search min Q0 */ - Word16 *T0_min_frac, /* i: delta search min Q0 */ - Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ - ); - - /* o : floating pitch value */ - Word16 pit_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ - ); - - void pit_Q_dec_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 delta, /* i : Half the CL searched interval */ - const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ - ); - - void pit16k_Q_dec_fx( - const Word16 pitch_index, /* i : pitch index */ - const Word16 nBits, /* i : # of Q bits */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max, /* i/o: delta search max */ - Word16 *BER_detect /* o : BER detect flag */ - ); - - void abs_pit_dec_fx( - const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ - Word16 pitch_index, /* i: pitch index */ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - Word16 *T0, /* o: integer pitch lag */ - Word16 *T0_frac /* o: pitch fraction */ - ); - - void delta_pit_dec_fx( - const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ - const Word16 pitch_index, /* i : pitch index */ - Word16 *T0, /* o : integer pitch lag */ - Word16 *T0_frac, /* o : pitch fraction */ - const Word16 T0_min /* i : delta search min */ - ); - - void limit_T0_fx( - const Word16 L_frame, /* i : length of the frame */ - const Word16 delta, /* i : Half the close-loop searched interval */ - const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ - const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_max /* o : higher pitch limit */ - ); - - void limit_T0_voiced( - const Word16 nbits, - const Word16 res, - const Word16 T0, /* i : rough pitch estimate around which the search is done */ - const Word16 T0_frac, /* i : pitch estimate fractional part */ - const Word16 T0_res, /* i : pitch resolution */ - Word16 *T0_min, /* o : lower pitch limit */ - Word16 *T0_min_frac, /* o : lower pitch limit */ - Word16 *T0_max, /* o : higher pitch limit */ - Word16 *T0_max_frac, /* o : higher pitch limit */ - const Word16 pit_min, /* i : Minimum pitch lag */ - const Word16 pit_max /* i : Maximum pitch lag */ - ); - - void inov_decode_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ - ); - - void inov_decode_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate Q0 */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ - const Word16 L_frame, /* i : length of the frame Q0 */ - const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ - const Word16 i_subfr, /* i : subframe index Q0 */ - const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ - const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ - const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ - Word16 *code, /* o : algebraic excitation Q12 */ - const Word16 L_subfr /* i : subframe length Q0 */ - ); - - void dec_acelp_4t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 nbbits, /* i : number of bits per codebook */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ - const Word16 Opt_AMR_WB ); - - void D_ACELP_decode_43bit_fx( - UWord16 idxs[], - Word16 code[], - Word16 *pulsestrack ); - - void D_ACELP_indexing_fx( - Word16 code[], - PulseConfig config, - Word16 num_tracks, - Word16 index[], - Word16 *BER_detect ); - - void fcb_pulse_track_joint_decode_fx( - UWord16 *idxs, - Word16 wordcnt, - UWord32 *index_n, - Word16 *pulse_num, - Word16 track_num ); - - void dec_acelp_2t32_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[] /* o: algebraic (fixed) codebook excitation */ - ); - - void dec_acelp_1t64_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ - const Word16 L_subfr /* i : sub frame lenght*/ - ); - - ivas_error acelp_core_switch_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ - Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ - const Word16 output_frame, /* i : input frame length */ - const Word16 core_switching_flag, /* i : core switching flag */ - Word16 *mem_synth, /* o : synthesis to overlap */ - Word16 *Q_syn ); - - ivas_error acelp_core_switch_dec_bfi_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ - ); - - ivas_error acelp_core_switch_dec_bfi_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 synth_out[], /* o : synthesis Q_syn */ - const Word16 coder_type /* i : coder type */ - ); - - void pred_lt4( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ - ); - - void pred_lt4_ivas_fx( - const Word16 excI[], /* in : excitation buffer Q_exc*/ - Word16 excO[], /* out: excitation buffer Q_exc*/ - const Word16 T0, /* input : integer pitch lag Q0*/ - Word16 frac, /* input : fraction of lag Q0*/ - const Word16 L_subfr, /* input : subframe size Q0*/ - const Word32 *win, /* i : interpolation window Q31*/ - const Word16 nb_coef, /* i : nb of filter coef Q0*/ - const Word16 up_sample /* i : up_sample Q0*/ - ); - - void pred_lt4_tc_fx( - Word16 exc[], /* i/o: excitation buffer Q0*/ - const Word16 T0, /* i : integer pitch lag Q0*/ - Word16 frac, /* i: fraction of lag Q0*/ - const Word16 *win, /* i : interpolation window Q14*/ - const Word16 imp_pos, /* i : glottal impulse position Q0*/ - const Word16 i_subfr /* i : subframe index Q0*/ - ); - - void pvq_decode_frame_fx( - Decoder_State *st_fx, - Word16 *coefs_quant, /* o : quantized coefficients */ - Word16 *npulses, /* o : number of pulses per band */ - Word16 *pulse_vector, /* o : non-normalized pulse shapes */ - const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ - const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ - const Word16 *sfmsize, /* i : band sizes */ - const Word16 nb_sfm, /* i : total number of bands */ - const Word16 *R, /* i : bitallocation per band */ - const Word16 pvq_bits, /* i : number of bits avaiable */ - const Word16 core /* i : core */ - ); - - Word16 pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - - Word16 ivas_pvq_core_dec_fx( - Decoder_State *st_fx, - const Word16 *sfm_start, - const Word16 *sfm_end, - const Word16 *sfmsize, - Word16 coefs_quant[], /* o : output MDCT */ - Word16 *Q_coefs, - Word16 bits_tot, - Word16 nb_sfm, - Word16 *R, /* Q3 */ - Word16 *Rs, - Word16 *npulses, - Word16 *maxpulse, - const Word16 core ); - - void decode_energies_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 Np, - Word16 *dim_part, - Word16 *bits_part, - Word16 *g_part, /* Q15 */ - Word16 qband, - Word16 *bits_left, - Word16 dim, - const Word16 strict_bits ); - - void rc_dec_init_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 tot_bits /* i : Total bit budget */ - ); - - /* o : Decoded cumulative frequency */ - UWord32 rc_decode_fx( - Word16 *BER_detect, /* o : Bit error detection flag */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Total cumulative frequency */ - ); - - void rc_dec_update_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - - UWord32 cum_freq, /* i : Cumulative frequency */ - UWord32 sym_freq /* i : Symbol frequency */ - ); - - /* o : Decoded value */ - Word32 rc_dec_bits_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 bits /* i : Number of bits */ - ); - - /* o : Decoded value */ - UWord32 rc_dec_uniform_fx( - Decoder_State *st_fx, /* i/o: Decoder State */ - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - UWord32 tot /* i : Maximum value */ - ); - - void rc_dec_finish_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ - ); - - void pvq_decode_fx( - Decoder_State *st_fx, - PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ - Word16 *xq, /* o: decoded vector (Q15) */ - Word16 *y, /* o: decoded vector (non-scaled int) */ - const Word16 k_val, /* i: number of allocated pulses */ - const Word16 dim, /* i: Length of vector */ - const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ - ); - void nelp_decoder_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ - Word16 *exc, /* o : adapt. excitation exc Q_exc */ - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate Q0 */ - const Word16 coder_type, /* i : coding type Q0 */ - Word16 *gain_buf /* Q14 */ - ); - - void decod_nelp_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ - Word16 *exc_fx, /* o : adapt. excitation exc */ - Word16 *exc2_fx, /* o : adapt. excitation/total exc */ - Word16 *voice_factors, /* o : Voice factor */ - Word16 *bwe_exc, - Word16 *Q_exc, - Word16 bfi, /* i : frame error rate */ - Word16 *gain_buf /*Q14*/ - ); - - void lp_filt_exc_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 codec_mode, /* i : coder mode */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 L_subfr, /* i : subframe size */ - const Word16 L_frame, /* i : frame size */ - Word16 lp_flag, /* i : operation mode signalling */ - Word16 *exc ); - - void FEC_lsf2lsp_interp( - Decoder_State *st, /* i/o: Decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *Aq, /* o : calculated A(z) for 4 subframes */ - Word16 *lsf, /* o : estimated LSF vector */ - Word16 *lsp /* o : estimated LSP vector */ - ); - - ivas_error createFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - - void initFdCngDec_fx( - DEC_CORE_HANDLE st, /* i/o: decoder state structure */ - const Word16 scale ); - - /* Delete the instance of type FD_CNG */ - void deleteFdCngDec_fx( - HANDLE_FD_CNG_DEC *hFdCngDec ); - - /* Configure CLDFB-CNG */ - void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ - Word16 bandwidth, - Word32 bitrate, - Word16 L_frame, - const Word16 Last_L_frame, - const Word16 element_mode ); - - Word16 ApplyFdCng_fx( - Word16 *timeDomainInput, /* i : pointer to time domain input */ - Word16 Q, - Word32 *powerSpectrum, - Word16 Q_power_spectrum, - Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ - Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ - Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ - Decoder_State *st, - const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ - Word16 is_music ); - - /* Perform noise estimation */ - void perform_noise_estimation_dec_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain i */ - const Word16 Q, - HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - void perform_noise_estimation_dec_ivas_fx( - const Word16 *timeDomainInput, /* i: pointer to time domain input */ - const Word16 Q, - Word32 *power_spectrum, - Word16 Q_power_spectrum, - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ - const Word32 last_core_brate, /* i : previous frame core bitrate */ - const Word16 VAD /* i : VAD flag in the decoder */ - ); - - /* Decode the CLDFB-CNG bitstream */ - void FdCng_decodeSID_fx( - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Decoder_State *corest ); /* i/o: decoder state structure */ - - void noisy_speech_detection_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ - const Word16 vad, /* i : VAD flag */ - const Word16 *syn, /* i : i time-domain frame */ - const Word16 Q ); - - void generate_comfort_noise_dec_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ - ); - - void generate_comfort_noise_dec_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec, - Word16 *Q_new, - Word16 gen_exc, - const Word16 nchan_out /* i : number of output channels */ - ); - - void generate_comfort_noise_dec_hf_fx( - Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec ); - - void generate_comfort_noise_dec_hf_ivas_fx( - Word32 **bufferReal, /* o : matrix to real part of input bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ - ); - - /* Generate the comfort noise based on the target noise level */ - void generate_masking_noise_fx( - Word16 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 Q, - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 length, - Word16 core ); - - void generate_masking_noise_update_seed_fx( - HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ - ); - - void generate_masking_noise_mdct_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Word16 L_frame ); - - void generate_masking_noise_mdct_ivas_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); - - ivas_error init_decoder_fx( - Decoder_State *st_fx, /* o : Decoder static variables structure */ - const Word16 idchan, /* i : channel ID */ - const MC_MODE mc_mode /* i : MC mode */ - ); - - void reset_preecho_dec_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ - ); - - void destroy_cldfb_decoder_fx( - Decoder_State *st_fx /* o: Decoder static variables structure */ - ); - - void destroy_cldfb_encoder_fx( - Encoder_State *st /* i/o: state structure */ - ); - - Word16 WB_BWE_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *WB_fenv /*Q15*/ - ); - - Word16 wb_bwe_dec_fx( - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *Qpost ); - - /* o : BWE class */ - Word16 swb_bwe_gain_deq_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 core, /* i : core */ - Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ - Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ - const Word16 hr_flag, /* i : high rate flag */ - const Word16 hqswb_clas /* i : HQ BWE class */ - ); - - /*o :Q_syn_hb*/ - Word16 swb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *Qpost ); - - void fd_bwe_dec_init( - Decoder_State *st_fx, /* i/o: decoder state structure */ - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ - ); - - void hq_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *audio_fx, /* i : input audio signal Q0 */ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ - const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ - ); - - void hq_core_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word16 synth[], /* o : output synthesis Q_synth*/ - Word16 *Q_synth, /* o : Q value of synth */ - const Word16 output_frame, /* i : output frame length Q0*/ - const Word16 hq_core_type, /* i : HQ core type Q0*/ - const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ - ); - - void HQ_core_dec_init_fx( - HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ - ); - - void HQ_nbfec_init_fx( - HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ - ); - - - void hq_ecu_fx( - const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ - Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ - Word16 *time_offs, - Word16 *X_sav, - Word16 *Q_spec, /* i/o : Q value of stored spectrum */ - Word16 *num_p, - Word16 *plocs, - Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ - const Word16 env_stab, - Word16 *last_fec, - const Word16 ph_ecu_HqVoicing, - Word16 *ph_ecu_active, /* i : Phase ECU active flag */ - Word16 *gapsynth, - const Word16 prev_bfi, /* i : indicating burst frame error */ - const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ - Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ - Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ - Word16 *beta_mute, /* o : Factor for long-term mute */ - const Word16 output_frame, /* i : frame length */ - Decoder_State *st_fx /* i/o: decoder state structure */ - ); - - void hq_lr_dec_fx( - Decoder_State *st_fx, /* i/o: : decoder state structure */ - Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ - const Word16 inner_frame, /* i : Q0 : inner frame length */ - Word16 num_bits, /* i : Q0 : number of available bits */ - Word16 *is_transient_fx /* o : Q0 : transient flag */ - ); - - /* o : Number of bits Q0*/ - Word16 decode_envelope_indices_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : starting band index Q0*/ - const Word16 num_sfm, /* i : Number of subbands Q0*/ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ - Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ - const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ - ); - - void dequantize_norms_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : First SDE encoded norm Q0*/ - const Word16 num_sfm, /* i : Number of norms Q0*/ - const Word16 is_transient, /* i : Transient flag Q0*/ - Word16 *ynrm, /* o : Decoded norm indices Q0*/ - Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ - ); - - void hdecnrm_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* (i) number of norms Q0*/ - Word16 *index ); /* (o) indices of quantized norms Q0*/ - - Word16 decode_huff_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *hufftab, - Word16 *rbits ); - - void hdecnrm_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* Q0 */ - Word16 *index, /* Q0 */ - Word16 *n_length /* Q0 */ - ); - - void hdecnrm_resize_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs Q0*/ - Word16 *index /* (o) norm quantization index vector Q0*/ - ); - - void huff_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : Number of codewords to decode Q0*/ - const Word16 buffer_len, /* i : Number of bits to read Q0*/ - const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ - const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ - const Word16 *offset, /* i : Offset for first codeword Q0*/ - const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ - Word16 *index /* o : Decoded index Q0*/ - ); - - void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms Q0*/ - Word16 *index /* o : indices of quantized norms Q0*/ - ); - - void tcq_core_LR_dec_fx( - Decoder_State *st_fx, - Word16 *inp_vector_fx, /*x5 */ - const Word16 bit_budget, /*Q0 */ - const Word16 BANDS, /*Q0 */ - const Word16 *band_start, /*Q0 */ - const Word16 *band_width, /*Q0 */ - Word32 *Rk_fx, /*Q16*/ - Word16 *npulses, /*Q0 */ - Word16 *k_sort, /*Q0 */ - const Word16 *p2a_flags, /*Q0 */ - const Word16 p2a_bands, /*Q0 */ - const Word16 *last_bitalloc, /*Q0 */ - const Word16 input_frame, /*Q0 */ - const Word16 adjustFlag, /*Q0 */ - const Word16 *is_transient /*Q0 */ - ); - - void HQ_FEC_processing_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ - Word16 is_transient, /* i : Old flag for transient */ - Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ - Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ - Word16 num_Sb, /* i : Number of sub-band group */ - Word16 nb_sfm, /* i : Number of sub-band */ - Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ - Word16 output_frame, /* i : Frame size */ - const Word16 *sfm_start, /* i : Start of bands */ - const Word16 *sfm_end /* i : End of bands */ - ); - - void HQ_FEC_Mem_update_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 *t_audio_q_fx, /*Q12*/ - Word32 *normq_fx, /*Q14*/ - Word16 *ynrm, - Word16 *Num_bands_p, - Word16 is_transient, - Word16 hqswb_clas, - Word16 c_switching_flag, - Word16 nb_sfm, - Word16 num_Sb, - Word16 *mean_en_high_fx, /*Q5*/ - Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ); - - void time_domain_FEC_HQ_fx( - Decoder_State *st_fx, /* i : Decoder State */ - Word32 *wtda_audio_fx, /* i : i */ - Word16 *out_fx, /* o : output audio */ - Word16 mean_en_high_fx, /* i : transient flag */ - const Word16 output_frame, - Word16 *Q_synth ); - - void hq_pred_hb_bws_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *ynrm, /* i : norm quantization index vector Q0*/ - const Word16 length, /* i : frame length Q0*/ - const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ - const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ - ); - - void hq_hr_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure fx */ - Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ - const Word16 length, /* i : frame length Q0 */ - Word16 num_bits, /* i : number of available bits Q0 */ - Word16 *ynrm, /* o : norm quantization index vector Q0 */ - Word16 *is_transient, /* o : transient flag Q0 */ - Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ - Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ - const Word16 core_switching_flag /* i : Core switching flag Q1 */ - ); - - /* o : Consumed bits */ - Word16 hq_classifier_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : Core bit rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - Word16 *is_transient, /* o : Transient flag Q0 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ - ); - - void hvq_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 num_bits, /* i : Number of available bits */ - const Word32 core_brate, /* i : Core bit-rate */ - const Word16 *ynrm, /* i : Envelope coefficients Q0 */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *noise_level, /* o : Noise level in Q15 */ - Word16 *peak_idx, /* o : Peak position vector */ - Word16 *Npeaks, /* o : Total number of peaks */ - Word32 *coefsq_norm, /* o : Output vector in Q12 */ - const Word16 core ); - - Word16 hvq_pvq_bitalloc_fx( - Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ - const Word32 brate, /* i : bitrate */ - const Word16 bwidth_fx, /* i : Encoded bandwidth */ - const Word16 *ynrm, /* i : Envelope coefficients */ - const Word32 manE_peak, /* i : Peak energy mantissa */ - const Word16 expE_peak, /* i : Peak energy exponent */ - Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ - Word16 *R, /* Q0 i/o: Global bit allocation */ - Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ - Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ - ); - - void hq_configure_bfi_fx( - Word16 *nb_sfm, /* o : Number of sub bands Q0*/ - Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ - Word16 *num_bands_p, /* o : FEC sub bands Q0*/ - const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ - const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ - const Word16 **sfm_end /* o : Subband end coefficients Q0*/ - ); - - void bandwidth_switching_detect_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ - ); - - void bandwidth_switching_detect_ivas_fx( - Decoder_State *st_fx /* i/o: encoder state structure */ - ); - - void bw_switching_pre_proc_fx( - const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ - Decoder_State *st_fx /* i/o: decoder state structure */ - ); - - ivas_error core_switching_pre_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output_frame /* i : frame length Q0*/ - ); - - ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ - ); - - ivas_error core_switching_post_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ - const Word16 output_frame, /* i : frame length Q0*/ - const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ - const Word16 nchan_out, /* i : number of output channels Q0*/ - const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ - Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ - ); - - void core_switching_hq_prepare_dec_fx( - Decoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *num_bits, /* i/o: bit budget update Q0*/ - const Word16 output_frame /* i : output frame length Q0*/ - ); - - ivas_error amr_wb_dec_fx( - Word16 output_sp[], /* o : synthesis output */ - Decoder_State *st_fx /* o : Decoder static variables structure */ - ); - - void amr_wb_dec_init_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ - ); - - void updt_dec_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 *old_exc_fx, /* i : buffer of excitation */ - const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ - const Word16 Es_pred, /* i : predicited scaled innovation energy */ - const Word16 *Aq, /* i : A(z) quantized for all subframes */ - const Word16 *lsf_new_fx, /* i : current frame LSF vector */ - const Word16 *lsp_new_fx, /* i : current frame LSP vector */ - const Word16 voice_factors[], /* i : voicing factors */ - const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ - const Word16 *gain_buf /*Q14*/ - ); - - void updt_IO_switch_dec_fx( - const Word16 output_frame, /* i : output frame length */ - Decoder_State *st_fx /* o : Decoder static variables structure */ - ); - - void updt_bw_switching_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *synth, /* i : synthesis signal Qpost */ - const Word16 Qpost ); - - void updt_dec_common_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 hq_core_type_fx, /* i : HQ core type */ - const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ - const Word16 *synth, /* i : decoded synthesis */ - const Word16 Qpostd /* i : Synthesis Q value */ - ); - - void update_decoder_LPD_cng( - Decoder_State *st, - Word16 coder_type, - Word16 *timeDomainBuffer, - Word16 *A, - Word16 *bpf_noise_buf ); - - void FEC_clas_estim_fx( - Decoder_State *st_fx, /* i/o: decoder state handle */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ - const Word16 L_frame, /* i : length of the frame */ - Word16 *clas, /* i/o: frame classification */ - const Word16 coder_type, /* i : coder type */ - const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ - Word16 *syn, /* i : synthesis buffer */ - Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ - Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ - Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ - Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ - Word16 *Last_ener, /* i/o: last_energy frame A*/ - Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ - Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ - Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ - Word16 Q_syn, /* i : Synthesis scaling */ - Word16 *class_para, /* o : classification para. fmerit1 A*/ - Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ - Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ - Word16 mode, /* i : signal classifier mode B*/ - Word16 bfi, /* i : bad frame indicator B*/ - Word32 last_core_brate, /* i : bitrate of previous frame */ - const Word16 FEC_mode /* i : ACELP FEC mode */ - ); - - Word16 FEC_pos_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ - Word32 *enr_q, /* o : decoded energy in Q0 */ - const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ - ); - - void post_decoder( - Decoder_State *st, - Word16 synth_buf[], /* Q0 */ - Word16 pit_gain[], /* Q14 */ - Word16 pitch[], /* Q0 */ - Word16 signal_out[], /* Q0 */ - Word16 *bpf_noise_buf /* Q0 */ - ); - - void post_decoder_ivas_fx( - Decoder_State *st, - Word16 synth_buf[], // Q0 - Word16 pit_gain[], // Q14 - Word16 pitch[], // Q0 - Word16 signal_out[], // Q0 - Word16 *bpf_noise_buf // Q0 - ); - - void cldfb_synth_set_bandsToZero( - Decoder_State *st, - Word32 **rAnalysis, - Word32 **iAnalysis, - const Word16 nTimeSlots, - const CLDFB_SCALE_FACTOR scaleFactor ); - - void FEC_pitch_estim_fx( - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 last_core, /* i : last core */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 clas, /* i : current frame classification */ - const Word16 last_good, /* i : last good clas information */ - const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ - const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ - Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ - Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ - Word16 *upd_cnt, /* i/o: update counter */ - const Word16 coder_type, /* i : coder_type */ - Word16 element_mode /* i : element mode */ - ); - - void FEC_scale_syn_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ - Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ - Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const Word16 *pitch, /* i: pitch values for each subframe */ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ - Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ - Word16 *exc, /* i/o: excitation signal without enhancement */ - Word16 *exc2, /* i/o: excitation signal with enhancement */ - Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ - Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ - Word16 *mem_syn, /* o: initial synthesis filter states */ - Word16 Q_exc, - Word16 Q_syn, - const Word16 element_mode, /* i : element mode */ - const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i : force scaling */ - ); - - void LD_music_post_filter_fx( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const Word16 dtc_in[], /* i : i synthesis Qdct */ - Word16 dtc_out[], /* o : output synthesis Qdct */ - const Word32 core_brate, /* i : core bitrate Q0 */ - Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ - const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ - const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ - ); - - void Prep_music_postP_fx( - Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ - Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ - Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ - const Word16 last_core, /* i : last core */ - const Word16 element_mode, /* i : element mode */ - const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ - Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 *qdct /* o : Scaling factor of dct coefficient */ - ); - - void Post_music_postP_fx( - Word16 dct_buffer_in[], /* i/o: excitation buffer */ - Word16 *exc2, /* i/o: Current excitation to be overwriten */ - const Word16 *mem_tmp, /* i : previous frame synthesis memory */ - Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ - const Word16 *Aq, /* i : LPC filter coefficients */ - Word16 *syn, /* i/o: 12k8 synthesis */ - Word16 *Q_exc, /* i : excitation scaling */ - Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ - Word16 *Q_syn, /* i : Current frame synthesis scaling */ - Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ - const Word16 IsIO, /* i : Flag to indicate IO mode */ - Word16 *mem_deemph, /* i/o: speech deemph filter memory */ - Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ - Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ - Word16 *mem_agc, - PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ - Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ - ); - - void music_postfilt_init( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ - ); - - void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class Q0*/ - const Word16 coder_type, /* i : coder type Q0*/ - const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ - Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ - Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ - const Word16 locattack, /* i : Flag for a detected attack Q0*/ - Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ - Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ - Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ - const Word16 Q_syn, /* i : Synthesis scaling */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ - const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ - const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ - const Word16 last_coder_type /* i : Last coder_type Q0*/ - ); - - void decod_amr_wb_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficients */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ - ); - - void CNG_reset_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ - Word16 *voice_factors /* o : voicing factors Q15*/ - ); - - ivas_error ppp_voiced_decoder_fx( - Decoder_State *st_fx, /* i/o: state structure */ - Word16 *out_fx, /* o : residual signal */ - const Word16 *lpc2_fx, /* i : current frame LPC */ - Word16 *exc_fx, /* i : previous frame excitation */ - Word16 *pitch, /* o : floating pitch values for each subframe */ - Word16 bfi /* i : Frame error rate */ - ); - - void sc_vbr_dec_init( - SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ - ); - - ivas_error ppp_quarter_decoder_fx( - DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ - Word16 prevCW_lag_fx, /* i : Previous lag */ - Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ - Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ - Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ - Word16 bfi, /* i : FER flag */ - Word16 *S_fx, /* i : sine table, Q15 */ - Word16 *C_fx, /* i : cosine table, Q15 */ - DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ - Decoder_State *st_fx ); - - void open_decoder_LPD_fx( - Decoder_State *st, - const Word32 total_brate, /* Q0 */ - const Word16 bwidth /* Q0 */ - ); - - void open_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - - void reset_tcx_overl_buf_fx( - TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ - ); - - void acelp_plc_mdct_transition_fx( - Decoder_State *st /* i/o: Decoder state */ - ); - - void cldfb_reset_memory_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - void tcxltp_dec_init_fx( - TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ - const Word16 ini_frame, /* Q0 */ - const Word16 last_codec_mode, /* Q0 */ - const Word16 element_mode, /* Q0 */ - const Word16 pit_max, /* Q0 */ - const Word32 sr_core ); /* Q0 */ - - /* o : Exponent of SHB synthesis */ - Word16 swb_bwe_dec_hr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ - const Word16 exp, /* i : Exponent of core synthesis */ - Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ - const Word16 output_frame, /* i : frame length */ - const Word16 unbits, /* i : number of core unused bits */ - const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ - ); - - void hr_bwe_dec_init( - HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ - ); - - void swb_hr_noise_fill_fx( - const Word16 is_transient, /* i : transient flag */ - const Word16 spect_start, /* i : spectrum start point */ - const Word16 spect_end, /* i : spectrum end point */ - const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ - const Word16 pitch, /* i : pitch value Q15 */ - const Word16 nq[], /* i : AVQ nq index */ - Word16 Nsv, /* i : number of subband */ - Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ - Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ - Word16 Q_audio ); - - void stat_noise_uv_dec_fx( - Decoder_State *st_fx, /* i/o: Decoder static memory */ - Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ - Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ - Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ - const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ - ); - - void stat_noise_uv_mod_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ - Word16 *exc2, /* i/o: excitation buffer Q_exc */ - Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q15 */ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : input bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ - ); - - void stat_noise_uv_mod_ivas_fx( - const Word16 coder_type, /* i : Coder type */ - Word16 noisiness, /* i : noisiness parameter Q=0 */ - const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ - const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ - Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ - Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ - const Word16 bfi, /* i : Bad frame indicator */ - Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ - Word16 *uv_count, /* i/o: unvoiced counter */ - Word16 *act_count, /* i/o: activation counter */ - Word16 lspold_s[], /* i/o: old LSP Q=15*/ - Word16 *noimix_seed, /* i/o: mixture seed Q0 */ - Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ - Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ - const Word32 bitrate, /* i : core bitrate */ - const Word16 bwidth_fx, /* i : i bandwidth */ - Word16 *Q_stat_noise, /* i/o: noise scaling */ - Word16 *Q_stat_noise_ge /* i/o: noise scaling */ - ); - - Word16 FEC_SinOnset_fx( - Word16 *exc, /* i/o : exc vector to modify */ - Word16 puls_pos, /* i : last pulse position desired */ - const Word16 T0, /* i : Pitch information of the 1 subfr */ - Word32 enr_q, /* i : energy provide by the encoder */ - Word16 *Aq, /* i : A(z) filter Q12 */ - const Word16 L_frame, /* i : frame length */ - const Word16 Qold ); - - Word16 FEC_enhACB_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 last_L_frame, /* i : frame length of previous frame */ - Word16 *exc_io, /* i/o : adaptive codebook memory */ - const Word16 new_pit, /* i : decoded first frame pitch */ - const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ - const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ - ); - - /*! r: do_WI flag */ - Word16 FEC_synchro_exc_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* i/o: exc vector to modify */ - const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ - const Word16 true_puls_pos, /* i : Present pulse location */ - const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ - ); - - void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ - Word16 *gain_buf ); - - void gaus_dec_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *code, /* o : unvoiced excitation Q12 */ - Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ - Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ - Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ - Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ - Word16 *voice_fac, /* o : estimated voicing factor Q15 */ - Word16 *gain_pit, /* o : pitch gain Q14 */ - Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ - Word16 *exc, /* o : excitation signal frame */ - Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ - Word16 *exc2, /* o : Scaled excitation signal frame */ - Word16 *bwe_exc_fx, - Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ - Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ - ); - - void gaus_L2_dec( - Word16 *code, /* o : decoded gaussian codevector Q9 */ - Word16 tilt_code, /* i : tilt of code Q15 */ - const Word16 *A, /* i : quantized LPCs Q12 */ - Word16 formant_enh, /* i : formant enhancement factor Q15 */ - Word16 *seed_acelp /*i/o : random seed Q0 */ - ); - - ivas_error decod_gen_voic_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ - ); - - void decod_tran_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 tc_subfr_fx, /* i : TC subframe index */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ - Word16 *unbits, /* i/o: number of unused bits */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 *gain_buf /*Q14*/ - ); - - void transition_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 tc_subfr, /* i : TC subframe index */ - Word16 *Jopt_flag, /* i : joint optimization flag */ - Word16 *exc, /* o : excitation signal */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - Word16 **pt_pitch, /* o : floating pitch values */ - Word16 *position, /* i/o: first glottal impulse position in frame */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *Q_exc /*i/o : scaling of excitation */ - ); - - Word16 tc_classif_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame /* i : length of the frame */ - ); - - ivas_error decod_ppp_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ - Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation */ - Word16 *exc2_fx, /* i/o: current enhanced excitation */ - Word16 bfi, /* i : bad frame indicator */ - Word16 *gain_buf, /*Q14*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ - ); - - void swb_bwe_dec_lr_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 L_m_core[], /* i : lowband synthesis : QsL */ - const Word16 QsL, /* i : Q value of m_core */ - Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ - const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ - Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ - Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ - Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ - Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ - Word16 Qbe, /* i : Q value of band energy */ - Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ - const Word16 hqswb_clas_fx, /* i : class information : Q0 */ - Word16 lowlength_fx, /* i : Lowband Length : Q0 */ - Word16 highlength_fx, /* i : Highband Length : Q0 */ - const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ - Word16 *prev_frm_hfe2, /* i/o: : Q0 */ - Word16 *prev_stab_hfe2, /* i/o: : Q0 */ - Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ - const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ - Word16 *ni_seed_fx /* i/o: random seed : QsL */ - ); - - Word16 dec_acelp_tcx_frame_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 *concealWholeFrame, /* i/o: concealment flag */ - Word16 *pcmBuf, /* o : synthesis */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 *pcmbufFB, /* o : synthesis @output_FS */ - Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 pitch_buf[] /* o : floating pitch for each subframe */ - ); - - void decoder_LPD_fx( - Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ - Word16 signal_outFB[], /* o : synthesis @output_FS */ - Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ - Decoder_State *st, /* i/o: decoder memory state pointer */ - Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ - Word16 bfi, /* i : BFI flag */ - Word16 *bitsRead, /* o : number of read bits */ - Word16 param[], /* o : buffer of parameters */ - Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ - ); - - void mode_switch_decoder_LPD_fx( - Decoder_State *st, /* Q0 */ - Word16 bandwidth_in, /* Q0 */ - Word32 bitrate, /* Q0 */ - Word16 frame_size_index /* Q0 */ - ); - - void mode_switch_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ - const Word16 frame_size_index, /* i : index determining the frame size Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 last_element_mode, /* i : last element mode Q0*/ - Word16 *Q_syn_Overl_TDAC, - Word16 *Q_fer_samples, - Word16 *Q_syn_Overl, - Word16 *Q_syn_Overl_TDACFB, - Word16 *Q_syn_OverlFB, - Word16 *Q_old_out, - Word16 *Q_old_outLB, - Word16 *Q_old_Aq_12_8 ); - - Word16 DecodeIndex( - Decoder_State *st, - const Word16 Bandwidth, /* o : NB, 1: (S)WB */ - Word16 *PeriodicityIndex ); - - Word16 DecodeIndex_fx( - Decoder_State *st, - const Word16 Bandwidth, - Word16 *PeriodicityIndex ); - - void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ - ); - - Word16 lsf_msvq_ma_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ - ); - - Word16 lsf_bctcvq_decprm( - Decoder_State *st, - Word16 *param_lpc /* Q0 */ - ); - - Word16 D_lsf_tcxlpc( - const Word16 indices[], /* i : VQ indices Q0*/ - Word16 lsf_q[], /* o : quantized LSF Q1*/ - Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk, /* i : codebook selector Q0*/ - Word16 mem_MA[] /* i : MA memory Q1*/ - ); - - Word16 dec_lsf_tcxlpc( - Decoder_State *st, /* i/o: Decoder state */ - Word16 **indices, /* o : Ptr to VQ indices Q0*/ - Word16 narrowband, /* i : narrowband flag Q0*/ - Word16 cdk /* i : codebook selector Q0*/ - ); - - void midlsf_dec( - const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ - const Word16 idx, /* i: codebook index */ - Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ - const Word16 coder_type, - Word16 *mid_lsf_int, - const Word16 prev_bfi, - const Word16 safety_net ); - - Word16 lsf_ind_is_active( - const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ - const Word16 means[], /*(14Q1*1.28)*/ - const Word16 narrowband, - const Word16 cdk ); - - void IGFSCFDecoderOpen( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ - H_IGF_INFO hIgfInfo, /* i : IGF info handle */ - const Word32 total_brate, - const Word16 bwidth, - const Word16 element_mode, - const Word16 rf_mode ); - - void IGFSCFDecoderReset( - IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ - ); - - void IGFSCFDecoderDecode( - IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - Decoder_State *st, /* i/o: pointer to decoder state */ - Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, - if 0 on input the decoder will be forced to encode without a reset */ - ); - - Word32 ari_decode_overflow_fx( - Tastat *s ); - - void ari_start_decoding_14bits_fx( - Decoder_State *st, - Tastat *s ); - - Word16 ari_start_decoding_14bits_prm_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - - Word16 ari_decode_14bits_s17_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - - Word16 ari_decode_14bits_s27_ext_fx( - Decoder_State *st, - Tastat *s, - UWord16 const *cum_freq ); - - Word16 ari_decode_14bits_bit_ext_fx( - Decoder_State *st, - Tastat *s ); - - Word16 ari_decode_14bits_pow_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - Word16 base ); - - Word16 ari_decode_14bits_sign_fx( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - - void getTCXparam_fx( - Decoder_State *st, /* i/o: Decoder State handle */ - Decoder_State *st0, /* i : bitstream */ - CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - Word16 param[], /* o : decoded parameters Q0 */ - const Word16 bits_common, /* i : number of common bits Q0 */ - const Word16 start_bit_pos, /* i : position of the start bit Q0 */ - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ - Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ - Word16 nTnsBitsTCX10[2], /*Q0*/ - const Word16 pre_past_flag /*Q0*/ - ); - - void dec_prm_fx( - Word16 *coder_type, - Word16 param[], /* (o) : decoded parameters */ - Word16 param_lpc[], /* (o) : LPC parameters */ - Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ - Decoder_State *st, - Word16 L_frame, - Word16 *bitsRead ); - - void getLPCparam_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Word16 param_lpc[], /* o : LTP parameters Q0 */ - Decoder_State *st0, /* i : bitstream */ - const Word16 ch, /* i : channel Q0 */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ - ); - - void UnmapIndex( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word16 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ - ); - - void ConfigureContextHm( - const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ - const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ - const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ - const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ - ); - - Word16 CountIndexBits( - Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ - Word16 PeriodicityIndex /* Q0 */ - ); - - Word32 tcx_hm_render( - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ - ); - - void tcx_hm_modify_envelope( - Word16 gain, /* i: HM gain Q11 */ - Word32 lag, /* i: pitch lag Q0 */ - Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - Word16 L_frame /* i: number of spectral lines Q0 */ - ); - - Word16 ReadTnsData( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - - void ReadTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - - Word16 DecodeTnsData( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - - Word16 DecodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); - - void GetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void const *pParameter, - Word16 **pStream, - Word16 *pnSize, - Word16 *pnBits ); - - void GetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, // Q0 - void const *pParameter, // Q0 - Word16 **pStream, // Q0 - Word16 *pnSize, // Q0 - Word16 *pnBits // Q0 - ); - - void EncodeTnsData_ivas_fx( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream Q0*/ - Word16 *pnSize, /* o : number of written parameters Q0*/ - Word16 *pnBits /* o : number of written bits Q0*/ - ); - - void SetParameters( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - - void SetParameters_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - void *pParameter, - const Word16 **pStream, - Word16 *pnSize ); - - void WriteToBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nParams, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - void ReadFromBitstream( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - - void ReadFromBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - Decoder_State *st, - Word16 **pStream, - Word16 *pnSize ); - - void IGFDecReadData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ - ); - - void IGFDecReadLevel( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ - ); - - void IGFDecApplyMono( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ - ); - - void IGFDecApplyMono_ivas( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ - Word16 element_mode /**< in: | IVAS element mode */ - ); - - void IGFDecApplyStereo( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ - Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ - Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ - Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ - const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 *coreMsMask, - const Word16 restrict_hopsize, - const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ - const Word16 bfi_apply_damping ); - - void IGFDecSetMode( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void IGFDecSetMode_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ - const Word32 total_brate, /* i : bitrate */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 defaultStartLine, /* i : default start subband index */ - const Word16 defaultStopLine, /* i : default stop subband index */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void IGFDecUpdateInfo( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 igfGridIdx /**< in: | IGF grid index */ - ); - - void IGFDecUpdateInfo_ivas_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ - const Word16 subFrameIdx, /* i : subframe index */ - const Word16 igfGridIdx /* i : IGF grid index */ - ); - - void IGFDecCopyLPCFlatSpectrum( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ - ); - - void IGFDecCopyLPCFlatSpectrum_fx( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ - ); - - void IGFDecStoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ - ); - - void IGFDecRestoreTCX10SubFrameData( - const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ - ); - - void IGFDecRestoreTCX10SubFrameData_fx( - const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ - const Word16 subFrameIdx /* i : index of subframe */ - ); - - void init_igf_dec( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ - ); - - Word16 dlpc_avq_fx( - Word16 *index, /* (i) Quantization indices */ - Word16 *LSF_Q, /* (o) Quantized LSF vectors */ - Word16 numlpc, /* (i) Number of sets of lpc */ - Word32 sr_core ); - - Word16 decode_lpc_avq_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ - ); - - Word16 decode_lpc_avq_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc, /* o : lpc parameters */ - const Word16 ch, /* i : channel */ - const Word16 element_mode, /* i : element mode */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ - ); - - void vlpc_1st_dec( - Word16 index, /* i : codebook index */ - Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ - - void vlpc_2st_dec( - Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ - Word16 *indx, /* i : index[] (4 bits per words) */ - Word16 mode, /* i : 0=abs, >0=rel */ - Word32 sr_core ); - - void lsf_weight_2st( - const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ - const Word16 mode /* input: operational mode Q0 */ - ); - - /* Returns: index of next coefficient */ - Word16 get_next_coeff_mapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - /* Returns: index of next coefficient */ - Word16 get_next_coeff_unmapped( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - Word16 update_mixed_context( - Word16 ctx, /* Q0 */ - Word16 a /* Q0 */ - ); - - Word32 update_mixed_context_ivas_fx( - Word32 ctx, /* Q0 */ - Word16 a /* Q0 */ - ); - - typedef Word16 ( *get_next_coeff_function )( - Word16 ii[2], /* i/o: coefficient indexes */ - Word16 *pp, /* o : peak(1)/hole(0) indicator */ - Word16 *idx, /* o : index in unmapped domain */ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - Word16 ACcontextMapping_decode2_no_mem_s17_LC( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o: decoded spectrum */ - Word16 nt, /* i: size of spectrum */ - Word16 nbbits, /* i: bit budget */ - Word16 resQMaxBits, /* i: residual coding maximum bits*/ - CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ - ); - - Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( - Decoder_State *st, /* i/o: decoder state */ - Word16 *x, /* o : decoded spectrum */ - const Word16 nt, /* i : size of spectrum */ - const Word16 nbbits, /* i : bit budget */ - const Word16 resQMaxBits, /* i : residual coding maximum bits */ - CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ - ); - - void reconfig_decoder_LPD_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 bits_frame, /* i : bit budget Q0*/ - Word16 bwidth, /* i : audio bandwidth Q0*/ - Word32 total_brate, /* i : total bitrate Q0*/ - Word16 L_frame_old /* i : frame length Q0*/ - ); - - void reconfig_decoder_LPD_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 bits_frame, /* i : bit budget Q0*/ - const Word16 bwidth, /* i : audio bandwidth Q0*/ - const Word32 total_brate, /* i : total bitrate Q0*/ - const Word16 L_frame_old /* i : frame length Q0*/ - ); - - void minimumStatistics_fx( - Word16 *noiseLevelMemory, /* Q15, internal state */ - Word16 *noiseLevelIndex, /* Q0, internal state */ - Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ - Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ - Word16 *lastFrameLevel, /* Q15, level of the last frame */ - Word16 currentFrameLevel, /* Q15, level of the current frame */ - Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ - Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ - Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ - Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ - Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ - - /*10Q5*/ - Word16 getLevelSynDeemph_fx( - Word16 h1Init[], /* i: i value or vector to be processed Q15 */ - Word16 const A[], /* i: LPC coefficients Qx */ - Word16 const lpcorder, /* i: LPC order Q0 */ - Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ - Word16 const preemph_fac, /* i: preemphasis factor Q15 */ - Word16 const numLoops, /* i: number of loops Q0 */ - Word16 *Exp /* o: exponent of return value Q15 */ - ); - - void genPlcFiltBWAdap_fx( - Word32 const sr_core, /*mem_syn >rescaling done */ - Word16 *pitch_buffer, - Word16 *voice_factors, - Word16 *bwe_exc ); - - void decoder_acelp_fx( - Decoder_State *st, - Word16 prm[], /* i : parameters */ - Word16 A[], /* i : coefficients NxAz[M+1] */ - ACELP_config acelp_cfg, /* i : ACELP config */ - Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ - Word16 *pT, /* out: pitch for all subframe Q0 */ - Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ - Word16 stab_fac, /* i : stability of isf */ - Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ - Word16 *voice_factors, /* out: voicing factors */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *bwe_exc /* out: excitation for SWB TBE */ - ); - - void decode_acelp_gains_fx( - Word16 *code, - Word16 gains_mode, - Word16 mean_ener_code, - Word16 *gain_pit, - Word32 *gain_code, - Word16 **pt_indice, - Word16 *past_gpit, - Word32 *past_gcode, - Word16 *gain_inov, - Word16 L_subfr, - Word16 *code2, - Word32 *gain_code2 ); - - void d_gain_pred_fx( - Word16 nrg_mode, /* i : NRG mode */ - Word16 *Es_pred, /* o : predicited scaled innovation energy */ - Word16 **pt_indice /* i/o: pointer to the buffer of indices */ - ); - - ivas_error evs_dec_fx( - Decoder_State *st_fx, /* i/o : Decoder state structure */ - Word16 output_sp[], /* o : output synthesis signal */ - FRAME_MODE frameMode /* i : Decoder frame mode */ - ); - - void fft_cldfb_fx( - Word32 *data, /* i/o: input/output vector */ - const Word16 size /* size of fft operation */ - ); - - void stereo_dft_dec_analyze_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 *input_fx, /* i : input signal q*/ - Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ - const Word16 chan, /* i : channel number Q0*/ - const Word16 input_frame, /* i : input frame size Q0*/ - const Word16 output_frame, /* i : output frame size Q0*/ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ - const Word16 k_offset, /* i : offset of DFT Q0*/ - const Word16 delay, /* i : delay in samples FOR input signal Q0*/ - Word16 *q, - Word16 *q_DFT ); - - void set32_fx( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ - ); - - void delay_signal_q_adj_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay, /* i : delay in samples */ - const Word16 q_x, - const Word16 q_mem ); - - Word32 anint_fx( - const Word32 x, /* i: Round to the nearest integer */ - const Word16 exp /* i: Exponent for round step */ - ); - - Word32 ceil_fx( - const Word32 x, /* i: number to ceil */ - const Word16 exp /* i: Exponent for ceil step */ - ); - - void v_add_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_shr_16( - const Word16 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word16 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ - ); - - void v_shr( - const Word32 x[], /* i : Input vector */ - const Word16 shift, /* i : Constant */ - Word32 y[], /* o : Output vector that contains x >> shift */ - const Word16 N /* i : Vector length */ - ); - - void cldfbAnalysis_ts_fx( - const Word32 *timeIn_fx, /* i : time buffer */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, - Word16 *q_cldfb ); - - Word16 floor_log_2( - Word32 num ); - - void cldfbAnalysis_ts_fx_var_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - - void cldfbAnalysis_ts_fx_fixed_q( - const Word32 *timeIn_fx, /* i : time buffer q */ - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word16 *q_cldfb ); - - void configureCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - const Word32 sampling_rate /* i : sampling rate */ - ); - - void dec_acelp_fast_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 cdk_index, /* i : codebook index */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - const Word16 L_subfr /* i : subframe length */ - ); - - void tcx5SpectrumInterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - - void tcx5SpectrumDeinterleaving_fx( - const Word16 tcx5Size, - Word32 *spectrum ); - - void tcx5TnsGrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum ); - - void tcx5TnsUngrouping_fx( - const Word16 L_frame, - const Word16 L_spec, - Word32 *spectrum, - const Word16 enc_dec ); - - void bpf_pitch_coherence_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ - ); - - /* fft_rel.c */ - -#define SIZE_256 256 -#define NUM_STAGE_256 7 -#define SIZE2_256 ( SIZE_256 / 2 ) - - void cldfbAnalysis_ivas_fx( - const Word32 *timeIn_fx, /* i : time buffer Qx */ - Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ - Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ - ); - - void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ - const Word16 out_shift, /* i : scale for output buffer */ - HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ - ); - - void addBassPostFilter_ivas_fx( - const Word32 *harm_timeIn_fx, - const Word16 samplesToProcess, - Word32 **rAnalysis_fx, - Word32 **iAnalysis_fx, - HANDLE_CLDFB_FILTER_BANK cldfb ); - - /* o : Q22*/ - Word32 ism_dequant_meta_fx( - const Word16 idx, /* i : quantizer index */ - const Word32 borders_fx[], /* i : level borders Q22*/ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ - const Word16 cbsize /* i : codebook size */ - ); - - void save_synthesis_hq_fec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ - const Word32 output_fx[], /* i : decoded synthesis */ - const Word16 output_frame, /* i : decoded synthesis */ - const Word16 Qpostd, /* i : Q value of delayed signal */ - CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ - ); - - void calculate_nbits_meta_fx( - const Word16 nchan_ism, - Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 - Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 - const Word16 numSf, - const Word16 numCodingBands, - Word16 *bits_ism, - const Word16 idx_sep_obj, - const Word16 ism_imp ); - - void ivas_get_stereo_panning_gains_fx( - const Word16 aziDeg, - const Word16 eleDeg, - Word16 panningGains[2] ); - - ivas_error openCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ - const Word16 enc_dec ); /* i : encoder/decoder flag */ - - Word32 rand_gauss_fx( - Word32 *x, - Word16 *seed, - Word16 q ); - - void resampleCldfb_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate ); - - void generate_masking_noise_dirac_ivas_fx( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ - Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ - Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ - Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ - const Word16 slot_index, /* i : CLDFB slot index */ - const Word16 cna_flag, /* i : CNA flag for LB and HB */ - const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ - Word16 q_input, - Word16 *q_cldfb ); - - void IMDCT_fx( - Word32 *x, - Word16 x_e, - Word16 *old_syn_overl, - Word16 *syn_Overl_TDAC, - Word16 *xn_buf, - const Word16 *tcx_aldo_window_1, - const PWord16 *tcx_aldo_window_1_trunc, - const PWord16 *tcx_aldo_window_2, - const PWord16 *tcx_mdct_window_half, - const PWord16 *tcx_mdct_window_minimum, - const PWord16 *tcx_mdct_window_trans, - Word16 tcx_mdct_window_half_length, - Word16 tcx_mdct_window_min_length, - Word16 index, - Word16 left_rect, - Word16 tcx_offset, - Word16 overlap, - Word16 L_frame, - Word16 L_frameTCX, - Word16 L_spec_TCX5, - Word16 L_frame_glob, - Word16 frame_cnt, - Word16 bfi, - Word16 *old_out, - Word16 *Q_old_wtda, - Decoder_State *st, - Word16 fullbandScale, - Word16 *acelp_zir ); - - void IMDCT_ivas_fx( - Word32 *x_fx, - Word16 q_x, - Word16 *old_syn_overl_fx, - Word16 *Q_old_syn_overl_fx, - Word16 *syn_Overl_TDAC_fx, - Word16 *Q_syn_Overl_TDAC_fx, - Word16 *xn_buf_fx, - Word16 q_xn_buf_fx, - const Word16 *tcx_aldo_window_1_fx, - const PWord16 *tcx_aldo_window_1_trunc_fx, - const PWord16 *tcx_aldo_window_2_fx, - const PWord16 *tcx_mdct_window_half_fx, - const PWord16 *tcx_mdct_window_minimum_fx, - const PWord16 *tcx_mdct_window_trans_fx, - const Word16 tcx_mdct_window_half_length, - const Word16 tcx_mdct_window_min_length, - Word16 index, - const UWord16 kernel_type, /* i : TCX transform kernel type */ - const Word16 left_rect, - const Word16 tcx_offset, - const Word16 overlap, - const Word16 L_frame, - const Word16 L_frameTCX, - const Word16 L_spec_TCX5, - const Word16 L_frame_glob, - const Word16 frame_cnt, - const Word16 bfi, - Word16 *old_out_fx, - Word16 *q_old_out_fx, - const Word16 FB_flag, - Decoder_State *st, - const Word16 fullbandScale, - Word16 *acelp_zir_fx, - Word16 *q_acelp_zir_fx, - Word16 *pq_win ); - - void v_mult16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void configureFdCngDec_fx( - HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, - const Word32 total_brate, - const Word16 L_frame, - const Word16 last_L_frame, - const Word16 element_mode ); - - Word32 sum2_f_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ - ); - - Word32 sum2_f_16_gb_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - - Word32 sum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - - Word16 vq_dec_lvq_ivas_fx( - Word16 sf_flag, /* i : safety net flag */ - Word16 x[], /* o : Decoded vector Q(x2.56)*/ - Word16 indices[], /* i : Indices */ - Word16 stages, /* i : Number of stages */ - Word16 N, /* i : Vector dimension */ - Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ - Word16 no_bits /* (i): no. bits for lattice */ - ); - - Word16 deindex_lvq_ivas_fx( - Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ - Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ - Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ - Word16 sf_flag, /* i : safety net flag */ - Word16 no_bits /* i : number of bits for lattice */ - ); - - void deleteCldfb_fx( - HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ - ); - - void fd_bwe_dec_init_fx( - FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ - ); - - void stereo_dft_dec_open( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 nchan_transport /* i : number of transport channels */ - ); - - void ivas_bw_switching_pre_proc_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - Word32 *old_syn_12k8_16k_fx, - Word16 Q, - Word16 Q_audio ); - - UWord32 mvl2s_r( - const Word32 x[], /* i : input vector */ - const Word16 q, - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ - ); - - void decoder_tcx_post_ivas_fx( - Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 Q_syn, - Word16 *A, - Word16 bfi, - Word16 MCT_flag ); - - void con_tcx_ivas_fx( - Decoder_State *st, /* i/o: coder memory state */ - Word16 synth[], /* i/o: synth[] Q0 */ - const Word16 coh, /* i : coherence of stereo signal */ - Word16 *noise_seed, /* i/o: noise seed for stereo */ - const Word16 only_left, /* i : TD-PLC only in left channel */ - const Word16 *A_cng /* i : CNG LP filter coefficients */ - ); - - void ivas_mdct_core_reconstruct_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ - Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ - Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - Word16 q_x, - Word16 e_sig[CPE_CHANNELS] ); - - void ari_start_encoding_14bits_ivas_fx( - Tastat *s ); - - void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i: input coefficients */ - Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ - Word16 L_frame, /* i: frame length */ - Word16 gain, /* i: quantization gain */ - Word16 gain_e, /* i: quantization gain exponent */ - Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ - const Word16 alfe_flag ); - - Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( - Word16 *x, /* Spectral coefficients Q0*/ - const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ - Word16 *lastnz_out, /* Q0 */ - Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ - const Word16 target, /* Target bits Q0*/ - Word16 *stop, /* Q0 */ - Word16 mode, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ - ); - - /* Qx*/ - Word16 usdequant_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta /* i: quantization step Qy*/ - ); - - /* Qx*/ - Word32 usdequant32_fx( - const Word16 idx, /* i: quantizer index Q0*/ - const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word32 delta /* i: quantization step Qy*/ - ); - - /* o: index of the winning codeword */ - Word16 usquant_fx( - const Word16 x, /* i: scalar value to quantize Qx*/ - Word16 *xq, /* o: quantized value Qx*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta, /* i: quantization step Qx-1*/ - const Word16 cbsize /* i: codebook size */ - ); - - /* o : Sum */ - Word32 Dot_product( - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg /* i : vector length */ - ); - - /* o : dot product of x[] and y[] */ - Word32 dotp_fx( - const Word16 x[], /* i : vector x[] */ - const Word16 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 *exp /* (o) : exponent of result (0..+30) */ - ); - - /* o : sum of all squared vector elements Q(2x+1)*/ - Word32 sum2_fx_mod( - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ - ); - - void Copy_Scale_sig( - const Word16 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Scale_sig32( - Word32 x[], /* i/o: signal to scale Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_16_32_DEPREC( - const Word16 x[], /* i : signal to scale i Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_16_32_r( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_16_32_no_sat( - const Word16 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Copy_Scale_sig_32_16( - const Word32 x[], /* i : signal to scale i Qx */ - Word16 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void Random_Fill( - Word16 *seed, /* i/o: random seed */ - Word16 n, /* i : number of values */ - Word16 *y, /* o : output values */ - Word16 scaling /* i : scaling of values */ - ); - - /* o : mean of vector */ - Word16 mean_fx( - const Word16 *vec_fx, /* i : i vector */ - const Word16 lvec_fx /* i : length of i vector */ - ); - - /* o : mean of vector Qx */ - Word16 mean_no_sat_fx( - const Word16 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx /* i : length of input vector */ - ); - - /* o : mean of vector Qx */ - Word32 mean_no_sat_Word32_fx( - const Word32 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx, /* i : length of input vector */ - const Word16 gb ); - void sort( - UWord16 *x, /* i/o: Vector to be sorted */ - UWord16 len /* i/o: vector length */ - ); - - void sort_fx( - Word16 *r, /* i/o: Vector to be sorted in place */ - Word16 lo, /* i : Low limit of sorting range */ - Word16 up /* I : High limit of sorting range */ - ); - - void sort_32_fx( - Word32 *r, /* i/o: Vector to be sorted in place */ - const Word16 lo, /* i : Low limit of sorting range */ - const Word16 up /* I : High limit of sorting range */ - ); - - /* o : index of the minimum value in the input vector */ - Word16 minimum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *min_fx /* o : minimum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *max_fx /* o : maximum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_exp_fx( - const Word16 *vec_fx, /* i : input vector */ - const Word16 *exp_vec, /* i : exponents of input vector */ - const Word16 lvec_fx /* i : length of input vector */ - ); - - /* o : index of the maximum abs value in the input vector */ - Word16 maximum_abs_16_fx( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max_val /* o : maximum value in the input vector */ - ); - - /* o : index of the minimum value in the input vector */ - Word16 minimum_abs32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ - ); - - /* o : index of the minimum value in the input vector */ - Word16 minimum_32_fx( - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /* o : index of the maximum value in the input vector */ - Word16 maximum_abs_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /*! r: index of the maximum value in the input vector */ - Word16 maximum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max /* o : maximum value in the input vector */ - ); - - /*! r: index of the minimum value in the input vector */ - Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ - ); - - Word16 Exp16Array( - const Word16 n, /* (i): Array size */ - const Word16 *sx /* (i): Data array */ - ); - - Word16 Exp32Array( - const Word16 n, /* (i): Array size */ - const Word32 *sx /* (i): Data array */ - ); - - /* o : sum of all vector elements Qx*/ - Word32 sum16_32_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - /* o : sum of all vector elements Qx*/ - Word32 sum32_sat( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - /* o: variance of vector Qx+16*/ - Word32 var_fx_32( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ - ); - - /* o: variance of vector Qx+16*/ - Word32 var_fx_32in_32out( - const Word32 *x, /* i: input vector Qx*/ - Word16 *Qx, - const Word16 len, /* i: length of inputvector */ - const Word16 gb ); - - /* o: variance of vector Qx*/ - Word16 var_fx( - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ - ); - - /* o: variance of vector Qx*/ - Word16 std_fx( - const Word16 x[], /* i: input vector */ - const Word16 len /* i: length of the input vector */ - ); - - /* o : the dot product x'*A*x */ - Word32 dot_product_mat_fx( - const Word16 *x, /* i : vector x Q15 */ - const Word32 *A, /* i : matrix A Q0*/ - const Word16 m /* i : vector & matrix size */ - ); - - void Vr_subt( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - Word16 N /* i : Vector lenght */ - ); - - /* o: index of the winning codevector */ - Word16 vquant_ivas_fx( - Word32 x[], /* i: vector to quantize Q25 */ - const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ - Word32 xq[], /* o: quantized vector Q25 */ - const Word32 cb[], /* i: codebook Q25 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ - ); - - /* o: index of the winning codevector */ - Word16 vquant_fx( - Word16 x[], /* i: vector to quantize Q13 */ - const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ - Word16 xq[], /* o: quantized vector Q13 */ - const Word16 cb[], /* i: codebook Q13 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ - ); - - Word16 w_vquant_fx( - Word16 x[], /* i: vector to quantize in Q10 */ - Word16 Qx, - const Word16 weights[], /* i: error weights in Q0 */ - Word16 xq[], /* o: quantized vector in Q15 */ - const Word16 cb[], /* i: codebook in Q15 */ - const Word16 cbsize, /* i: codebook size */ - const Word16 rev_vect /* i: reverse codebook vectors */ - ); - - /* o : return index with max energy value in vector Q0 */ - Word16 emaximum_fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word16 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ - ); - - /* o : return index with max energy value in vector Q0 */ - Word16 emaximum_32fx( - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word32 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ - ); - - /* o : mean of the elements of the vector */ - Word32 Mean32( - const Word32 in[], /* i : input vector */ - const Word16 L /* i : length of input vector */ - ); - - /* o : sum of all vector elements Qx*/ - Word32 sum32_fx( - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - /* o : sum of all vector elements Qx*/ - Word16 sum16_fx( - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ - ); - - Word16 own_random2_fx( - Word16 seed ); - - void iDiv_and_mod_32( - const Word32 Numer, /* i : 32 bits numerator */ - const Word16 Denom, /* i : 16 bits denominator */ - Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ - Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ - const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ - ); - - void pz_filter_sp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word16 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - - Word32 root_a_fx( - Word32 a, - Word16 Q_a, - Word16 *exp_out ); - - Word32 root_a_over_b_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - - Word32 root_a_over_b_ivas_fx( - Word32 a, /* Q(Q_a) */ - Word16 Q_a, - Word32 b, /* Q(Q_b) */ - Word16 Q_b, - Word16 *exp_out ); - - void fir_fx( - const Word16 x[], /* i : input vector Qx*/ - const Word16 h[], /* i : impulse response of the FIR filter Q12*/ - Word16 y[], /* o : output vector (result of filtering) Qx*/ - Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ - const Word16 L, /* i : input vector size */ - const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ - const Word16 upd, /* i : 1 = update the memory, 0 = not */ - Word16 shift /* i : difference between Q15 and scaling of h[] */ - ); - - void v_add_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_shr_32( - Word32 x1[], /* i : Input vector 1 */ - Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N, /* i : Vector length */ - Word16 shift /*shift value*/ - ); - - void v_sub_32( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_add_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_sub_16( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - /* o: index of the winning codeword */ - Word16 squant_fx( - const Word16 x, /* i: scalar value to quantize */ - Word16 *xq, /* o: quantized value */ - const Word16 cb[], /* i: codebook */ - const Word16 cbsize /* i: codebook size */ - ); - - Word16 squant_int_fx( - UWord8 x, /* i : scalar value to quantize */ - UWord8 *xq, /* o : quantized value */ - const UWord8 *cb, /* i : codebook */ - const Word16 cbsize /* i : codebook size */ - ); - - void pz_filter_dp_fx( - const Word16 b[], - const Word16 a[], - Word16 x[], - Word16 y[], - Word32 buf[], - Word16 PNR, - Word16 PDR, - Word16 N, - Word16 Qa ); - - void Copy_Scale_sig32_16( - const Word32 *src, /* i : signal to scale Qx */ - Word16 *dst, /* o : scaled signal Qx */ - Word16 len, /* i : size of x[] Q0 */ - Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ - - void v_multc_att( - const Word16 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word16 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_att32( - const Word32 x[], /* i : Input vector Qx */ - const Word16 att, /* i : Constant Q15, <= MAX_16 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ - ); - - void v_multc_att3232( - const Word32 x[], /* i : Input vector Qx */ - const Word32 att, /* i : Constant Q32, <= MAX_32 */ - Word32 y[], /* o : Output vector that contains att*x */ - const Word16 N /* i : Vector length */ - ); - - void v_L_mult_1616( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_L_mult_3216( - const Word32 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void add_vec_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 Qx1, /* i : SCaling of input 1 */ - const Word16 x2[], /* i : Input vector 2 */ - const Word16 Qx2, /* i : SCaling of input 1 */ - Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const Word16 Qy, /* i : SCaling of output 1 */ - const Word16 N /* i : Vector lenght */ - ); - - /* o: Result (Normalized) */ - Word32 Add_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ - ); - - /* o: Result (Normalized) */ - Word32 Mul_flt32_Q15( - Word32 value, /* i: Pseudo_float Value */ - Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ - Word16 frac /* i: Q15 value */ - ); - - /* o: Result (Normalized) */ - Word32 Div_flt32_flt32( - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ - ); - - /* o: Result (Normalized) */ - Word32 Calc_Energy_Autoscaled( - const Word16 *signal, /* i: Signal */ - Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ - Word16 len, /* i: Frame Length */ - Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ - ); - - Word16 Find_Max_Norm16( - const Word16 *src, - Word16 len ); - - Word16 Find_Max_Norm32( - const Word32 *src, - Word16 len ); - - /* o: Result in Q31 */ - Word32 Sqrt_Ratio32( - Word32 L_val1, /* i: Mantisa of Val1 */ - Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ - Word32 L_val2, /* i: Mantisa of Val2 */ - Word16 exp2, /* i: Exp of Val2 (same as exp1) */ - Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ - ); - - /* result in Q'15 + 'exp' */ - Word16 Invert16( - Word16 val, - Word16 *exp ); - - Word16 find_rem( - Word16 n, - Word16 m, - Word16 *r ); - - Word32 find_remd( - Word32 n, - Word32 m, - Word32 *r ); - - Word16 rint_new_fx( - Word32 x /*Q16 */ - ); - - Word16 erb_diff_search_fx( - Word16 *prev_erb, - const Word16 *curr_erb, - Word16 *dif_erb, - Word16 *pow_spec, - const Word16 *cb_fx, - Word16 cb_size, - Word16 cb_dim, - Word16 offset ); - - void Acelp_dec_total_exc( - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - const Word16 gain_code16, /* i : Gain code Q0 */ - const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ - const Word16 i_subfr, /* i ; subfr */ - const Word16 *code_fx, /* i : code in Q9 */ - const Word16 L_subfr /* i : Subframne lenght */ - ); - - UWord32 UL_inverse( - const UWord32 UL_val, - Word16 *exp ); - - UWord32 UL_div( - const UWord32 UL_num, - const UWord32 UL_den ); - - Word16 ratio( - const Word32 numer, - const Word32 denom, - Word16 *expo ); - - void hp400_12k8_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ - ); - - void hp400_12k8_ivas_fx( - Word16 signal[], /* i/o: input signal / output is divided by 16 */ - const Word16 lg, /* i : lenght of signal */ - Word16 mem[] /* i/o: filter memory [6] */ - ); - - Word16 dot_prod_satcontr( - const Word16 *x, - const Word16 *y, - Word16 qx, - Word16 qy, - Word16 *qo, - Word16 len ); - - void E_UTIL_f_convolve( - const Word16 x[], - const Word16 h[], - Word16 y[], - const Word16 size ); - - void floating_point_add( - Word32 *mx, /* io: mantissa of the addend Q31 */ - Word16 *ex, /* io: exponent of the addend Q0 */ - const Word32 my, /* i: mantissa of the adder Q31 */ - const Word16 ey /* i: exponent of the adder Q0 */ - ); - - void delay_signal_fx( - Word16 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word16 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ - ); - - void delay_signal32_fx( - Word32 x[], /* i/o: signal to be delayed */ - const Word16 len, /* i : length of the input signal */ - Word32 mem[], /* i/o: synchronization memory */ - const Word16 delay /* i : delay in samples */ - ); - - Word16 lin_interp_ivas_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ - ); - - Word16 lin_interp_fx( - const Word16 x, /* i : the value to be mapped */ - const Word16 x1, /* i : source range interval: low end */ - const Word16 y1, /* i : source range interval: high end */ - const Word16 x2, /* i : target range interval: low */ - const Word16 y2, /* i : target range interval: high */ - const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ - ); - - Word16 ceil_log_2( - UWord64 val ); - - Word32 imax_pos_fx( - const Word32 *y /* i : Input vector for peak interpolation Qx*/ - ); - - void msvq_enc_ivas_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ - const Word16 Q_cb, /* i : Codebook Q */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ - const Word16 u_e, /* i : Exponent for Vector to be encoded */ - const Word16 *levels, /* i : Number of levels in each stage */ - const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ - const Word16 stages, /* i : Number of stages */ - const Word16 w[], /* i : Weights Q8 */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 applyDCT_flag, /* i : applyDCT flag */ - Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ - Word16 Idx[] /* o : Indices */ - ); - - void msvq_dec_fx( - const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ - const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const Word16 stages, /* i : Number of stages */ - const Word16 N, /* i : Vector dimension */ - const Word16 maxN, /* i : Codebook dimension */ - const Word16 Idx[], /* i : Indices */ - const Word16 applyIDCT_flag, /* i : applyIDCT flag */ - const Word32 *invTrfMatrix, /* i : synthesis matrix */ - Word32 *uq, /* o : quantized vector */ - Word16 *uq_ind, /* o : quantized vector (fixed point) */ - Word16 exp ); - - void dec_FDCNG_MSVQ_stage1_fx( - Word16 j_full, /* i : index full range */ - Word16 n, /* i : dimension to generate */ - const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ - const DCTTYPE idcttype, /* i : specify which IDCT */ - Word32 *uq, /* o : synthesized stage1 vector Q20 */ - Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ - ); - - void dctT2_N_apply_matrix_fx( - const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ - Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ - const Word16 dct_dim, /* i : dct processing dim possibly truncated */ - const Word16 fdcngvq_dim, /* i : fdcng domain length */ - const Word32 *matrix, /* i : IDCT matrix */ - const Word16 matrix_row_dim, /* i : */ - const DCTTYPE dcttype /* i : matrix operation type */ - ); - - Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb ); - - Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - - void v_mult_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_sub_s16_fx( - const Word16 x1[], /* i : Input vector 1 */ - const Word16 x2[], /* i : Input vector 2 */ - Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void v_sub32_fx( - const Word32 x1[], /* i : Input vector 1 */ - const Word32 x2[], /* i : Input vector 2 */ - Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ - const Word16 N /* i : Vector length */ - ); - - void ivas_swb_tbe_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ - const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ - Word16 Q_exc, - const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ - const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ - Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ - Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ - Word16 *pitch_buf_fx, /* i : Q6 */ - Word16 *Q_white_exc ); - - Word16 swb_bwe_dec_fx32( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ - Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ - Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ - Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - Word16 output_frame /* i : frame length */ - ); - - ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs */ - Word16 synth_fx16[], /* o : synthesis */ - Word16 save_hb_synth_fx16[], /* o : HB synthesis */ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ - ); - - void wtda_fx32( - const Word32 *new_audio, /* i : input audio Q11 */ - Word32 *wtda_audio, /* o : windowed audio Q11 */ - Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ - const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ - const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ - const Word16 L /* i : length */ - ); - - ivas_error core_switching_pre_dec_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 output_frame, /* i : frame length */ - const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ - const Word16 nchan_out, /* i : number of output channels */ - const Word16 last_element_mode, /* i : last_element_mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - Word16 Q_old_synthFB, - Word16 *Q_olapBufferSynth, - Word16 *Q_olapBufferSynth2 ); - - void hp20_fx_32( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - - void hp20_fx_32_opt( - Word32 signal_fx[], - const Word16 lg, - Word32 mem_fx[], - const Word32 Fs ); - - void getTCXMode_ivas_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Decoder_State *st0, /* i : bitstream */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - ); - - void getTCXWindowing_ivas_fx( - const Word16 core, /* i : current frame mode */ - const Word16 last_core, /* i : last frame mode */ - const Word16 element_mode, /* i : element mode */ - TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ - Decoder_State *st0 /* i : bitstream */ - ); - - Word16 ari_start_decoding_14bits_prm_ivas_fx( - const Word16 *ptr, - Word16 bp, - Tastat *s ); - - void generate_masking_noise_ivas_fx( - Word32 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 *exp_out, /* o : time-domain signal exp */ - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 length, /* i : frame size */ - const Word16 core, /* i : core */ - const Word16 return_noise, /* i : noise is returned instead of added */ - const Word16 secondary, /* i : flag to indicate secondary noise generation */ - const Word16 element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void SynthesisSTFT_dirac_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 samples_out, - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - ); - - void generate_stereo_masking_noise_fx( - Word16 *syn, /* i/o: time-domain signal */ - Word16 Q_syn, - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 fadeOut, /* i : only fade out of previous state */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void SynthesisSTFT_fx( - Word32 *fftBuffer, /* i : FFT bins */ - Word32 *timeDomainOutput, - Word32 *olapBuffer, - const Word16 *olapWin, - const Word16 tcx_transition, - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const Word16 element_mode, /* i : element mode */ - const Word16 nchan_out /* i : number of output channels */ - ); - - void FdCng_decodeSID_ivas_fx( - Decoder_State *st /* i/o: decoder state structure */ - ); - - void cldfb_restore_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - ivas_error cldfb_save_memory_ivas_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ - ); - - Word16 sr2fscale( - const Word32 sr_core /* i : internal sampling rate */ - ); - - void Copy_Scale_sig32( - const Word32 x[], /* i : signal to scale input Qx */ - Word32 y[], /* o : scaled signal output Qx */ - const Word16 lg, /* i : size of x[] Q0 */ - const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ - ); - - void swb_pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ - Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ - Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ - Word16 *Q_shb_spch, - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ - Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ - ); - - void core_encode_update_ivas_fx( - Encoder_State *st /* i/o: Encoder state structure */ - ); - - void updt_enc_common_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 Q_new /* i : CUrrent frame scaling */ - ); - - /* o : Q(2x - 31 - gb) */ - Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 gb /* i : guard bits */ - ); - - Word32 sum2_16_exp_fx( - const Word16 *vec, /* i : input vector Q(15 - exp) */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ - ); - - Word32 sum2_32_exp_fx( - const Word32 *vec, /* i : input vector, Qx */ - const Word16 lvec, /* i : length of input vector */ - Word16 *exp, /* i/o: exponent of vector */ - Word16 gb /* i : guard bits */ - ); - - Word32 sum2_32_fx( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *e ); - - void ProcessStereoIGF_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ - Word16 q_pITFMDCTSpectrum_1, - Word16 q_pITFMDCTSpectrum_2, - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - - void IGFEncApplyStereo_fx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ - Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ - Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ - Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ - Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ - Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ - Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ - const Word16 frameno, /* i : flag indicating index of current subfr. */ - const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 mct_on ); - - void IGFSaveSpectrumForITF_ivas_fx( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igfGridIdx, /* i : IGF grid index */ - const Word32 *pITFSpectrum, /* i : MDCT spectrum */ - Word16 exp_pITFSpectrum ); - - Word16 IGFEncWriteBitstream_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 *pBitOffset, /* i : ptr to bitOffset counter */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ - ); - - Word16 IGFSCFEncoderEncode_ivas_fx( - IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ - Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ - const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ - const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ - ); - - Word16 ari_encode_14bits_ext_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s, - Word32 symbol, /* Q0 */ - UWord16 const *cum_freq /* Q0 */ - ); - - Word16 ari_encode_14bits_sign_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Word32 bits, /* Q0 */ - Tastat *s, - Word16 sign /* Q0 */ - ); - - Word16 ari_done_encoding_14bits_ivas_fx( - Word16 *ptr, /* Q0 */ - Word16 bp, /* Q0 */ - Tastat *s ); - - void IGFEncConcatenateBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ - ); - - void hq_generic_hf_encoding_fx( - const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ - Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ - const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ - Word16 length ); - - Word16 ari_decode_14bits_pow_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s, - UWord16 base ); - - Word16 ari_decode_14bits_sign_ivas( - Word16 *ptr, - Word16 bp, - Word16 bits, - Word16 *res, - Tastat *s ); - - void lsf_syn_mem_backup_ivas_fx( - Encoder_State *st_fx, /* i: state structure */ - Word16 *btilt_code_fx, /* i: tilt code Q15 */ - Word32 *gc_threshold_fx, /* i: Q16 */ - Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ - Word16 *next_force_sf_bck_fx, /* o: */ - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ - Word16 *pstreaklen ); - - ivas_error config_acelp1_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 total_brate, /* i : total bitrate */ - const Word32 core_brate_inp, /* i : core bitrate */ - const Word16 core, /* i : core */ - const Word16 extl, /* i : extension layer */ - const Word32 extl_brate, /* i : extension layer bitrate */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const Word16 signaling_bits, /* i : number of signaling bits */ - const Word16 coder_type, /* i : coder type */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 tc_subfr, /* i : TC subfr ID */ - const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ - Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - Word16 *unbits, /* o : number of unused bits */ - const Word16 element_mode, /* i : element mode */ - Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 idchan, /* i : stereo channel ID */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) -#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) -#define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ ); -#endif - -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - ivas_error push_next_indice_( - const char *caller, -#else -ivas_error push_next_indice( -#endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ - ); - -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - ivas_error push_next_bits_( - const char *caller, #else -ivas_error push_next_bits( +void highband_exc_dct_in_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 *mfreq_bindiv, /* i : bin per bands tables */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 Diff_len, /* i : number of bin before cut-off frequency */ + Word16 noise_lev, /* i : pulses dynamic */ + Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 *exc_diffQ, /* i : frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ + Word16 nb_subfr, /* i : Number of subframe considered */ + Word16 *exc_dct_in, /* o : dct of residual signal */ + Word16 last_coder_type, /* i : coding type of last frame */ + Word16 *bitallocation_band, /* i : bit allocation flag of each band */ + const Word16 *lsf_new, /* i : LSFs at the end of the frame */ + Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ + Word16 *last_ener, /* i : frequency energy of last frame */ + Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ + Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ + Word16 bfi, /* i : bad frame indicator */ + const Word16 coder_type, /* i : coder type */ + Word16 bwidth, + Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ + Word16 Qexc_diffQ, + Word16 *Q_exc, + const Word16 GSC_noisy_speech, + Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); +#endif + +void lsf_dec_bfi( + const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ + Word16 *lsf, /*!< o : 14Q1*1.28 quantized ISFs */ + const Word16 *lsfold, /*!< i : 14Q1*1.28 past quantized ISF */ + Word16 *lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */ + const Word16 lsfBase[], /* i : base for differential lsf coding */ + Word16 *mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 *mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */ + Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) Q15*/ + const Word16 last_coder_type, /*!< i : coding type in last good received fr. */ + Word16 L_frame, + const Word16 last_good, /*!< i : last good received frame */ + const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */ + const Word8 plcBackgroundNoiseUpdated, /* i : background noise already updated?*/ + Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */ + Word16 *lsf_cng, /* Q2.56 */ + Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise Q2.56*/ + const Word16 Last_GSC_pit_band_idx, + const Word16 Opt_AMR_WB, /* i : IO flag */ + const Word8 tcxonly, + const short bwidth /* i: coded bandwidth */ +); + +Word16 const *PlcGetLsfBase( + Word16 const lpcQuantization, + Word16 const narrowBand, + Word32 const sr_core ); + +/* Create an instance of type FD_CNG */ +ivas_error createFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + +void initFdCngCom( + HANDLE_FD_CNG_COM hFdCngCom, + Word16 scale ); + +/* Delete the instance of type FD_CNG */ +void deleteFdCngCom_fx( + HANDLE_FD_CNG_COM *hFdCngCom ); + +/* Initialize the spectral partitioning */ +void initPartitions( + const Word16 *part_in, + const Word16 npart_in, + const Word16 startBand, + const Word16 stopBand, + Word16 *part_out, + Word16 *npart_out, + Word16 *midband, + Word16 *psize, + Word16 *psize_norm, + Word16 *psize_norm_exp, + Word16 *psize_inv, + const Word16 stopBandFR ); + +/* Noise estimation using Minimum Statistics (MS) */ +void compress_range( + Word32 *in, + Word16 in_exp, + Word16 *out, + const Word16 len ); + +void expand_range( + Word16 *in, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + +void expand_range_fx( + Word32 *in, // Q25 + Word32 *out, // exp:out_exp + Word16 *out_exp, + const Word16 len ); + +void expand_range_var_exp( + Word16 *in, + Word16 in_exp, + Word32 *out, + Word16 *out_exp, + const Word16 len ); + +void minimum_statistics( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ + Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */ +); + +void minimum_statistics_fx( + Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ + Word16 lenFFT, /* i : Number of FFT partitions */ + Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *msPeriodog, /* i : Periodogram (energies) */ + Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ + Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ + Word32 *msAlpha, /* i/o: Forgetting factors */ + Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ + Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ + Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */ + Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */ + Word32 *msBminWin, /* o : Bias correction factors */ + Word32 *msBminSubWin, /* o : Bias correction factors */ + Word32 *msCurrentMin, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */ + Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */ + Word16 *msLocalMinFlag, /* i : Binary flag */ + Word16 *msNewMinFlag, /* i : Binary flag */ + Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */ + Word16 *msPeriodogBufPtr, /* i/o: Counter */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 enc_dec, /* i : encoder/decoder indicator */ + const Word16 element_mode /* i : IVAS element mode type */ +); + +/* Apply bitrate-dependant scale */ +void apply_scale( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ +); + +Word16 apply_scale_ind( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize /* i : Size of scale table */ +); +void apply_scale_ivas_fx( + Word32 *scale, /* o : scalefactor */ + const Word16 bwmode, /* i : audio bandwidth */ + const Word32 bitrate, /* i : Bit rate */ + const SCALE_SETUP *scaleTable, /* i : Scale table */ + const Word16 scaleTableSize, /* i : Size of scale table */ + Word16 *index ); + +/* Compute the power for each partition */ +void bandcombinepow( + const Word32 *bandpow, /* i : Power for each band */ + const Word16 exp_bandpow, /* i : exponent of bandpow */ + const Word16 nband, /* i : Number of bands */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + const Word16 *psize_inv, /* i : Inverse partition sizes */ + Word32 *partpow, /* o : Power for each partition */ + Word16 *exp_partpow ); + +/* Scale partitions (with smoothing) */ +void scalebands( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + +void scalebands_fx( + const Word32 *partpow, /* i : Power for each partition */ + Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */ + const Word16 npart, /* i : Number of partitions */ + Word16 *midband, /* i : Central band of each partition */ + const Word16 nFFTpart, /* i : Number of FFT partitions */ + const Word16 nband, /* i : Number of bands */ + Word32 *bandpow, /* o : Power for each band */ + const Word16 flag_fft_en ); + +/* STFT analysis filterbank */ +void AnalysisSTFT( + const Word16 *timeDomainInput, /* i : pointer to time signal */ + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ +); + +void AnalysisSTFT_fx( + const Word16 *timeDomainInput, + Word16 Q, + Word32 *fftBuffer, /* o : FFT bins */ + Word16 *fftBuffer_exp, /* i : exponent of FFT bins */ + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ +); + +/* STFT synthesis filterbank */ +void SynthesisSTFT( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +void SynthesisSTFT_ivas_fx( + Word32 *fftBuffer, /* i : pointer to FFT bins */ + Word16 fftBufferExp, /* i : exponent of FFT bins */ + Word16 *timeDomainOutput, /* o : pointer to time domain signal */ + Word16 *olapBuffer, /* i/o : pointer to overlap buffer */ + const PWord16 *olapWin, /* i : pointer to overlap window */ + Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG structure containing all buffers and variables */ + Word16 gen_exc, + Word16 *Q_new, + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +Word32 sign_l( + const Word32 x /* i : input value of x */ +); + +void ivas_updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word32 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ +); + +/* Random generator with Gaussian distribution with mean 0 and std 1 */ +Word32 rand_gauss( + Word16 *seed ); + +Word16 rand_gauss_fix( + Word16 *x, + Word16 *seed ); + +void lpc_from_spectrum( + HANDLE_FD_CNG_COM hFdCngCom, + const Word16 start, /*i : start band*/ + const Word16 stop, /*i : stop band*/ + const Word16 preemph_fac /*i : preemphase factor format Q1.15*/ +); + +void msvq_decoder( + const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook vector dimension */ + const Word16 Idx[], /* i : Indices */ + Word16 *uq /* o : quantized vector */ +); + +void FdCng_exc( + HANDLE_FD_CNG_COM hs, + Word16 *CNG_mode, + Word16 L_frame, + Word16 *lsp_old, + Word16 first_CNG, + Word16 *lsp_CNG, + Word16 *Aq, /* o: LPC coeffs */ + Word16 *lsp_new, /* o: lsp */ + Word16 *lsf_new, /* o: lsf */ + Word16 *exc, /* o: LP excitation */ + Word16 *exc2, /* o: LP excitation */ + Word16 *bwe_exc /* o: LP excitation for BWE */ +); + +void direct_transform_fx( + const Word32 in32_fx[], + Word32 out32_fx[], + const Word16 is_transient, + const Word16 L, + Word16 *Q, + const Word16 element_mode ); + +void preecho_sb_fx( + const Word32 brate, /* i Q0 : core bit-rate */ + Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */ + Word16 q_sig32, /* i Q value for wtda_audio_fx */ + Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */ + Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */ + const Word16 framelength, /* i Q0 : frame length */ + Word16 *memfilt_lb_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */ + Word16 *smoothmem_fx, /* i/o Q15 : memory */ + Word32 *mean_prev_fx, /* i/o Q0 : memory */ + Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */ + Word16 *wmold_hb_fx, /* i/o Q15 : memory */ + Word16 *prevflag, /* i/o Q0 : flag */ + Word16 *pastpre, /* i/o Q0 : flag */ + const Word16 bwidth /* i Q0 : bandwidth */ +); + +void Inverse_Transform( + const Word32 *in_mdct, /* i : i MDCT vector */ + Word16 *Q, /* i/o: Q value of i */ + Word32 *out, /* o : output vector */ + const Word16 is_transient, /* i : transient flag */ + const Word16 L, /* i : output frame length */ + const Word16 L_inner, /* i : length of the transform */ + const Word16 element_mode /* i : IVAS element mode */ +); + +void recovernorm_fx( + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ +); + +Word32 ar_div( Word32 num, Word32 denum ); + +void ar_encoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst, const Word32 max_bits ); +void ar_encoder_done_fx( PARCODEC arInst ); +void ar_decoder_start_fx( PARCODEC arInst, TCQ_PBITSTREAM bsInst ); +void ar_decoder_done_fx( PARCODEC arInst ); +Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32 *savedstates, Word32 noTCQ, Word16 *nzpout, Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer ); + +void TCQLSB_fx( + Word16 bcount, + Word32 *abuffer_fx, + Word16 *mbuffer_fx, + Word32 *sbuffer_fx, + Word16 *dpath ); + +void TCQLSBdec_fx( + Word16 *dpath, + Word16 *mbuffer, + Word16 bcount ); + +void RestoreTCQ_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + +void RestoreTCQdec_fx( + Word16 *magn, + Word16 size, + Word16 *bcount, + Word16 *mbuffer ); + +void InitLSBTCQ_fx( + Word16 *bcount ); + +void SaveTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + +void LoadTCQdata_fx( + PARCODEC arInst, + Word16 *dpath, + Word16 bcount ); + +Word32 encode_position_ari_fx( PARCODEC parenc, Word16 *quants, Word16 size, Word32 *est_bits_frame_fx ); +Word32 encode_magnitude_usq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *est_frame_bits_fx ); +Word32 encode_magnitude_tcq_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npulses, Word16 nzpos, Word32 *savedstates, Word32 *est_frame_bits_fx ); + +Word32 encode_signs_fx( ARCODEC *parenc, Word16 *magn, Word16 size, Word16 npos, Word32 *est_frame_bits_fx ); + +void decode_position_ari_fx( PARCODEC pardec, Word16 size, Word16 npulses, Word16 *nz, Word16 *position ); +void decode_magnitude_usq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out ); +void decode_mangitude_tcq_fx( ARCODEC *pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16 *positions, Word16 *out, Word32 *surplus_fx ); +void decode_signs_fx( ARCODEC *pardec, Word16 size, Word16 *out ); + +Word16 GetScale_fx( + Word16 blen, + Word32 bits_fx, + Word32 *surplus_fx ); + +void srt_vec_ind_fx( + const Word32 *linear, + Word32 *srt, + Word16 *I, + Word16 length ); + +void fill_spectrum_fx( + Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */ + Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */ + const Word16 *R, /* i : number of pulses per band Q0 */ + const Word16 is_transient, /* i : transient flag Q0 */ + Word16 norm[], /* i : quantization indices for norms Q0 */ + const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */ + const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */ + const Word16 nf_idx, /* i : noise fill index Q0 */ + const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */ + const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */ + Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */ + Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */ + Word16 *bwe_seed, /* i/o: random seed for generating BWE i Q0 */ + const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */ + const Word16 core_sfm, /* i : index of the end band for core Q0 */ + const Word16 HQ_mode, /* i : HQ mode Q0 */ + Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */ + const Word32 L_core_brate, /* i : target bit-rate Q0 */ + Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */ + Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */ + Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */ + const Word16 *peak_idx, /* i : peak indices for hvq Q0 */ + const Word16 Npeaks, /* i : number of peaks in hvq Q0 */ + const Word16 *npulses, /* i : number of pulses per band Q0 */ + const Word16 prev_is_transient, /* i : previous transient flag Q0 */ + Word32 *prev_normq, /* i/o: previous norms Q14 */ + Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */ + const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */ + const Word16 *sfmsize, /* i : Length of bands Q0 */ + const Word16 *sfm_start, /* i : Start of bands Q0 */ + const Word16 *sfm_end, /* i : End of bands Q0 */ + Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */ + const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */ + const Word16 num_sfm, /* i : Total number of bands Q0 */ + Word16 *prev_env_Q, + const Word16 num_env_bands, + const Word16 element_mode ); + +void hq_bit_allocation_fx( + const Word32 core_brate, /* i : Core bit-rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + const Word16 hqswb_clas, /* i : HQ class Q0 */ + Word16 *num_bits, /* i/o: Remaining bit budget Q0 */ + const Word16 *normqlg2, /* i : Quantized norms Q0 */ + const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */ + const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */ + Word16 *noise_level, /* o : HVQ noise level Q15 */ + Word16 *R, /* o : Bit allocation per sub band Q0 */ + Word16 *Rsubband, /* o : Fractional bit allocation Q3 */ + Word16 *sum, /* o : Sum of allocated shape bits Q0 */ + Word16 *core_sfm, /* o : Last coded band in core Q0 */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE Q0 */ +); + +void map_quant_weight_fx( + const Word16 normqlg2[], /* i : quantized norms Q0*/ + Word16 wnorm[], /* o : weighted norm Q0*/ + const Word16 is_transient /* i : transient flag Q0*/ +); + +void bitalloc_fx( + Word16 *y, /* i : reordered norm of sub-vectors Q0 */ + Word16 *idx, /* i : reordered sub-vector indices Q0 */ + Word16 sum, /* i : number of available bits Q0 */ + Word16 N, /* i : number of norms Q0 */ + Word16 K, /* i : maximum number of bits per dimension Q0 */ + Word16 *r, /* o : bit-allacation vector Q0 */ + const Word16 *sfmsize, /* i : band length Q0 */ + const Word16 hqswb_clas /* i : signal classification flag Q0 */ +); + +Word16 BitAllocF_fx( + Word16 *y, /* i : norm of sub-vectors :Q0 */ + Word32 bit_rate, /* i : bitrate :Q0 */ + Word16 B, /* i : number of available bits :Q0 */ + Word16 N, /* i : number of sub-vectors :Q0 */ + Word16 *R, /* o : bit-allocation indicator :Q0 */ + Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ + const Word16 hqswb_clas, /* i : hq swb class */ + const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */ +); + +Word16 BitAllocWB_fx( + Word16 *y, /* i : norm of sub-vectors Q0*/ + Word16 B, /* i : number of available bits Q0*/ + Word16 N, /* i : number of sub-vectors Q0*/ + Word16 *R, /* o : bit-allocation indicator Q0*/ + Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/ +); + +void bitallocsum_fx( + Word16 *R, /* i : bit-allocation vector Q0 */ + const Word16 nb_sfm, /* i : number of sub-vectors Q0 */ + Word16 *sum, /* o : total number of bits allocated Q0 */ + Word16 *Rsubband, /* o : rate per subband Q3 */ + const Word16 num_bits, /* i : number of bits Q0 */ + const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */ + const Word16 *sfmsize /* i : band length Q0 */ +); + +Word16 stab_est_fx( + Word16 etot, /* i : Total energy of the current frame Q8*/ + Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8*/ + Word16 *mem_etot, /* i/o : Total energy memory Q8*/ + Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */ + Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */ + Word16 *thresh, /* i/o : Detection thresold Q11*/ + Word16 *last_music_flag, /* i/o : Previous music detection ouptut */ + const Word16 vad_flag /* i : VAD flag */ +); + +void enhancer_fx( + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ +); + +void enhancer_ivas_fx( + const Word16 codec_mode, /* i : flag indicating Codec Mode */ + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 cbk_index, /* i : */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 coder_type, /* i : coder type */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 L_frame, /* i : frame size */ + const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ + Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ + const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ + Word16 *code, /* i/o: innovation Q12 */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ + const Word16 gain_pit, /* i : quantized pitch gain Q14 */ + struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ + const Word16 Q_exc /* i : Q of the excitation */ +); + +Word16 E_UTIL_enhancer( + Word16 voice_fac, /* i : subframe voicing estimation Q15 */ + Word16 stab_fac, /* i : LP filter stability measure Q15 */ + Word32 gain_code, /* i : innovative cb. gain 15Q16 */ + Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ + Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */ + Word16 *code, /* i/o: innovation(in: Q9) code_exp */ + Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */ + Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */ + Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */ + Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */ + Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */ + Word16 coder_type, /* i : coder type */ + Word16 cdk_index, /* i : */ + Word16 L_subfr, /* i : */ + Word16 L_frame, /* i : frame size */ + Word16 Q_new ); + +void phase_dispersion( + const Word32 gain_code, /* i : gain of code 15Q16 */ + const Word16 gain_pit, /* i : gain of pitch Q14 */ + Word16 code[], /* i/o: code vector */ + Word16 *code_e, /* i/o: exponent of code */ + const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */ + Word32 *prev_gain_code, /* i/o: static memory 15Q16 */ + Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */ + Word16 *prev_state, /* i/o: static memory Q0 */ + Word16 L_subfr /* i : subframe length [40,64] */ +); + +void tcx_ltp_get_lpc( + Word16 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word16 *A, /* Qx */ + const Word16 order /* Q0 */ +); + +void tcx_ltp_get_lpc_fx( + Word32 *x, /* Qx */ + const Word16 L, /* Q0 */ + Word32 *A, /* Qx */ + const Word16 order /* Q0 */ +); + +void predict_signal( + const Word16 excI[], /* i : input excitation buffer Qx*/ + Word16 excO[], /* o : output excitation buffer Qx*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i : fraction of lag Q0*/ + const Word16 frac_max, /* i : max fraction Q0*/ + const Word16 L_subfr /* i : subframe size Q0*/ +); + +Word16 tcx_ltp_decode_params( + Word16 *ltp_param, /* Q0 */ + Word16 *pitch_int, /* Q0 */ + Word16 *pitch_fr, /* Q0 */ + Word16 *gain, /* Q13 */ + const Word16 pitmin, /* Q0 */ + const Word16 pitfr1, /* Q0 */ + const Word16 pitfr2, /* Q0 */ + const Word16 pitmax, /* Q0 */ + const Word16 pitres /* Q0 */ +); + +void tcx_ltp_post_fx( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word16 *sig, /* Qx */ + Word16 *tcx_buf /* Qx */ +); + +void tcx_ltp_post_fx32( + Decoder_State *st, + TCX_LTP_DEC_HANDLE hTcxLtpDec, + Word16 core, /* Q0 */ + Word16 output_frame, /* Q0 */ + Word16 delay, /* Q0 */ + Word32 *sig, /* sig_q */ + Word32 *tcx_buf, /* sig_q */ + Word16 sig_q ); + +void Inac_switch_ematch_fx( + Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ + Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ + Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ + const Word16 coder_type, /* i : Coding mode */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 L_frame, /* i : Frame lenght */ + const Word16 Q_exc, /* i : input and output format of exc2 */ + const Word16 bfi, /* i : frame lost indicator */ + const Word16 last_core, /* i : Last core used */ + const Word16 last_codec_mode, /* i : Last codec mode */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 element_mode /* i : element mode */ +); + +/**< out: Q0 | multiplication factor */ +Word16 IGF_ApplyTransFac( + const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */ + const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */ +); + +Word16 IGF_MapBitRateToIndex( + const Word32 brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void IGFCommonFuncsCalcSfbEnergyPowerSpec( + const Word16 startSfb, /**< in: Q0 | start sfb index */ + const Word16 stopSfb, /**< in: Q0 | stop sfb index */ + const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */ + Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */ + Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */ + Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */ + Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */ +); + +void IGFCommonFuncsMDCTSquareSpec( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ +); + +void IGFCommonFuncsMDCTSquareSpec_ivas( + const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */ + const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */ + const Word32 *mdctSpec, /**< in: | MDCT spectrum to square */ + const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */ + Word32 *mdctSquareSpec, /**< out: | MDCT square spectrum */ + Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */ + Word16 indexOffset /**< in: Q0 | index offset */ +); + +Word16 IGFCommonFuncsIGFConfiguration( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +Word16 IGFCommonFuncsIGFGetCFTables_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + const Word16 rf_mode, /* i : flag to signal the RF mode */ + const UWord16 **cf_se00, /* o : CF table for t == 0 and f == 0 */ + const UWord16 **cf_se01, /* o : CF table for t == 0 and f == 1 */ + Word16 *cf_off_se01, /* o : offset for CF table above */ + const UWord16 **cf_se02, /* o : CF tables for t == 0 and f >= 2 */ + const Word16 **cf_off_se02, /* o : offsets for CF tables above */ + const UWord16 **cf_se10, /* o : CF table for t == 1 and f == 0 */ + Word16 *cf_off_se10, /* o : offset for CF table above */ + const UWord16 **cf_se11, /* o : CF tables for t == 1 and f >= 1 */ + const Word16 **cf_off_se11 /* o : offsets for CF tables above */ +); + +Word32 L_multi31x16_X2( + Word16 xh, + Word16 xl, + Word16 y ); + +Word32 mul_sbc_14bits( + Word32 r, /* Q0 */ + Word16 c /* Q0 */ +); + +void ham_cos_window( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + +void ham_cos_window_ivas( + Word16 *fh, + const Word16 n1, + const Word16 n2 ); + +/* o: Q31 */ +Word32 expfp( + const Word16 x, /* i: mantissa Q-e */ + const Word16 x_e ); /* i: exponent Q0 */ + +void powfp_odd2( + const Word16 base, /* Q15 */ + const Word16 exp, /* Q0 */ + Word16 *pout1, /* Q15 */ + Word16 *pout2 ); /* Q15 */ + +void tcx_arith_scale_envelope( + const Word16 L_spec_core, /* i: number of lines to scale Q0 */ + Word16 L_frame, /* i: number of lines Q0 */ + const Word32 env[], /* i: unscaled envelope Q16 */ + Word16 target_bits, /* i: number of available bits Q0 */ + const Word16 low_complexity, /* i: low-complexity flag Q0 */ + Word16 s_env[], /* o: scaled envelope Q15-e */ + Word16 *s_env_e /* o: scaled envelope exponent Q0 */ +); + +void tcx_arith_render_envelope( + const Word16 A_ind[], /* i: LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i: number of spectral lines Q0*/ + const Word16 L_spec, /* Q0 */ + const Word16 preemph_fac, /* i: pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i: A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o: shaped signal envelope Q16*/ +); + +/* returns innovation gain Q16 */ +Word32 calc_gain_inov( + const Word16 *code, /* i : algebraic excitation Q9 */ + const Word16 lcode, /* i : Subframe size Q0 */ + Word32 *dotp, /* o : intermediate result Q31-e */ + Word16 *dotp_e /* o : intermediate result exponent Q0 */ +); + +/////////////////////////////////// +/* Lib_dec */ +////////////////////////////////// + +void ResetSHBbuffer_Dec_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl /* i : BWE extension layer */ +); + +void wb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */ + const Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */ + Word16 *Q_synth ); + +void swb_tbe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/ + Word16 Q_exc, + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/ + Word16 *White_exc16k, /* o : shaped white excitation for the FB TBE */ + Word16 *Q_white_exc, + Word16 *synth, /* o : SHB synthesis/final synthesis */ + Word16 *Q_synth, + Word16 *pitch_buf ); + +void ivas_dequantizeSHBparams_fx_9_1( + Decoder_State *st_fx, + const Word16 extl, /* i : extension layer */ + Word32 extl_brate, /* i : extensiuon layer bitrate */ + Word16 *Q_lsf, /* o : SHB LSF from de-quantization Q15*/ + Word16 *Q_subgain, /* o : SHB subframe gains from de-quantization Q15*/ + Word32 *Q_framegrain, /* o : SHB frame gain from de-quantization Q18*/ + Word16 *uv_flag, /* o : unvoiced flag*/ + Word32 *Q_shb_ener_sf, /* o : Q15 */ + Word16 *Q_shb_res_gshape, /* o : Q14 */ + Word16 *Q_mixFactors, /* o : Q15 */ + Word16 *MSFlag ); + +void fb_tbe_dec_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word16 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp ); + +void fb_tbe_dec_ivas_fx( + Decoder_State *st, /* i/o: encoder state structure */ + const Word16 fb_exc[], /* i : FB excitation from the SWB part */ + Word16 Q_fb_exc, + Word32 *hb_synth, /* o : high-band synthesis */ + Word16 hb_synth_exp, + Word16 *fb_synth_ref, + Word16 Q_fb_synth_ref, + Word16 output_frame ); + +void tbe_read_bitstream_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +); + +void GenTransition_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ + const Word32 output_Fs, /* i : output sampling rate */ + Word16 rf_flag, /* i : RF flag */ + Word32 total_bitrate /* i : total bitrate */ +); + +void GenTransition_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs, /* i : output sampling rate : Q0 */ + const Word16 L_frame, /* i : ACELP frame length : Q0 */ + const Word16 prev_Qx ); + +void GenTransition_WB_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word16 *output, /* o : synthesized transitions signal */ + const Word32 output_Fs /* i : output sampling rate */ +); + +void GenTransition_WB_fx32( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + Word32 *outputHB_fx, /* o : synthesized HB transitions signal : Q11 */ + const Word32 output_Fs /* i : output sampling rate */ +); + +void TBEreset_dec_fx( + Decoder_State *st_fx /* i/o: decoder state structure */ +); + +void td_bwe_dec_init_fx( + TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ + const Word16 extl, /* i : BWE extension layer */ + const Word32 output_Fs /* i : output sampling rate */ +); + +void lsf_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ + Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ +); + +/*! r: index of the maximum value in the input vector */ +Word16 maximum_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_l( + const Word32 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word32 *min_val /* o : minimum value in the input vector */ +); + +void v_multc_fx( + const Word32 x[], /* i : Input vector */ + const Word32 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_fx_16( + const Word32 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word32 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_fx_16_16( + const Word16 x[], /* i : Input vector */ + const Word16 c, /* i : Constant */ + Word16 y[], /* o : Output vector that contains c*x */ + const Word16 N /* i : Vector length */ +); + +void v_add_fx_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_add_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_add_fx_me( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x1_e, /* i : Exponent for input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + const Word16 x2_e, /* i : Exponent for input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 *y_e, /* i : Exponent for output vector */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_add_w64( + const Word64 x1[], /* i : Input vector 1 */ + const Word64 x2[], /* i : Input vector 2 */ + Word64 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_sub_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N, /* i : Vector length */ + const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ +); + +void v_sub_fx_no_hdrm( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +/*! r: dot product of x[] and y[] */ +Word32 dotp_fx32( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ +); + +/*! r: dot product of x[] and y[] in case of overflow*/ +Word32 dotp_fx32_o( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q ); + +Word32 dotp_fx32_fac( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + const Word16 log_len, /* i : max factor added to result q after dot product (equal to log2(n)) */ + Word16 *res_q /*stores resultant Q*/ +); + +Word32 dotp_fx_ivas_fx( + const Word32 x[], /* i : vector x[] */ + Word16 x_e, + const Word32 y[], /* i : vector y[] */ + Word16 y_e, + const Word16 n, /* i : vector length */ + Word16 *out_e ); + +Word32 dotp_fx_guarded( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n /* i : vector length */ +); + +Word32 dotp_me_fx( + const Word32 x[], /* i : vector x[] */ + const Word32 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 exp_x, + Word16 exp_y, + Word16 *exp_suma ); + +void lsf_end_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 mode2_flag, /* Q0 */ + const Word16 coder_type_org, /* i : coding type Q0*/ + const Word16 bwidth, /* i : input signal bandwidth Q0*/ + const Word16 nBits_in, /* i : number of bits used for ISF quantization Q0*/ + Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ + Word16 *lpc_param, /* i : LPC parameters Q0*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ +); + +void lsf_mid_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 lsp_new[], /* i : quantized LSPs from frame endS Q15*/ + Word16 coder_type, /* i : Coder type Q0*/ + Word16 lsp_mid[] /* o : quantized LSPs Q15*/ +); + +void CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 last_element_mode, /* i : last element mode Q0 */ + Word16 Aq[], /* o : LP coefficients Q12 */ + Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ + Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ + Word16 *allow_cn_step, /* o : allow CN step Q0 */ + Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ + Word32 *q_env ); + +void swb_CNG_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ +); + +void swb_CNG_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz Qsyn*/ + Word16 *shb_synth_fx, /* o : high-band CNG synthesis Qx*/ + const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0*/ + const Word16 Qsyn /* i : Q value of ACELP core synthesis */ +); + +void td_cng_dec_init_fx( + DEC_CORE_HANDLE st /* i/o: decoder state structure */ +); + +void set_state( + Word16 *state, + Word16 num, + Word16 N ); + +void concealment_init_x( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + +void concealment_init_ivas_fx( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); + +void concealment_update_x( + const Word16 bfi, + const Word16 core, + const Word16 tonality, + Word32 *invkoef /*Qinvkoef_scale*/, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + +Word16 Sqrt_x_fast( + Word32 value ); + +Word32 dot_w32_accuracy_x( + Word16 *s1, + Word16 *s2, + Word16 nbits, + Word16 N ); + +Word16 int_div_s_x( + Word16 a, + Word16 b ); + +Word16 GetW32Norm_x( + Word32 *s, + Word16 N ); + +Word16 harmo_x( + Word32 *X, + Word16 Framesize, + Word16 pitch ); + +void LpFilter2_x( + Word16 *x, + Word16 *y, + Word16 N ); + +void sig_tilt_x( + Word16 *s, + Word16 FrameSize, + Word32 *enr1, + Word32 *enr2 ); + +void get_maxConv_and_pitch_x( + Word16 *s_LP, + Word16 s, + Word16 e, + Word16 N, + Word32 *maxConv, + Word16 *maxConv_bits, + Word16 *pitch ); + +Word16 get_voicing_x( + Word16 *s_LP, + Word16 pitch, + Word32 covMax, + Word16 maxConv_bits, + Word16 Framesize ); + +void pitch_modify_x( + Word16 *s_LP, + Word16 *voicing, + Word16 *pitch, + Word16 FrameSize ); + +Word16 Is_Periodic_x( + Word32 *mdct_data, + Word16 cov_max, + Word16 zp, + Word32 ener, + Word32 ener_mean, + Word16 pitch, + Word16 Framesize ); + +Word16 get_conv_relation_x( + Word16 *s_LP, + Word16 shift, + Word16 N ); + +void concealment_decode_fix( + Word16 curr_mode, + Word32 *invkoef, + Word16 *invkoef_scale, + T_PLCInfo_HANDLE hPlcInfo ); + +Word32 Spl_Energy_x( + const Word16 *vector, + const Word16 vector_length, + Word16 *scale_factor ); + +void Log10OfEnergy_x( + const Word16 *s, + Word32 *enerlogval, + const Word16 len ); + +void concealment_update2_x( + const Word16 *outx_new, + T_PLCInfo_HANDLE hPlcInfo, + const Word16 FrameSize ); + +Word16 ffr_getSfWord16( + Word16 *vector, /*!< Pointer to i vector */ + Word16 len ); + +void waveform_adj2_fix( + T_PLCInfo_HANDLE hPlcInfo, + Word16 *overlapbuf, + Word16 *outx_new, + const Word16 delay, + const Word16 bfi_cnt, + const Word16 bfi ); + +void concealment_signal_tuning_fx( + Decoder_State *st, + const Word16 bfi, + Word16 *outx_new_fx /*Qoutx_new_fx*/, + const Word16 past_core ); + +void DetectTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + +void RefineTonalComponents( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode ); + +void ivas_RefineTonalComponents_fx( + Word16 indexOfTonalPeak[], + Word16 lowerIndex[], + Word16 upperIndex[], + Word16 phaseDiff[], + Word16 phases[], + Word16 *pNumIndexes, + const Word32 lastPitchLag, + const Word32 currentPitchLag, + const Word16 lastMDCTSpectrum[], + const Word16 lastMDCTSpectrum_exp, + const Word16 scaleFactors[], + const Word16 scaleFactors_exp[], + const Word16 scaleFactors_max_e, + const Word32 secondLastPowerSpectrum[], + const Word16 secondLastPowerSpectrum_e, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ + Word16 element_mode, + const PsychoacousticParameters *psychParamsCurrent ); + +ivas_error PsychoacousticParameters_Init( + const Word32 sr_core, /* i : sampling rate of core-coder */ + const Word16 nBins, /* i : Number of bins (spectral lines) */ + const Word8 nBands, /* i : Number of spectrum subbands */ + const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ + const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ + PsychoacousticParameters *pPsychParams ); + +ivas_error TonalMDCTConceal_Init( + TonalMDCTConcealPtr self, + const Word16 nSamples, + const Word16 nSamplesCore, + const Word16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ +); + +ivas_error TonalMDCTConceal_Init_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const UWord16 nSamples, + const UWord16 nSamplesCore, + const UWord16 nScaleFactors, + TCX_CONFIG_HANDLE hTcxCfg /* TCX config */ +); + +/* Must be called only when a good frame is recieved - concealment is inactive */ +void TonalMDCTConceal_SaveFreqSignal( + TonalMDCTConcealPtr self, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + Word16 nNewSamples, + Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp ); + +void TonalMDCTConceal_SaveFreqSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + const Word32 *mdctSpectrum, + const Word16 mdctSpectrum_exp, + const Word16 nNewSamples, + const Word16 nNewSamplesCore, + const Word16 *scaleFactors, + const Word16 *scaleFactors_exp, + const Word16 gain_tcx_exp, + const Word16 infoIGFStartLine ); + +void TonalMDCTConceal_UpdateState( + TonalMDCTConcealPtr self, + Word16 nNewSamples, + Word32 pitchLag, + Word16 badBlock, + Word8 tonalConcealmentActive ); + +void TonalMDCTConceal_Detect( + const TonalMDCTConcealPtr self, /*IN */ + const Word32 pitchLag, /*IN */ + Word16 *umIndices, /*OUT*/ + Word16 element_mode /* IN */ +); + +void TonalMDCTConceal_Apply( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 *mdctSpectrum_exp /*IN */ +); + +void TonalMDCTConceal_Apply_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ + Word16 mdctSpectrum_exp, /*IN */ + const PsychoacousticParameters *psychParamsCurrent ); + +void TonalMDCTConceal_InsertNoise_ivas_fx( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, + Word16 *mdctSpectrum_exp, + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + const Word16 crossfadeGain, + const Word32 concealment_noise[L_FRAME48k], + const Word16 concealment_noise_e, + const Word32 cngLevelBackgroundTrace_bfi, + const Word16 cngLevelBackgroundTrace_e, + const Word16 crossOverFreq ); + +void TonalMDCTConceal_InsertNoise( + const TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*OUT*/ + Word16 *mdctSpectrum_exp, /*OUT*/ + const Word16 tonalConcealmentActive, + Word16 *pSeed, /*IN/OUT*/ + const Word16 tiltCompFactor, + Word16 crossfadeGain, + const Word16 crossOverFreq ); + +void TonalMDCTConceal_SaveTimeSignal( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 nNewSamples ); + +void TonalMDCTConceal_SaveTimeSignal_ivas_fx( + TonalMDCTConcealPtr hTonalMDCTConc, + Word16 *timeSignal, + Word16 q_timeSignal, + Word16 nNewSamples ); + +void decision_matrix_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ + Word16 *hq_core_type, /* o : HQ core type Q0 */ + Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ +); + +void hf_synth_init_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ +); + +void hf_synth_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero /* o : zero BWE decoder handle */ +); + +void hf_synth_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ +); + +void hf_synth_ivas_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ + Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ + Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ +); + +void hf_synth_amr_wb_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ +); + +void hf_synth_amr_wb_reset_fx( + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ +); + +void hf_synth_amr_wb_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + const Word32 core_brate, /* i : core bitrate Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 *Aq, /* i : quantized Az : Q12*/ + const Word16 *exc, /* i : excitation at 12.8 kHz : Q_exc*/ + Word16 *synth, /* i/o: synthesis signal at 12.8k : Q_syn*/ + Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) Q0*/ + Word16 *synth_out, /* i/o: output signal at output Fs : Q_out*/ + Word16 fmerit, /* i : classify parameter from FEC : Q14*/ + const Word16 *hf_gain, /* i : decoded HF gain Q0*/ + const Word16 *voice_factors, /* i : voicing factors : Q15*/ + const Word16 pitch_buf[], /* i : pitch buffer : Q5*/ + const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8*/ + const Word16 *lsf_new, /* i : ISF vector : Q2*/ + const Word16 Q_exc, /* i : exc scaling */ + const Word16 Q_out /* i : Q_syn2-1 */ +); + +void Init_post_filter_fx( + PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ +); /* i : core decoder parameters */ + +void nb_post_filt_fx( + const Word16 L_frame, /* i : frame length */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *psf_lp_noise, /* i : Long term noise Q8 */ + const Word16 tmp_noise, /* i : noise energy Q0 */ + Word16 *Synth, /* i : 12k8 synthesis Qsyn */ + const Word16 *Aq, /* i : LP filter coefficient Q12 */ + const Word16 *Pitch_buf, /* i : Fractionnal subframe pitch buffer Q0 */ + const Word16 coder_type, /* i : coder_type */ + const Word16 BER_detect, /* i : BER detect flag */ + const Word16 disable_hpf /* i : flag to diabled HPF */ +); + +void formant_post_filt_fx( + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *synth_in, /* i : 12k8 synthesis */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ + Word16 *synth_out, /* i/o: input signal */ + const Word16 L_frame, /* i : frame length */ + const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ + const Word32 brate, /* (i) : bit-rate */ + const Word16 off_flag /* i : off flag */ +); + +void Filt_mu_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr /* i : the length of subframe */ +); + +void Filt_mu_ivas_fx( + Word16 *sig_in, /* i : signal (beginning at sample -1) */ + Word16 *sig_out, /* o : signal with tilt */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 L_subfr, /* i : the length of subframe */ + const Word16 extl ); + +void scale_st_fx( + const Word16 *sig_in, /* i : postfilter i signal */ + Word16 *sig_out, /* i/o: postfilter o signal */ + Word16 *gain_prec, /* i/o: last value of gain for subframe */ + Word16 L_subfr ); + +void blend_subfr2_fx( + Word16 *sigIn1, /* i : i signal for fade-out */ + Word16 *sigIn2, /* i : i signal for fade-in */ + Word16 *sigOut /* o : output signal */ +); + +void init_tcx_window_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, /* i : TCX Config handle */ + const Word32 sr_core, /* i : SR core */ + const Word32 input_Fs, /* i : input/output SR */ + const Word16 L_frame, /* i : L_frame at sr_core */ + const Word16 L_frameTCX, /* i : L_frame at i/o SR */ + const Word16 mdctWindowLength, /* i : window length at sr_core */ + const Word16 mdctWindowLengthFB, /* i : window length at i/o SR */ + const Word16 element_mode /* i : mode of CPE/SCE */ +); + +void init_tcx_cfg_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, /*Q15*/ + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */, + const Word16 fscaleFB ); + +void syn_output_fx( + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + Word16 *synth, /* i/o: fixed point synthesis signal Q_syn2 */ + const Word16 output_frame, /* i : output frame length */ + Word16 *synth_out, /* o : integer 16 bits synthesis signal Q_syn2 */ + const Word16 Q_syn2 /* i : Synthesis scaling factor */ +); + +void unscale_AGC( + const Word16 x[], /* i: 16kHz synthesis Qx */ + const Word16 Qx, /* i: scale factor of x */ + Word16 y[], /* o: output vector Q0 */ + Word16 mem[], /* i/o: mem[2] should be init to [0,0] Q0 */ + const Word16 n /* i: vector size */ +); + +void bass_psfilter_init_fx( + BPF_DEC_HANDLE hBPF /* o : BPF data handle */ +); + +void bass_psfilter_fx( + BPF_DEC_HANDLE hBPF, /* i/o: BPF data handle */ + const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag Q0*/ + Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) Q_syn2-1*/ + const Word16 L_frame, /* i : length of the last frame Q0*/ + Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] Q6*/ + const Word16 bpf_off, /* i : do not use BPF when set to 1 Q0*/ + Word16 v_stab_fx, /* i : stability factor Q15*/ + Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor Q15*/ + const Word16 coder_type, /* i : coder_type Q0*/ + Word16 Q_syn, + Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) Qx*/ +); + +void addBassPostFilter_fx( + const Word16 *harm_timeIn_Fx, /* timeIn_e */ + Word32 **rAnalysis_Fx, /* Qx - 5 */ + Word32 **iAnalysis_Fx, /* Qx - 5 */ + HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx, + Word32 *workBuffer, /* Qx */ + const Word16 timeIn_e, + const Word16 nTimeSlots, /* Q0 */ + const Word16 nTimeSlotsTotal, /* Q0 */ + const Word16 nBandsTotal, /* Q0 */ + CLDFB_SCALE_FACTOR *cldfb_scale ); + +void FEC_exc_estim_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* o : pointer to excitation buffer (with past) */ + Word16 *exc2, /* o : total excitation (for synthesis) */ + Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */ + Word16 *pitch_buf, /* o : Floating pitch for each subframe */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *tmp_tc, /* o : FEC pitch Q6 */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *lsf_new, /* i : ISFs at the end of the frame */ + Word16 *Q_exc, + Word16 *tmp_noise /* o : long-term noise energy Q0 */ +); + +void pitch_pred_linear_fit( + const Word16 bfi_cnt, /* i: bfi counter Q0 */ + const Word16 last_good, /* i: last classification type Q0 */ + Word32 *old_pitch_buf, /* i: pitch lag buffer Q16*/ + Word32 *old_fpitch, /* i: Q16*/ + Word32 *T0_out, /* o: estimated close loop pitch Q16*/ + Word16 pit_min, /* i: Minimum pitch lag Q0 */ + Word16 pit_max, /* i: Maximum pitch lag Q0 */ + Word16 *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain Q0*/ + Word16 limitation, + Word16 plc_use_future_lag, /* i: Q0 */ + Word16 *extrapolationFailed, /* o: flag if extrap decides not to change the pitch Q0 */ + Word16 nb_subfr /* i: number of ACELP subframes */ +); + +void get_subframe_pitch( + Word16 nSubframes, /* i: number of subframes Q0 */ + Word32 pitchStart, /* i: starting pitch lag (in subframe -1) 15Q16*/ + Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) 15Q16*/ + Word32 *pitchBuf /* o: interpolated pitch lag per subframe 15Q16*/ +); + +void PulseResynchronization_fx( + Word16 const *const src_exc, /*i Q15*/ + Word16 *const dst_exc, /*o Q15*/ + Word16 const nFrameLength, /*i Q0 */ + Word16 const nSubframes, /*i Q0 */ + Word32 const pitchStart, /*i Q16*/ + Word32 const pitchEnd /*i Q16*/ +); + +void decod_audio_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ +); + +void gsc_dec_fx( + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ + Word16 *Q_exc ); + +void GSC_dec_init_fx( + GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ +); + +void Es_pred_dec_fx( + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + const Word16 enr_idx, /* i : indice */ + const Word16 nb_bits, /* i : number of bits */ + const Word16 no_ltp /* i : no LTP flag */ +); + +void gain_dec_tc_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ +); + +void gain_dec_tc_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : pitch gain */ + Word32 *gain_code_fx, /* o : Quantized codeebook gain */ + Word16 *gain_inov_fx, /* o : unscaled innovation gain */ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */ +); + +void gain_dec_mless_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr_fx, /* i : subframe number */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *code_fx, /* i : algebraic code excitation */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ +); + +void gain_dec_lbr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 coder_type, /* i : coding type */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 *code_fx, /* i : algebraic excitation Q9 */ + Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ + Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ + Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ + Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ + Word32 gc_mem[], /* i/o: gain_code from previous subframes */ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ + const Word16 L_subfr /* i : subfr lenght */ +); + +void lp_gain_updt_fx( +#ifdef CLEANUP_ACELP_ENC + const Word16 element_mode, /* i : element mode */ +#else + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ +); +void lp_gain_updt_ivas_fx( +#endif + const Word16 i_subfr, /* i : subframe number Q0 */ + const Word16 gain_pit, /* i : Decoded gain pitch Q14 */ + const Word32 norm_gain_code, /* i : Normalised gain code Q16 */ + Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */ + Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */ + const Word16 L_frame /* i : length of the frame */ +); + +/*! r: quantized codebook gain Q16 */ +Word32 gain_dec_gaus_fx( + Word16 index, /* i : quantization index */ + const Word16 bits, /* i : number of bits to quantize */ + const Word16 lowBound, /* i : lower bound of quantizer (dB) */ + const Word16 topBound, /* i : upper bound of quantizer (dB) */ + const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ +); + +void gain_dec_SQ_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 i_subfr, /* i : subframe number */ + const Word16 *code, /* i : algebraic code excitation Q9*/ + const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */ + Word16 *gain_pit, /* o : Quantized pitch gain Q14*/ + Word32 *gain_code, /* o : Quantized codeebook gain Q16*/ + Word16 *gain_inov, /* o : unscaled innovation gain Q12*/ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/ +); + +void gain_dec_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + Word16 *gain_pit, /* o : Quantized pitch gain */ + Word32 *gain_code, /* o : Quantized codeebook gain */ + Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */ + Word16 *gain_inov, /* o : unscaled innovation gain */ + const Word16 *code, /* i : algebraic code excitation */ + Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */ +); + +void transf_cdbk_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */ + const Word32 gain_code, /* i : innovative excitation gain (Q16) */ + Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */ + Word32 *norm_gain_preQ, /* o : normalized prequantizer excitation gain (Q16) */ + Word16 code_preQ[], /* o : prequantizer excitation (Q8) */ + Word16 *unbits /* o : number of AVQ unused bits */ +); + +/* o: decoded gain */ +Word16 gain_dequant_fx( + Word16 index, /* i: quantization index */ + const Word16 min, /* i: value of lower limit */ + const Word16 max, /* i: value of upper limit */ + const Word16 bits, /* i: number of bits to dequantize */ + Word16 *expg ); + +void AVQ_demuxdec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 xriq[], /* o : decoded subvectors [0..8*Nsv-1] Q0*/ + Word16 *nb_bits, /* i/o: number of allocated bits Q0*/ + const Word16 Nsv, /* i : number of subvectors Q0*/ + Word16 nq[], /* i/o: AVQ nq index Q0*/ + Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution Q0*/ + Word16 trgtSvPos /* i : target SV for AVQ bit savings Q0*/ +); + +void AVQ_dec_lpc( + Word16 *indx, /* input: index[] (4 bits per words) Q0*/ + Word16 *nvecq, /* output: vector quantized Q0*/ + Word16 Nsv ); /* input: number of subvectors (lg=Nsv*8) Q0*/ + +void re8_dec_fx( + Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */ + const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */ + const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ +); + +void re8_decode_base_index_fx( + const Word16 n, + UWord16 I, + Word16 *x ); + +void re8_k2y_fx( + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ +); + +void re8_vor_fx( + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ +); + +void re8_PPV_fx( + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ +); + +void dec_pit_exc_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 coder_type, /* i : coding type */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *code_fx, /* o : innovation */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + const Word16 nb_subfr_fx, /* i : Number of subframe considered */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +); + +/* o: pitch value Q16 */ +Word32 Mode2_pit_decode( + const Word16 coder_type, /* i: coding model */ + Word16 i_subfr, /* i: subframe index */ + Word16 L_subfr, + Word16 **pt_indice, /* i/o: quantization indices pointer */ + Word16 *T0, /* i/o: close loop integer pitch Q0 */ + Word16 *T0_frac, /* o: close loop fractional part of the pitch Q0 */ + Word16 *T0_res, /* i/o: pitch resolution Q0 */ + Word16 *T0_min, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_min_frac, /* i/o: lower limit for close-loop search Q0 */ + Word16 *T0_max, /* i/o: higher limit for close-loop search Q0 */ + Word16 *T0_max_frac, /* i/o: higher limit for close-loop search Q0 */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr1b, + Word16 pit_fr2, + Word16 pit_max, + Word16 pit_res_max ); + +void Mode2_abs_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 *T0_res, /* o: pitch resolution Q0 */ + Word16 **pt_indice, /* i/o: pointer to Vector of Q indexes */ + Word16 pit_min, + Word16 pit_fr1, + Word16 pit_fr2, + Word16 pit_res_max ); + +void Mode2_delta_pit_dec( + Word16 *T0, /* o: integer pitch lag Q0 */ + Word16 *T0_frac, /* o: pitch fraction Q0 */ + Word16 T0_res, /* i: pitch resolution Q0 */ + Word16 *T0_min, /* i: delta search min Q0 */ + Word16 *T0_min_frac, /* i: delta search min Q0 */ + Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ +); + +/* o : floating pitch value */ +Word16 pit_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ +); + +void pit_Q_dec_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 delta, /* i : Half the CL searched interval */ + const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ +); + +void pit16k_Q_dec_fx( + const Word16 pitch_index, /* i : pitch index */ + const Word16 nBits, /* i : # of Q bits */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + Word16 *T0_min, /* i/o: delta search min */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ +); + +void abs_pit_dec_fx( + const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */ + Word16 pitch_index, /* i: pitch index */ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + Word16 *T0, /* o: integer pitch lag */ + Word16 *T0_frac /* o: pitch fraction */ +); + +void delta_pit_dec_fx( + const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */ + const Word16 pitch_index, /* i : pitch index */ + Word16 *T0, /* o : integer pitch lag */ + Word16 *T0_frac, /* o : pitch fraction */ + const Word16 T0_min /* i : delta search min */ +); + +void limit_T0_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 delta, /* i : Half the close-loop searched interval */ + const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */ + const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */ + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_max /* o : higher pitch limit */ +); + +void limit_T0_voiced( + const Word16 nbits, + const Word16 res, + const Word16 T0, /* i : rough pitch estimate around which the search is done */ + const Word16 T0_frac, /* i : pitch estimate fractional part */ + const Word16 T0_res, /* i : pitch resolution */ + Word16 *T0_min, /* o : lower pitch limit */ + Word16 *T0_min_frac, /* o : lower pitch limit */ + Word16 *T0_max, /* o : higher pitch limit */ + Word16 *T0_max_frac, /* o : higher pitch limit */ + const Word16 pit_min, /* i : Minimum pitch lag */ + const Word16 pit_max /* i : Maximum pitch lag */ +); + +void inov_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ +); + +void inov_decode_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate Q0 */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */ + const Word16 L_frame, /* i : length of the frame Q0 */ + const Word16 sharpFlag, /* i : formant sharpening flag Q0 */ + const Word16 i_subfr, /* i : subframe index Q0 */ + const Word16 *p_Aq, /* i : LP filter coefficients Q12 */ + const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */ + const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/ + Word16 *code, /* o : algebraic excitation Q12 */ + const Word16 L_subfr /* i : subframe length Q0 */ +); + +void dec_acelp_4t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 nbbits, /* i : number of bits per codebook */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/ + const Word16 Opt_AMR_WB ); + +void D_ACELP_decode_43bit_fx( + UWord16 idxs[], + Word16 code[], + Word16 *pulsestrack ); + +void D_ACELP_indexing_fx( + Word16 code[], + PulseConfig config, + Word16 num_tracks, + Word16 index[], + Word16 *BER_detect ); + +void fcb_pulse_track_joint_decode_fx( + UWord16 *idxs, + Word16 wordcnt, + UWord32 *index_n, + Word16 *pulse_num, + Word16 track_num ); + +void dec_acelp_2t32_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[] /* o: algebraic (fixed) codebook excitation */ +); + +void dec_acelp_1t64_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ + const Word16 L_subfr /* i : sub frame lenght*/ +); + +ivas_error acelp_core_switch_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_subfr_out, /* o : synthesized ACELP subframe Q_syn*/ + Word16 *tmp_synth_bwe, /* o : synthesized ACELP subframe BWE Q_syn*/ + const Word16 output_frame, /* i : input frame length */ + const Word16 core_switching_flag, /* i : core switching flag */ + Word16 *mem_synth, /* o : synthesis to overlap */ + Word16 *Q_syn ); + +ivas_error acelp_core_switch_dec_bfi_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ +); + +ivas_error acelp_core_switch_dec_bfi_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 synth_out[], /* o : synthesis Q_syn */ + const Word16 coder_type /* i : coder type */ +); + +void pred_lt4( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +); + +void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +); + +void pred_lt4_tc_fx( + Word16 exc[], /* i/o: excitation buffer Q0*/ + const Word16 T0, /* i : integer pitch lag Q0*/ + Word16 frac, /* i: fraction of lag Q0*/ + const Word16 *win, /* i : interpolation window Q14*/ + const Word16 imp_pos, /* i : glottal impulse position Q0*/ + const Word16 i_subfr /* i : subframe index Q0*/ +); + +void pvq_decode_frame_fx( + Decoder_State *st_fx, + Word16 *coefs_quant, /* o : quantized coefficients */ + Word16 *npulses, /* o : number of pulses per band */ + Word16 *pulse_vector, /* o : non-normalized pulse shapes */ + const Word16 *sfm_start, /* i : indices of first coefficients in the bands */ + const Word16 *sfm_end, /* i : indices of last coefficients in the bands */ + const Word16 *sfmsize, /* i : band sizes */ + const Word16 nb_sfm, /* i : total number of bands */ + const Word16 *R, /* i : bitallocation per band */ + const Word16 pvq_bits, /* i : number of bits avaiable */ + const Word16 core /* i : core */ +); + +Word16 pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + +Word16 ivas_pvq_core_dec_fx( + Decoder_State *st_fx, + const Word16 *sfm_start, + const Word16 *sfm_end, + const Word16 *sfmsize, + Word16 coefs_quant[], /* o : output MDCT */ + Word16 *Q_coefs, + Word16 bits_tot, + Word16 nb_sfm, + Word16 *R, /* Q3 */ + Word16 *Rs, + Word16 *npulses, + Word16 *maxpulse, + const Word16 core ); + +void decode_energies_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 Np, + Word16 *dim_part, + Word16 *bits_part, + Word16 *g_part, /* Q15 */ + Word16 qband, + Word16 *bits_left, + Word16 dim, + const Word16 strict_bits ); + +void rc_dec_init_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 tot_bits /* i : Total bit budget */ +); + +/* o : Decoded cumulative frequency */ +UWord32 rc_decode_fx( + Word16 *BER_detect, /* o : Bit error detection flag */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Total cumulative frequency */ +); + +void rc_dec_update_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + + UWord32 cum_freq, /* i : Cumulative frequency */ + UWord32 sym_freq /* i : Symbol frequency */ +); + +/* o : Decoded value */ +Word32 rc_dec_bits_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 bits /* i : Number of bits */ +); + +/* o : Decoded value */ +UWord32 rc_dec_uniform_fx( + Decoder_State *st_fx, /* i/o: Decoder State */ + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + UWord32 tot /* i : Maximum value */ +); + +void rc_dec_finish_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ /* i/o: PVQ decoder handle */ +); + +void pvq_decode_fx( + Decoder_State *st_fx, + PVQ_DEC_HANDLE hPVQ, /* i/o: PVQ decoder handle */ + Word16 *xq, /* o: decoded vector (Q15) */ + Word16 *y, /* o: decoded vector (non-scaled int) */ + const Word16 k_val, /* i: number of allocated pulses */ + const Word16 dim, /* i: Length of vector */ + const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */ +); +void nelp_decoder_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *exc_nelp, /* o : adapt. excitation/total exc Q0 */ + Word16 *exc, /* o : adapt. excitation exc Q_exc */ + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate Q0 */ + const Word16 coder_type, /* i : coding type Q0 */ + Word16 *gain_buf /* Q14 */ +); + +void decod_nelp_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 *tmp_noise_fx, /* o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/ + Word16 *exc_fx, /* o : adapt. excitation exc */ + Word16 *exc2_fx, /* o : adapt. excitation/total exc */ + Word16 *voice_factors, /* o : Voice factor */ + Word16 *bwe_exc, + Word16 *Q_exc, + Word16 bfi, /* i : frame error rate */ + Word16 *gain_buf /*Q14*/ +); + +void lp_filt_exc_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 codec_mode, /* i : coder mode */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 L_subfr, /* i : subframe size */ + const Word16 L_frame, /* i : frame size */ + Word16 lp_flag, /* i : operation mode signalling */ + Word16 *exc ); + +void FEC_lsf2lsp_interp( + Decoder_State *st, /* i/o: Decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + Word16 *Aq, /* o : calculated A(z) for 4 subframes */ + Word16 *lsf, /* o : estimated LSF vector */ + Word16 *lsp /* o : estimated LSP vector */ +); + +ivas_error createFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + +void initFdCngDec_fx( + DEC_CORE_HANDLE st, /* i/o: decoder state structure */ + const Word16 scale ); + +/* Delete the instance of type FD_CNG */ +void deleteFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); + +/* Configure CLDFB-CNG */ +void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the CLDFB-based CNG process */ + Word16 bandwidth, + Word32 bitrate, + Word16 L_frame, + const Word16 Last_L_frame, + const Word16 element_mode ); + +Word16 ApplyFdCng_fx( + Word16 *timeDomainInput, /* i : pointer to time domain input */ + Word16 Q, + Word32 *powerSpectrum, + Word16 Q_power_spectrum, + Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ + Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */ + Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ + Decoder_State *st, + const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ + Word16 is_music ); + +/* Perform noise estimation */ +void perform_noise_estimation_dec_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain i */ + const Word16 Q, + HANDLE_FD_CNG_DEC hFdCngDec /* i/o: FD_CNG structure containing all buffers and variables */ +); + +void perform_noise_estimation_dec_ivas_fx( + const Word16 *timeDomainInput, /* i: pointer to time domain input */ + const Word16 Q, + Word32 *power_spectrum, + Word16 Q_power_spectrum, + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 last_L_frame, /* i : frame length of the last frame at internal Fs */ + const Word32 last_core_brate, /* i : previous frame core bitrate */ + const Word16 VAD /* i : VAD flag in the decoder */ +); + +/* Decode the CLDFB-CNG bitstream */ +void FdCng_decodeSID_fx( + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Decoder_State *corest ); /* i/o: decoder state structure */ + +void noisy_speech_detection_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ + const Word16 vad, /* i : VAD flag */ + const Word16 *syn, /* i : i time-domain frame */ + const Word16 Q ); + +void generate_comfort_noise_dec_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ +); + +void generate_comfort_noise_dec_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec, + Word16 *Q_new, + Word16 gen_exc, + const Word16 nchan_out /* i : number of output channels */ +); + +void generate_comfort_noise_dec_hf_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec ); + +void generate_comfort_noise_dec_hf_ivas_fx( + Word32 **bufferReal, /* o : matrix to real part of input bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of input bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 cng_coh_flag /* i : CNG Flag for coherence handling */ +); + +/* Generate the comfort noise based on the target noise level */ +void generate_masking_noise_fx( + Word16 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 Q, + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 length, + Word16 core ); + +void generate_masking_noise_update_seed_fx( + HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ +); + +void generate_masking_noise_mdct_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 L_frame ); + +void generate_masking_noise_mdct_ivas_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); + +ivas_error init_decoder_fx( + Decoder_State *st_fx, /* o : Decoder static variables structure */ + const Word16 idchan, /* i : channel ID */ + const MC_MODE mc_mode /* i : MC mode */ +); + +void reset_preecho_dec_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ +); + +void destroy_cldfb_decoder_fx( + Decoder_State *st_fx /* o: Decoder static variables structure */ +); + +void destroy_cldfb_encoder_fx( + Encoder_State *st /* i/o: state structure */ +); + +Word16 WB_BWE_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *WB_fenv /*Q15*/ +); + +Word16 wb_bwe_dec_fx( + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *voice_factors_fx, /* i : voicing factors Q15 */ + const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *Qpost ); + +/* o : BWE class */ +Word16 swb_bwe_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 core, /* i : core */ + Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ + Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ + const Word16 hr_flag, /* i : high rate flag */ + const Word16 hqswb_clas /* i : HQ BWE class */ +); + +/*o :Q_syn_hb*/ +Word16 swb_bwe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *Qpost ); + +void fd_bwe_dec_init( + Decoder_State *st_fx, /* i/o: decoder state structure */ + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ +); + +void hq_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *audio_fx, /* i : input audio signal Q0 */ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 Voicing_flag, /* i : Voicing flag for FER method selection Q0*/ + const Word16 vad_hover_flag /* i : VAD hangover flag Q0*/ +); + +void hq_core_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word16 synth[], /* o : output synthesis Q_synth*/ + Word16 *Q_synth, /* o : Q value of synth */ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 hq_core_type, /* i : HQ core type Q0*/ + const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag Q0*/ +); + +void HQ_core_dec_init_fx( + HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ +); + +void HQ_nbfec_init_fx( + HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ +); + + +void hq_ecu_fx( + const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ + Word32 *ecu_rec, /* o : reconstructed frame in tda domain */ + Word16 *time_offs, + Word16 *X_sav, + Word16 *Q_spec, /* i/o : Q value of stored spectrum */ + Word16 *num_p, + Word16 *plocs, + Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */ + const Word16 env_stab, + Word16 *last_fec, + const Word16 ph_ecu_HqVoicing, + Word16 *ph_ecu_active, /* i : Phase ECU active flag */ + Word16 *gapsynth, + const Word16 prev_bfi, /* i : indicating burst frame error */ + const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */ + Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients */ + Word16 *Xavg, /* i/o: Frequency group average gain to fade to */ + Word16 *beta_mute, /* o : Factor for long-term mute */ + const Word16 output_frame, /* i : frame length */ + Decoder_State *st_fx /* i/o: decoder state structure */ +); + +void hq_lr_dec_fx( + Decoder_State *st_fx, /* i/o: : decoder state structure */ + Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */ + const Word16 inner_frame, /* i : Q0 : inner frame length */ + Word16 num_bits, /* i : Q0 : number of available bits */ + Word16 *is_transient_fx /* o : Q0 : transient flag */ +); + +/* o : Number of bits Q0*/ +Word16 decode_envelope_indices_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : starting band index Q0*/ + const Word16 num_sfm, /* i : Number of subbands Q0*/ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ + Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ +); + +void dequantize_norms_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : First SDE encoded norm Q0*/ + const Word16 num_sfm, /* i : Number of norms Q0*/ + const Word16 is_transient, /* i : Transient flag Q0*/ + Word16 *ynrm, /* o : Decoded norm indices Q0*/ + Word16 *normqlg2 /* o : Log2 of decoded norms Q0*/ +); + +void hdecnrm_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 numNorms, /* (i) number of norms Q0*/ + Word16 *index ); /* (o) indices of quantized norms Q0*/ + +Word16 decode_huff_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *hufftab, + Word16 *rbits ); + +void hdecnrm_context_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* Q0 */ + Word16 *index, /* Q0 */ + Word16 *n_length /* Q0 */ +); + +void hdecnrm_resize_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ +); + +void huff_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : Number of codewords to decode Q0*/ + const Word16 buffer_len, /* i : Number of bits to read Q0*/ + const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ + const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ + const Word16 *offset, /* i : Offset for first codeword Q0*/ + const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ + Word16 *index /* o : Decoded index Q0*/ +); + +void hdecnrm_tran_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ +); + +void tcq_core_LR_dec_fx( + Decoder_State *st_fx, + Word16 *inp_vector_fx, /*x5 */ + const Word16 bit_budget, /*Q0 */ + const Word16 BANDS, /*Q0 */ + const Word16 *band_start, /*Q0 */ + const Word16 *band_width, /*Q0 */ + Word32 *Rk_fx, /*Q16*/ + Word16 *npulses, /*Q0 */ + Word16 *k_sort, /*Q0 */ + const Word16 *p2a_flags, /*Q0 */ + const Word16 p2a_bands, /*Q0 */ + const Word16 *last_bitalloc, /*Q0 */ + const Word16 input_frame, /*Q0 */ + const Word16 adjustFlag, /*Q0 */ + const Word16 *is_transient /*Q0 */ +); + +void HQ_FEC_processing_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */ + Word16 is_transient, /* i : Old flag for transient */ + Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */ + Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */ + Word16 num_Sb, /* i : Number of sub-band group */ + Word16 nb_sfm, /* i : Number of sub-band */ + Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */ + Word16 output_frame, /* i : Frame size */ + const Word16 *sfm_start, /* i : Start of bands */ + const Word16 *sfm_end /* i : End of bands */ +); + +void HQ_FEC_Mem_update_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 *t_audio_q_fx, /*Q12*/ + Word32 *normq_fx, /*Q14*/ + Word16 *ynrm, + Word16 *Num_bands_p, + Word16 is_transient, + Word16 hqswb_clas, + Word16 c_switching_flag, + Word16 nb_sfm, + Word16 num_Sb, + Word16 *mean_en_high_fx, /*Q5*/ + Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ + Word16 output_frame ); + +void time_domain_FEC_HQ_fx( + Decoder_State *st_fx, /* i : Decoder State */ + Word32 *wtda_audio_fx, /* i : i */ + Word16 *out_fx, /* o : output audio */ + Word16 mean_en_high_fx, /* i : transient flag */ + const Word16 output_frame, + Word16 *Q_synth ); + +void hq_pred_hb_bws_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *ynrm, /* i : norm quantization index vector Q0*/ + const Word16 length, /* i : frame length Q0*/ + const Word16 hqswb_clas, /* i : HQ SWB class Q0*/ + const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1*/ +); + +void hq_hr_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure fx */ + Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */ + const Word16 length, /* i : frame length Q0 */ + Word16 num_bits, /* i : number of available bits Q0 */ + Word16 *ynrm, /* o : norm quantization index vector Q0 */ + Word16 *is_transient, /* o : transient flag Q0 */ + Word16 *hqswb_clas, /* o : HQ SWB class Q0 */ + Word16 *SWB_fenv, /* o : SWB frequency envelopes Q1 */ + const Word16 core_switching_flag /* i : Core switching flag Q1 */ +); + +/* o : Consumed bits */ +Word16 hq_classifier_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : Core bit rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + Word16 *is_transient, /* o : Transient flag Q0 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +void hvq_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 num_bits, /* i : Number of available bits */ + const Word32 core_brate, /* i : Core bit-rate */ + const Word16 *ynrm, /* i : Envelope coefficients Q0 */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *noise_level, /* o : Noise level in Q15 */ + Word16 *peak_idx, /* o : Peak position vector */ + Word16 *Npeaks, /* o : Total number of peaks */ + Word32 *coefsq_norm, /* o : Output vector in Q12 */ + const Word16 core ); + +Word16 hvq_pvq_bitalloc_fx( + Word16 num_bits, /* i/o: Number of available bits (including gain bits) */ + const Word32 brate, /* i : bitrate */ + const Word16 bwidth_fx, /* i : Encoded bandwidth */ + const Word16 *ynrm, /* i : Envelope coefficients */ + const Word32 manE_peak, /* i : Peak energy mantissa */ + const Word16 expE_peak, /* i : Peak energy exponent */ + Word16 *Rk, /* Q3 o : bit allocation for concatenated vector */ + Word16 *R, /* Q0 i/o: Global bit allocation */ + Word16 *sel_bands, /* Q0 o : Selected bands for encoding */ + Word16 *n_sel_bands /* Q0 o : No. of selected bands for encoding */ +); + +void hq_configure_bfi_fx( + Word16 *nb_sfm, /* o : Number of sub bands Q0*/ + Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0*/ + Word16 *num_bands_p, /* o : FEC sub bands Q0*/ + const Word16 **sfmsize, /* o : Subband bandwidths Q0*/ + const Word16 **sfm_start, /* o : Subband start coefficients Q0*/ + const Word16 **sfm_end /* o : Subband end coefficients Q0*/ +); + +void bandwidth_switching_detect_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +); + +void bandwidth_switching_detect_ivas_fx( + Decoder_State *st_fx /* i/o: encoder state structure */ +); + +void bw_switching_pre_proc_fx( + const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz Qx*/ + Decoder_State *st_fx /* i/o: decoder state structure */ +); + +ivas_error core_switching_pre_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output_frame /* i : frame length Q0*/ +); + +ivas_error core_switching_post_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth Qsynth*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ +); + +ivas_error core_switching_post_dec_ivas_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ + const Word16 output_frame, /* i : frame length Q0*/ + const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ + const Word16 nchan_out, /* i : number of output channels Q0*/ + const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ + Word16 *Qsynth /* i/o: Scaling of ACELP exit (Q_syn2-1) or HQ exit (Qsynth); changes after this function */ +); + +void core_switching_hq_prepare_dec_fx( + Decoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *num_bits, /* i/o: bit budget update Q0*/ + const Word16 output_frame /* i : output frame length Q0*/ +); + +ivas_error amr_wb_dec_fx( + Word16 output_sp[], /* o : synthesis output */ + Decoder_State *st_fx /* o : Decoder static variables structure */ +); + +void amr_wb_dec_init_fx( + AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ +); + +void updt_dec_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 *old_exc_fx, /* i : buffer of excitation */ + const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */ + const Word16 Es_pred, /* i : predicited scaled innovation energy */ + const Word16 *Aq, /* i : A(z) quantized for all subframes */ + const Word16 *lsf_new_fx, /* i : current frame LSF vector */ + const Word16 *lsp_new_fx, /* i : current frame LSP vector */ + const Word16 voice_factors[], /* i : voicing factors */ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ + const Word16 *gain_buf /*Q14*/ +); + +void updt_IO_switch_dec_fx( + const Word16 output_frame, /* i : output frame length */ + Decoder_State *st_fx /* o : Decoder static variables structure */ +); + +void updt_bw_switching_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *synth, /* i : synthesis signal Qpost */ + const Word16 Qpost ); + +void updt_dec_common_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 hq_core_type_fx, /* i : HQ core type */ + const Word16 concealWholeFrameTmp, /* i : concealWholeFrameTmp flag */ + const Word16 *synth, /* i : decoded synthesis */ + const Word16 Qpostd /* i : Synthesis Q value */ +); + +void update_decoder_LPD_cng( + Decoder_State *st, + Word16 coder_type, + Word16 *timeDomainBuffer, + Word16 *A, + Word16 *bpf_noise_buf ); + +void FEC_clas_estim_fx( + Decoder_State *st_fx, /* i/o: decoder state handle */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ + const Word16 L_frame, /* i : length of the frame */ + Word16 *clas, /* i/o: frame classification */ + const Word16 coder_type, /* i : coder type */ + const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ + Word16 *syn, /* i : synthesis buffer */ + Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ + Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ + Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ + Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ + Word16 *Last_ener, /* i/o: last_energy frame A*/ + Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ + Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ + Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ + Word16 Q_syn, /* i : Synthesis scaling */ + Word16 *class_para, /* o : classification para. fmerit1 A*/ + Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ + Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation B*/ + Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ + Word16 mode, /* i : signal classifier mode B*/ + Word16 bfi, /* i : bad frame indicator B*/ + Word32 last_core_brate, /* i : bitrate of previous frame */ + const Word16 FEC_mode /* i : ACELP FEC mode */ +); + +Word16 FEC_pos_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ + Word32 *enr_q, /* o : decoded energy in Q0 */ + const Word16 nBits_es_Pred /* i : number of bits for Es_pred Q */ +); + +void post_decoder( + Decoder_State *st, + Word16 synth_buf[], /* Q0 */ + Word16 pit_gain[], /* Q14 */ + Word16 pitch[], /* Q0 */ + Word16 signal_out[], /* Q0 */ + Word16 *bpf_noise_buf /* Q0 */ +); + +void post_decoder_ivas_fx( + Decoder_State *st, + Word16 synth_buf[], // Q0 + Word16 pit_gain[], // Q14 + Word16 pitch[], // Q0 + Word16 signal_out[], // Q0 + Word16 *bpf_noise_buf // Q0 +); + +void cldfb_synth_set_bandsToZero( + Decoder_State *st, + Word32 **rAnalysis, + Word32 **iAnalysis, + const Word16 nTimeSlots, + const CLDFB_SCALE_FACTOR scaleFactor ); + +void FEC_pitch_estim_fx( + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 last_core, /* i : last core */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 clas, /* i : current frame classification */ + const Word16 last_good, /* i : last good clas information */ + const Word16 pitch_buf[], /* i : Floating pitch for each subframe */ + const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ + Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ + Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ + Word16 *upd_cnt, /* i/o: update counter */ + const Word16 coder_type, /* i : coder_type */ + Word16 element_mode /* i : element mode */ +); + +void FEC_scale_syn_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ + Word16 clas, /* i/o: frame classification */ + const Word16 last_good, /* i: last good frame classification */ + Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ + const Word16 *pitch, /* i: pitch values for each subframe */ + Word32 L_enr_old, /* i: energy at the end of previous frame */ + Word32 L_enr_q, /* i: transmitted energy for current frame */ + const Word16 coder_type, /* i: coder type */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ + Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ + Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ + const Word16 bfi, /* i: current frame BFI */ + const Word32 total_brate, /* i: total bitrate */ + const Word16 prev_bfi, /* i: previous frame BFI */ + const Word32 last_core_brate, /* i: previous frame core bitrate */ + Word16 *exc, /* i/o: excitation signal without enhancement */ + Word16 *exc2, /* i/o: excitation signal with enhancement */ + Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ + Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ + const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ + Word16 *mem_syn, /* o: initial synthesis filter states */ + Word16 Q_exc, + Word16 Q_syn, + const Word16 element_mode, /* i : element mode */ + const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ + const Word16 force_scaling /* i : force scaling */ +); + +void LD_music_post_filter_fx( + MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ + const Word16 dtc_in[], /* i : i synthesis Qdct */ + Word16 dtc_out[], /* o : output synthesis Qdct */ + const Word32 core_brate, /* i : core bitrate Q0 */ + Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ + const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ + const Word16 Last_coder_type, /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ +); + +void Prep_music_postP_fx( + Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ + Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ + Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ + const Word16 last_core, /* i : last core */ + const Word16 element_mode, /* i : element mode */ + const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ + Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ + const Word16 Q_exc, /* i : excitation scaling */ + Word16 *qdct /* o : Scaling factor of dct coefficient */ +); + +void Post_music_postP_fx( + Word16 dct_buffer_in[], /* i/o: excitation buffer */ + Word16 *exc2, /* i/o: Current excitation to be overwriten */ + const Word16 *mem_tmp, /* i : previous frame synthesis memory */ + Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ + const Word16 *Aq, /* i : LPC filter coefficients */ + Word16 *syn, /* i/o: 12k8 synthesis */ + Word16 *Q_exc, /* i : excitation scaling */ + Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ + Word16 *Q_syn, /* i : Current frame synthesis scaling */ + Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ + const Word16 IsIO, /* i : Flag to indicate IO mode */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ + Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ + Word16 *mem_agc, + PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ +); + +void music_postfilt_init( + MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ +); + +void improv_amr_wb_gs_fx( + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 locattack, /* i : Flag for a detected attack Q0*/ + Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ + Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ +); + +void decod_amr_wb_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* i : LP filter coefficients */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *gain_buf /* o : floating pitch gain for each subframe Q14 */ +); + +void CNG_reset_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *pitch_buf, /* o : floating pitch for each subframe Q6*/ + Word16 *voice_factors /* o : voicing factors Q15*/ +); + +ivas_error ppp_voiced_decoder_fx( + Decoder_State *st_fx, /* i/o: state structure */ + Word16 *out_fx, /* o : residual signal */ + const Word16 *lpc2_fx, /* i : current frame LPC */ + Word16 *exc_fx, /* i : previous frame excitation */ + Word16 *pitch, /* o : floating pitch values for each subframe */ + Word16 bfi /* i : Frame error rate */ +); + +void sc_vbr_dec_init( + SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ +); + +ivas_error ppp_quarter_decoder_fx( + DTFS_STRUCTURE *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */ + Word16 prevCW_lag_fx, /* i : Previous lag */ + Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */ + Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */ + Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */ + Word16 bfi, /* i : FER flag */ + Word16 *S_fx, /* i : sine table, Q15 */ + Word16 *C_fx, /* i : cosine table, Q15 */ + DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ + Decoder_State *st_fx ); + +void open_decoder_LPD_fx( + Decoder_State *st, + const Word32 total_brate, /* Q0 */ + const Word16 bwidth /* Q0 */ +); + +void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + +void reset_tcx_overl_buf_fx( + TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ +); + +void acelp_plc_mdct_transition_fx( + Decoder_State *st /* i/o: Decoder state */ +); + +void cldfb_reset_memory_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +void tcxltp_dec_init_fx( + TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ + const Word16 ini_frame, /* Q0 */ + const Word16 last_codec_mode, /* Q0 */ + const Word16 element_mode, /* Q0 */ + const Word16 pit_max, /* Q0 */ + const Word32 sr_core ); /* Q0 */ + +/* o : Exponent of SHB synthesis */ +Word16 swb_bwe_dec_hr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ + const Word16 exp, /* i : Exponent of core synthesis */ + Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ + const Word16 output_frame, /* i : frame length */ + const Word16 unbits, /* i : number of core unused bits */ + const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ +); + +void hr_bwe_dec_init( + HR_BWE_DEC_HANDLE hBWE_FD_HR /* i/o: HR BWE data handle */ +); + +void swb_hr_noise_fill_fx( + const Word16 is_transient, /* i : transient flag */ + const Word16 spect_start, /* i : spectrum start point */ + const Word16 spect_end, /* i : spectrum end point */ + const Word16 tilt_wb, /* i : tilt of wideband signal Q11 */ + const Word16 pitch, /* i : pitch value Q15 */ + const Word16 nq[], /* i : AVQ nq index */ + Word16 Nsv, /* i : number of subband */ + Word16 *bwe_highrate_seed, /* i/o: seed of random noise */ + Word16 *t_audio, /* i/o: mdct spectrum Q_audio */ + Word16 Q_audio ); + +void stat_noise_uv_dec_fx( + Decoder_State *st_fx, /* i/o: Decoder static memory */ + Word16 *lsp_new, /* i : end-frame LSP vector Q15 */ + Word16 *lsp_mid, /* i : mid-frame LSP vector Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q = 14 - norm_s(Aq[0]) */ + Word16 *exc2, /* i/o: excitation buffer, Q = st_fx->Q_exc */ + const Word16 uc_two_stage_flag /* i : flag indicating two-stage UC */ +); + +void stat_noise_uv_mod_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q15 */ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q15 */ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q15 */ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q12 */ + Word16 *exc2, /* i/o: excitation buffer Q_exc */ + Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q_ge */ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q15 */ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q15 */ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q_stat_noise */ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : input bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ +); + +void stat_noise_uv_mod_ivas_fx( + const Word16 coder_type, /* i : Coder type */ + Word16 noisiness, /* i : noisiness parameter Q=0 */ + const Word16 *lsp_old, /* i : old LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_new, /* i : LSP vector at 4th sfr Q=15*/ + const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ + Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ + Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + const Word16 bfi, /* i : Bad frame indicator */ + Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ + Word16 *uv_count, /* i/o: unvoiced counter */ + Word16 *act_count, /* i/o: activation counter */ + Word16 lspold_s[], /* i/o: old LSP Q=15*/ + Word16 *noimix_seed, /* i/o: mixture seed Q0 */ + Word16 *st_min_alpha, /* i/o: minimum alpha Q=15*/ + Word16 *exc_pe, /* i/o: scale Q_stat_noise Q=Q_stat_noise*/ + const Word32 bitrate, /* i : core bitrate */ + const Word16 bwidth_fx, /* i : i bandwidth */ + Word16 *Q_stat_noise, /* i/o: noise scaling */ + Word16 *Q_stat_noise_ge /* i/o: noise scaling */ +); + +Word16 FEC_SinOnset_fx( + Word16 *exc, /* i/o : exc vector to modify */ + Word16 puls_pos, /* i : last pulse position desired */ + const Word16 T0, /* i : Pitch information of the 1 subfr */ + Word32 enr_q, /* i : energy provide by the encoder */ + Word16 *Aq, /* i : A(z) filter Q12 */ + const Word16 L_frame, /* i : frame length */ + const Word16 Qold ); + +Word16 FEC_enhACB_fx( + const Word16 L_frame, /* i : frame length */ + const Word16 last_L_frame, /* i : frame length of previous frame */ + Word16 *exc_io, /* i/o : adaptive codebook memory */ + const Word16 new_pit, /* i : decoded first frame pitch */ + const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ + const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ +); + +/*! r: do_WI flag */ +Word16 FEC_synchro_exc_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* i/o: exc vector to modify */ + const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ + const Word16 true_puls_pos, /* i : Present pulse location */ + const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ +); + +void decod_unvoiced_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Word16 *gain_buf ); + +void gaus_dec_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *code, /* o : unvoiced excitation Q12 */ + Word32 *L_norm_gain_code, /* o : gain of normalized gaussian excitation Q16 */ + Word16 *lp_gainp, /* i/o : lp filtered pitch gain(FER) Q14 */ + Word16 *lp_gainc, /* i/o : lp filtered code gain (FER) Q3 */ + Word16 *inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word16 *tilt_code, /* o : synthesis excitation spectrum tilt Q15 */ + Word16 *voice_fac, /* o : estimated voicing factor Q15 */ + Word16 *gain_pit, /* o : pitch gain Q14 */ + Word16 *pt_pitch_1, /* o : floating pitch buffer Q6 */ + Word16 *exc, /* o : excitation signal frame */ + Word32 *L_gain_code, /* o : gain of the gaussian excitation Q16 */ + Word16 *exc2, /* o : Scaled excitation signal frame */ + Word16 *bwe_exc_fx, + Word16 *sQ_exc, /* i/o : Excitation scaling factor (Decoder state) */ + Word16 *sQsubfr /* i/o : Past excitation scaling factors (Decoder State) */ +); + +void gaus_L2_dec( + Word16 *code, /* o : decoded gaussian codevector Q9 */ + Word16 tilt_code, /* i : tilt of code Q15 */ + const Word16 *A, /* i : quantized LPCs Q12 */ + Word16 formant_enh, /* i : formant enhancement factor Q15 */ + Word16 *seed_acelp /*i/o : random seed Q0 */ +); + +ivas_error decod_gen_voic_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 sharpFlag_fx, /* i : formant sharpening flag */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 do_WI_fx, /* i : do interpolation after a FER */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + Word16 *unbits, /* number of unused bits */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +); + +void decod_tran_fx( + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 tc_subfr_fx, /* i : TC subframe index */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */ + Word16 *unbits, /* i/o: number of unused bits */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 *gain_buf /*Q14*/ +); + +void transition_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 i_subfr, /* i : subframe index */ + const Word16 tc_subfr, /* i : TC subframe index */ + Word16 *Jopt_flag, /* i : joint optimization flag */ + Word16 *exc, /* o : excitation signal */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + Word16 **pt_pitch, /* o : floating pitch values */ + Word16 *position, /* i/o: first glottal impulse position in frame */ + Word16 *bwe_exc, /* o : excitation for SWB TBE */ + Word16 *Q_exc /*i/o : scaling of excitation */ +); + +Word16 tc_classif_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 L_frame /* i : length of the frame */ +); + +ivas_error decod_ppp_fx( + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ + Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ + Word16 *exc_fx, /* i/o: current non-enhanced excitation */ + Word16 *exc2_fx, /* i/o: current enhanced excitation */ + Word16 bfi, /* i : bad frame indicator */ + Word16 *gain_buf, /*Q14*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ +); + +void swb_bwe_dec_lr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 L_m_core[], /* i : lowband synthesis : QsL */ + const Word16 QsL, /* i : Q value of m_core */ + Word32 L_m[], /* o : highband synthesis with lowband zeroed : QsL */ + const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */ + Word16 BANDS_fx, /* i : Number subbands/Frame : Q0 */ + Word16 *band_start_fx, /* i : Band Start of each SB : Q0 */ + Word16 *band_end_fx, /* i : Band end of each SB :Q0 */ + Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */ + Word16 Qbe, /* i : Q value of band energy */ + Word16 *p2a_flags_fx, /* i : HF tonal Indicator : Q0 */ + const Word16 hqswb_clas_fx, /* i : class information : Q0 */ + Word16 lowlength_fx, /* i : Lowband Length : Q0 */ + Word16 highlength_fx, /* i : Highband Length : Q0 */ + const Word16 har_bands_fx, /* i : Number of LF harmonic bands : Q0 */ + Word16 *prev_frm_hfe2, /* i/o: : Q0 */ + Word16 *prev_stab_hfe2, /* i/o: : Q0 */ + Word16 band_width_fx[], /* i : subband bandwidth : Q0 */ + const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */ + Word16 *ni_seed_fx /* i/o: random seed : QsL */ +); + +Word16 dec_acelp_tcx_frame_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 *concealWholeFrame, /* i/o: concealment flag */ + Word16 *pcmBuf, /* o : synthesis */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 *pcmbufFB, /* o : synthesis @output_FS */ + Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors, /* o : voicing factors */ + Word16 pitch_buf[] /* o : floating pitch for each subframe */ +); + +void decoder_LPD_fx( + Word16 signal_out[], /* o : signal with LPD delay (7 subfrs) */ + Word16 signal_outFB[], /* o : synthesis @output_FS */ + Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ + Decoder_State *st, /* i/o: decoder memory state pointer */ + Word16 *bpf_noise_buf, /* i/o: BPF noise buffer */ + Word16 bfi, /* i : BFI flag */ + Word16 *bitsRead, /* o : number of read bits */ + Word16 param[], /* o : buffer of parameters */ + Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/ + Word16 *voice_factors, /* o : voicing factors */ + Word16 *ptr_bwe_exc /* o : excitation for SWB TBE */ +); + +void mode_switch_decoder_LPD_fx( + Decoder_State *st, /* Q0 */ + Word16 bandwidth_in, /* Q0 */ + Word32 bitrate, /* Q0 */ + Word16 frame_size_index /* Q0 */ +); + +void mode_switch_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word32 last_total_brate, /* i : last frame total bitrate Q0*/ + const Word16 frame_size_index, /* i : index determining the frame size Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 last_element_mode, /* i : last element mode Q0*/ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ); + +Word16 DecodeIndex( + Decoder_State *st, + const Word16 Bandwidth, /* o : NB, 1: (S)WB */ + Word16 *PeriodicityIndex ); + +Word16 DecodeIndex_fx( + Decoder_State *st, + const Word16 Bandwidth, + Word16 *PeriodicityIndex ); + +void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ +); + +Word16 lsf_msvq_ma_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ +); + +Word16 lsf_bctcvq_decprm( + Decoder_State *st, + Word16 *param_lpc /* Q0 */ +); + +Word16 D_lsf_tcxlpc( + const Word16 indices[], /* i : VQ indices Q0*/ + Word16 lsf_q[], /* o : quantized LSF Q1*/ + Word16 lsp_q_ind[], /* o :quantized LSP (w/o MA prediction) Q1*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk, /* i : codebook selector Q0*/ + Word16 mem_MA[] /* i : MA memory Q1*/ +); + +Word16 dec_lsf_tcxlpc( + Decoder_State *st, /* i/o: Decoder state */ + Word16 **indices, /* o : Ptr to VQ indices Q0*/ + Word16 narrowband, /* i : narrowband flag Q0*/ + Word16 cdk /* i : codebook selector Q0*/ +); + +void midlsf_dec( + const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ + const Word16 idx, /* i: codebook index */ + Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */ + const Word16 coder_type, + Word16 *mid_lsf_int, + const Word16 prev_bfi, + const Word16 safety_net ); + +Word16 lsf_ind_is_active( + const Word16 lsf_q_ind[], /*(14Q1*1.28)*/ + const Word16 means[], /*(14Q1*1.28)*/ + const Word16 narrowband, + const Word16 cdk ); + +void IGFSCFDecoderOpen( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ + H_IGF_INFO hIgfInfo, /* i : IGF info handle */ + const Word32 total_brate, + const Word16 bwidth, + const Word16 element_mode, + const Word16 rf_mode ); + +void IGFSCFDecoderReset( + IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */ +); + +void IGFSCFDecoderDecode( + IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + Decoder_State *st, /* i/o: pointer to decoder state */ + Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, + if 0 on input the decoder will be forced to encode without a reset */ +); + +Word32 ari_decode_overflow_fx( + Tastat *s ); + +void ari_start_decoding_14bits_fx( + Decoder_State *st, + Tastat *s ); + +Word16 ari_start_decoding_14bits_prm_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + +Word16 ari_decode_14bits_s17_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + +Word16 ari_decode_14bits_s27_ext_fx( + Decoder_State *st, + Tastat *s, + UWord16 const *cum_freq ); + +Word16 ari_decode_14bits_bit_ext_fx( + Decoder_State *st, + Tastat *s ); + +Word16 ari_decode_14bits_pow_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + Word16 base ); + +Word16 ari_decode_14bits_sign_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + +void getTCXparam_fx( + Decoder_State *st, /* i/o: Decoder State handle */ + Decoder_State *st0, /* i : bitstream */ + CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ + Word16 param[], /* o : decoded parameters Q0 */ + const Word16 bits_common, /* i : number of common bits Q0 */ + const Word16 start_bit_pos, /* i : position of the start bit Q0 */ + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ + Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ + Word16 nTnsBitsTCX10[2], /*Q0*/ + const Word16 pre_past_flag /*Q0*/ +); + +void dec_prm_fx( + Word16 *coder_type, + Word16 param[], /* (o) : decoded parameters */ + Word16 param_lpc[], /* (o) : LPC parameters */ + Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ + Decoder_State *st, + Word16 L_frame, + Word16 *bitsRead ); + +void getLPCparam_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param_lpc[], /* o : LTP parameters Q0 */ + Decoder_State *st0, /* i : bitstream */ + const Word16 ch, /* i : channel Q0 */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ +); + +void UnmapIndex( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word16 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ +); + +void ConfigureContextHm( + const Word16 NumCoeffs, /* (I) Number of coefficients Q0*/ + const Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) Q0*/ + const Word16 PeriodicityIndex, /* (I) Pitch related index Q0*/ + const Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */ +); + +Word16 CountIndexBits( + Word16 Bandwidth, /* 0: NB, 1: (S)WB Q0*/ + Word16 PeriodicityIndex /* Q0 */ +); + +Word32 tcx_hm_render( + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ +); + +void tcx_hm_modify_envelope( + Word16 gain, /* i: HM gain Q11 */ + Word32 lag, /* i: pitch lag Q0 */ + Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + Word16 L_frame /* i: number of spectral lines Q0 */ +); + +Word16 ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void ReadTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +Word16 DecodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +void GetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void const *pParameter, + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ); + +void GetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, // Q0 + void const *pParameter, // Q0 + Word16 **pStream, // Q0 + Word16 *pnSize, // Q0 + Word16 *pnBits // Q0 +); + +void EncodeTnsData_ivas_fx( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream Q0*/ + Word16 *pnSize, /* o : number of written parameters Q0*/ + Word16 *pnBits /* o : number of written bits Q0*/ +); + +void SetParameters( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + +void SetParameters_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + void *pParameter, + const Word16 **pStream, + Word16 *pnSize ); + +void WriteToBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nParams, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + +void ReadFromBitstream( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + +void ReadFromBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + Decoder_State *st, + Word16 **pStream, + Word16 *pnSize ); + +void IGFDecReadData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +); + +void IGFDecReadLevel( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +); + +void IGFDecApplyMono( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ +); + +void IGFDecApplyMono_ivas( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi, /**< in: | frame loss == 1, frame good == 0 */ + Word16 element_mode /**< in: | IVAS element mode */ +); + +void IGFDecApplyStereo( + const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ + const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ + Word32 *spectrumL_fx, /* i/o: L MDCT spectrum */ + Word16 *spectrumL_e, /* i/o: L MDCT spectrum exp */ + Word32 *spectrumR_fx, /* i/o: R MDCT spectrum */ + Word16 *spectrumR_e, /* i/o: R MDCT spectrum exp */ + const Word16 igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 *coreMsMask, + const Word16 restrict_hopsize, + const Word16 bfi, /* i : frame loss == 1, frame good == 0 */ + const Word16 bfi_apply_damping ); + +void IGFDecSetMode( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void IGFDecSetMode_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 igfGridIdx /**< in: | IGF grid index */ +); + +void IGFDecUpdateInfo_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder */ + const Word16 subFrameIdx, /* i : subframe index */ + const Word16 igfGridIdx /* i : IGF grid index */ +); + +void IGFDecCopyLPCFlatSpectrum( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ +); + +void IGFDecCopyLPCFlatSpectrum_fx( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ +); + +void IGFDecStoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ +); + +void IGFDecRestoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ +); + +void IGFDecRestoreTCX10SubFrameData_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o : instance handle of IGF Decoder */ + const Word16 subFrameIdx /* i : index of subframe */ +); + +void init_igf_dec( + IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ +); + +Word16 dlpc_avq_fx( + Word16 *index, /* (i) Quantization indices */ + Word16 *LSF_Q, /* (o) Quantized LSF vectors */ + Word16 numlpc, /* (i) Number of sets of lpc */ + Word32 sr_core ); + +Word16 decode_lpc_avq_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc /* o : lpc parameters */ +); + +Word16 decode_lpc_avq_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc, /* o : lpc parameters */ + const Word16 ch, /* i : channel */ + const Word16 element_mode, /* i : element mode */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ +); + +void vlpc_1st_dec( + Word16 index, /* i : codebook index */ + Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ + +void vlpc_2st_dec( + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ + Word16 *indx, /* i : index[] (4 bits per words) */ + Word16 mode, /* i : 0=abs, >0=rel */ + Word32 sr_core ); + +void lsf_weight_2st( + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ +); + +/* Returns: index of next coefficient */ +Word16 get_next_coeff_mapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +/* Returns: index of next coefficient */ +Word16 get_next_coeff_unmapped( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word16 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +Word16 update_mixed_context( + Word16 ctx, /* Q0 */ + Word16 a /* Q0 */ +); + +Word32 update_mixed_context_ivas_fx( + Word32 ctx, /* Q0 */ + Word16 a /* Q0 */ +); + +typedef Word16 ( *get_next_coeff_function )( + Word16 ii[2], /* i/o: coefficient indexes */ + Word16 *pp, /* o : peak(1)/hole(0) indicator */ + Word16 *idx, /* o : index in unmapped domain */ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +Word16 ACcontextMapping_decode2_no_mem_s17_LC( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o: decoded spectrum */ + Word16 nt, /* i: size of spectrum */ + Word16 nbbits, /* i: bit budget */ + Word16 resQMaxBits, /* i: residual coding maximum bits*/ + CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ +); + +Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( + Decoder_State *st, /* i/o: decoder state */ + Word16 *x, /* o : decoded spectrum */ + const Word16 nt, /* i : size of spectrum */ + const Word16 nbbits, /* i : bit budget */ + const Word16 resQMaxBits, /* i : residual coding maximum bits */ + CONTEXT_HM_CONFIG *hm_cfg /* i : context-based harmonic model configuration*/ +); + +void reconfig_decoder_LPD_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 bits_frame, /* i : bit budget Q0*/ + Word16 bwidth, /* i : audio bandwidth Q0*/ + Word32 total_brate, /* i : total bitrate Q0*/ + Word16 L_frame_old /* i : frame length Q0*/ +); + +void reconfig_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bits_frame, /* i : bit budget Q0*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 total_brate, /* i : total bitrate Q0*/ + const Word16 L_frame_old /* i : frame length Q0*/ +); + +void minimumStatistics_fx( + Word16 *noiseLevelMemory, /* Q15, internal state */ + Word16 *noiseLevelIndex, /* Q0, internal state */ + Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ + Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ + Word16 *lastFrameLevel, /* Q15, level of the last frame */ + Word16 currentFrameLevel, /* Q15, level of the current frame */ + Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ + Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ + Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ + Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ + Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ + +/*10Q5*/ +Word16 getLevelSynDeemph_fx( + Word16 h1Init[], /* i: i value or vector to be processed Q15 */ + Word16 const A[], /* i: LPC coefficients Qx */ + Word16 const lpcorder, /* i: LPC order Q0 */ + Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ + Word16 const preemph_fac, /* i: preemphasis factor Q15 */ + Word16 const numLoops, /* i: number of loops Q0 */ + Word16 *Exp /* o: exponent of return value Q15 */ +); + +void genPlcFiltBWAdap_fx( + Word32 const sr_core, /*mem_syn >rescaling done */ + Word16 *pitch_buffer, + Word16 *voice_factors, + Word16 *bwe_exc ); + +void decoder_acelp_fx( + Decoder_State *st, + Word16 prm[], /* i : parameters */ + Word16 A[], /* i : coefficients NxAz[M+1] */ + ACELP_config acelp_cfg, /* i : ACELP config */ + Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */ + Word16 *pT, /* out: pitch for all subframe Q0 */ + Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */ + Word16 stab_fac, /* i : stability of isf */ + Word16 *pitch_buffer, /* out: pitch values for each subfr.*/ + Word16 *voice_factors, /* out: voicing factors */ + const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ + Word16 *bwe_exc /* out: excitation for SWB TBE */ +); + +void decode_acelp_gains_fx( + Word16 *code, + Word16 gains_mode, + Word16 mean_ener_code, + Word16 *gain_pit, + Word32 *gain_code, + Word16 **pt_indice, + Word16 *past_gpit, + Word32 *past_gcode, + Word16 *gain_inov, + Word16 L_subfr, + Word16 *code2, + Word32 *gain_code2 ); + +void d_gain_pred_fx( + Word16 nrg_mode, /* i : NRG mode */ + Word16 *Es_pred, /* o : predicited scaled innovation energy */ + Word16 **pt_indice /* i/o: pointer to the buffer of indices */ +); + +ivas_error evs_dec_fx( + Decoder_State *st_fx, /* i/o : Decoder state structure */ + Word16 output_sp[], /* o : output synthesis signal */ + FRAME_MODE frameMode /* i : Decoder frame mode */ +); + +void fft_cldfb_fx( + Word32 *data, /* i/o: input/output vector */ + const Word16 size /* size of fft operation */ +); + +void stereo_dft_dec_analyze_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + const Word32 *input_fx, /* i : input signal q*/ + Word32 out_DFT_fx[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers q_out_DFT*/ + const Word16 chan, /* i : channel number Q0*/ + const Word16 input_frame, /* i : input frame size Q0*/ + const Word16 output_frame, /* i : output frame size Q0*/ + const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : type of signal to analyse */ + const Word16 k_offset, /* i : offset of DFT Q0*/ + const Word16 delay, /* i : delay in samples FOR input signal Q0*/ + Word16 *q, + Word16 *q_DFT ); + +void set32_fx( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void delay_signal_q_adj_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay, /* i : delay in samples */ + const Word16 q_x, + const Word16 q_mem ); + +Word32 anint_fx( + const Word32 x, /* i: Round to the nearest integer */ + const Word16 exp /* i: Exponent for round step */ +); + +Word32 ceil_fx( + const Word32 x, /* i: number to ceil */ + const Word16 exp /* i: Exponent for ceil step */ +); + +void v_add_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_shr_16( + const Word16 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word16 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ +); + +void v_shr( + const Word32 x[], /* i : Input vector */ + const Word16 shift, /* i : Constant */ + Word32 y[], /* o : Output vector that contains x >> shift */ + const Word16 N /* i : Vector length */ +); + +void cldfbAnalysis_ts_fx( + const Word32 *timeIn_fx, /* i : time buffer */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, + Word16 *q_cldfb ); + +Word16 floor_log_2( + Word32 num ); + +void cldfbAnalysis_ts_fx_var_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q_cldfb - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q_cldfb - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + +void cldfbAnalysis_ts_fx_fixed_q( + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word16 *q_cldfb ); + +void configureCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ + const Word32 sampling_rate /* i : sampling rate */ +); + +void dec_acelp_fast_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const Word16 L_subfr /* i : subframe length */ +); + +void tcx5SpectrumInterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + +void tcx5SpectrumDeinterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + +void tcx5TnsGrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum ); + +void tcx5TnsUngrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum, + const Word16 enc_dec ); + +void bpf_pitch_coherence_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ +); + +/* fft_rel.c */ + +#define SIZE_256 256 +#define NUM_STAGE_256 7 +#define SIZE2_256 ( SIZE_256 / 2 ) + +void cldfbAnalysis_ivas_fx( + const Word32 *timeIn_fx, /* i : time buffer Qx */ + Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ + Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ +); + +void cldfbSynthesis_ivas_fx( + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ + const Word16 out_shift, /* i : scale for output buffer */ + HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ +); + +void addBassPostFilter_ivas_fx( + const Word32 *harm_timeIn_fx, + const Word16 samplesToProcess, + Word32 **rAnalysis_fx, + Word32 **iAnalysis_fx, + HANDLE_CLDFB_FILTER_BANK cldfb ); + +/* o : Q22*/ +Word32 ism_dequant_meta_fx( + const Word16 idx, /* i : quantizer index */ + const Word32 borders_fx[], /* i : level borders Q22*/ + const Word32 q_step_fx, /* i : quantization step Q22 */ + const Word32 q_step_border_fx, /* i : quantization step at the border Q22*/ + const Word16 cbsize /* i : codebook size */ +); + +void save_synthesis_hq_fec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ + const Word32 output_fx[], /* i : decoded synthesis */ + const Word16 output_frame, /* i : decoded synthesis */ + const Word16 Qpostd, /* i : Q value of delayed signal */ + CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ +); + +void calculate_nbits_meta_fx( + const Word16 nchan_ism, + Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 + Word32 masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], // Q30 + const Word16 numSf, + const Word16 numCodingBands, + Word16 *bits_ism, + const Word16 idx_sep_obj, + const Word16 ism_imp ); + +void ivas_get_stereo_panning_gains_fx( + const Word16 aziDeg, + const Word16 eleDeg, + Word16 panningGains[2] ); + +ivas_error openCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ + const Word16 enc_dec ); /* i : encoder/decoder flag */ + +Word32 rand_gauss_fx( + Word32 *x, + Word16 *seed, + Word16 q ); + +void resampleCldfb_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate ); + +void generate_masking_noise_dirac_ivas_fx( + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + Word32 *tdBuffer_fx, /* i/o: time-domain signal, if NULL no LB-CNA */ + Word32 *Cldfb_RealBuffer_fx, /* o : CLDFD real buffer */ + Word32 *Cldfb_ImagBuffer_fx, /* o : CLDFD imaginary buffer */ + const Word16 slot_index, /* i : CLDFB slot index */ + const Word16 cna_flag, /* i : CNA flag for LB and HB */ + const Word16 fd_cng_flag, /* i : FD-CNG flag for HB */ + Word16 q_input, + Word16 *q_cldfb ); + +void IMDCT_fx( + Word32 *x, + Word16 x_e, + Word16 *old_syn_overl, + Word16 *syn_Overl_TDAC, + Word16 *xn_buf, + const Word16 *tcx_aldo_window_1, + const PWord16 *tcx_aldo_window_1_trunc, + const PWord16 *tcx_aldo_window_2, + const PWord16 *tcx_mdct_window_half, + const PWord16 *tcx_mdct_window_minimum, + const PWord16 *tcx_mdct_window_trans, + Word16 tcx_mdct_window_half_length, + Word16 tcx_mdct_window_min_length, + Word16 index, + Word16 left_rect, + Word16 tcx_offset, + Word16 overlap, + Word16 L_frame, + Word16 L_frameTCX, + Word16 L_spec_TCX5, + Word16 L_frame_glob, + Word16 frame_cnt, + Word16 bfi, + Word16 *old_out, + Word16 *Q_old_wtda, + Decoder_State *st, + Word16 fullbandScale, + Word16 *acelp_zir ); + +void IMDCT_ivas_fx( + Word32 *x_fx, + Word16 q_x, + Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, + Word16 *xn_buf_fx, + Word16 q_xn_buf_fx, + const Word16 *tcx_aldo_window_1_fx, + const PWord16 *tcx_aldo_window_1_trunc_fx, + const PWord16 *tcx_aldo_window_2_fx, + const PWord16 *tcx_mdct_window_half_fx, + const PWord16 *tcx_mdct_window_minimum_fx, + const PWord16 *tcx_mdct_window_trans_fx, + const Word16 tcx_mdct_window_half_length, + const Word16 tcx_mdct_window_min_length, + Word16 index, + const UWord16 kernel_type, /* i : TCX transform kernel type */ + const Word16 left_rect, + const Word16 tcx_offset, + const Word16 overlap, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 L_spec_TCX5, + const Word16 L_frame_glob, + const Word16 frame_cnt, + const Word16 bfi, + Word16 *old_out_fx, + Word16 *q_old_out_fx, + const Word16 FB_flag, + Decoder_State *st, + const Word16 fullbandScale, + Word16 *acelp_zir_fx, + Word16 *q_acelp_zir_fx, + Word16 *pq_win ); + +void v_mult16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void configureFdCngDec_fx( + HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, + const Word32 total_brate, + const Word16 L_frame, + const Word16 last_L_frame, + const Word16 element_mode ); + +Word32 sum2_f_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ +); + +Word32 sum2_f_16_gb_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + +Word32 sum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + +Word16 vq_dec_lvq_ivas_fx( + Word16 sf_flag, /* i : safety net flag */ + Word16 x[], /* o : Decoded vector Q(x2.56)*/ + Word16 indices[], /* i : Indices */ + Word16 stages, /* i : Number of stages */ + Word16 N, /* i : Vector dimension */ + Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ + Word16 no_bits /* (i): no. bits for lattice */ +); + +Word16 deindex_lvq_ivas_fx( + Word16 *index, /* i : index to be decoded, as an array of 3 Word16 */ + Word16 *x_lvq, /* o : decoded codevector Q(x2.56) */ + Word16 mode, /* i : LVQ coding mode/MSLVQ structure index (select scales & no_lead ), or idx_cv for CNG case */ + Word16 sf_flag, /* i : safety net flag */ + Word16 no_bits /* i : number of bits for lattice */ +); + +void deleteCldfb_fx( + HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ +); + +void fd_bwe_dec_init_fx( + FD_BWE_DEC_HANDLE hBWE_FD /* i/o: FD BWE data handle */ +); + +void stereo_dft_dec_open( + STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_transport /* i : number of transport channels */ +); + +void ivas_bw_switching_pre_proc_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + Word32 *old_syn_12k8_16k_fx, + Word16 Q, + Word16 Q_audio ); + +UWord32 mvl2s_r( + const Word32 x[], /* i : input vector */ + const Word16 q, + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ +); + +void decoder_tcx_post_ivas_fx( + Decoder_State *st_fx, + Word16 *synth, + Word16 *synthFB, + Word16 Q_syn, + Word16 *A, + Word16 bfi, + Word16 MCT_flag ); + +void con_tcx_ivas_fx( + Decoder_State *st, /* i/o: coder memory state */ + Word16 synth[], /* i/o: synth[] Q0 */ + const Word16 coh, /* i : coherence of stereo signal */ + Word16 *noise_seed, /* i/o: noise seed for stereo */ + const Word16 only_left, /* i : TD-PLC only in left channel */ + const Word16 *A_cng /* i : CNG LP filter coefficients */ +); + +void ivas_mdct_core_reconstruct_fx( + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ + Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ + Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + Word16 q_x, + Word16 e_sig[CPE_CHANNELS] ); + +void ari_start_encoding_14bits_ivas_fx( + Tastat *s ); + +void tcx_scalar_quantization_ivas_fx( + Word32 *x, /* i: input coefficients */ + Word16 x_e, /* i: exponent */ + Word16 *xq, /* o: quantized coefficients */ + Word16 L_frame, /* i: frame length */ + Word16 gain, /* i: quantization gain */ + Word16 gain_e, /* i: quantization gain exponent */ + Word16 offset, /* i: rounding offset (deadzone) */ + Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + const Word16 alfe_flag ); + +Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( + Word16 *x, /* Spectral coefficients Q0*/ + const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ + Word16 *lastnz_out, /* Q0 */ + Word16 *nEncoded, /* No. of spectral coefficients that can be coded without an overflow occuring Q0*/ + const Word16 target, /* Target bits Q0*/ + Word16 *stop, /* Q0 */ + Word16 mode, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ +); + +/* Qx*/ +Word16 usdequant_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qy*/ +); + +/* Qx*/ +Word32 usdequant32_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word32 delta /* i: quantization step Qy*/ +); + +/* o: index of the winning codeword */ +Word16 usquant_fx( + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ +); + +/* o : Sum */ +Word32 Dot_product( + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ +); + +/* o : dot product of x[] and y[] */ +Word32 dotp_fx( + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 *exp /* (o) : exponent of result (0..+30) */ +); + +/* o : sum of all squared vector elements Q(2x+1)*/ +Word32 sum2_fx_mod( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ +); + +void Copy_Scale_sig( + const Word16 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Scale_sig32( + Word32 x[], /* i/o: signal to scale Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32_DEPREC( + const Word16 x[], /* i : signal to scale i Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32_r( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_16_32_no_sat( + const Word16 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Copy_Scale_sig_32_16( + const Word32 x[], /* i : signal to scale i Qx */ + Word16 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void Random_Fill( + Word16 *seed, /* i/o: random seed */ + Word16 n, /* i : number of values */ + Word16 *y, /* o : output values */ + Word16 scaling /* i : scaling of values */ +); + +/* o : mean of vector */ +Word16 mean_fx( + const Word16 *vec_fx, /* i : i vector */ + const Word16 lvec_fx /* i : length of i vector */ +); + +/* o : mean of vector Qx */ +Word16 mean_no_sat_fx( + const Word16 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx /* i : length of input vector */ +); + +/* o : mean of vector Qx */ +Word32 mean_no_sat_Word32_fx( + const Word32 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx, /* i : length of input vector */ + const Word16 gb ); +void sort( + UWord16 *x, /* i/o: Vector to be sorted */ + UWord16 len /* i/o: vector length */ +); + +void sort_fx( + Word16 *r, /* i/o: Vector to be sorted in place */ + Word16 lo, /* i : Low limit of sorting range */ + Word16 up /* I : High limit of sorting range */ +); + +void sort_32_fx( + Word32 *r, /* i/o: Vector to be sorted in place */ + const Word16 lo, /* i : Low limit of sorting range */ + const Word16 up /* I : High limit of sorting range */ +); + +/* o : index of the minimum value in the input vector */ +Word16 minimum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *max_fx /* o : maximum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_exp_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 *exp_vec, /* i : exponents of input vector */ + const Word16 lvec_fx /* i : length of input vector */ +); + +/* o : index of the maximum abs value in the input vector */ +Word16 maximum_abs_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max_val /* o : maximum value in the input vector */ +); + +/* o : index of the minimum value in the input vector */ +Word16 minimum_abs32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ +); + +/* o : index of the minimum value in the input vector */ +Word16 minimum_32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/* o : index of the maximum value in the input vector */ +Word16 maximum_abs_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the maximum value in the input vector */ +Word16 maximum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ +); + +Word16 Exp16Array( + const Word16 n, /* (i): Array size */ + const Word16 *sx /* (i): Data array */ +); + +Word16 Exp32Array( + const Word16 n, /* (i): Array size */ + const Word32 *sx /* (i): Data array */ +); + +/* o : sum of all vector elements Qx*/ +Word32 sum16_32_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +/* o : sum of all vector elements Qx*/ +Word32 sum32_sat( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +/* o: variance of vector Qx+16*/ +Word32 var_fx_32( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ +); + +/* o: variance of vector Qx+16*/ +Word32 var_fx_32in_32out( + const Word32 *x, /* i: input vector Qx*/ + Word16 *Qx, + const Word16 len, /* i: length of inputvector */ + const Word16 gb ); + +/* o: variance of vector Qx*/ +Word16 var_fx( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ +); + +/* o: variance of vector Qx*/ +Word16 std_fx( + const Word16 x[], /* i: input vector */ + const Word16 len /* i: length of the input vector */ +); + +/* o : the dot product x'*A*x */ +Word32 dot_product_mat_fx( + const Word16 *x, /* i : vector x Q15 */ + const Word32 *A, /* i : matrix A Q0*/ + const Word16 m /* i : vector & matrix size */ +); + +void Vr_subt( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + Word16 N /* i : Vector lenght */ +); + +/* o: index of the winning codevector */ +Word16 vquant_ivas_fx( + Word32 x[], /* i: vector to quantize Q25 */ + const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ + Word32 xq[], /* o: quantized vector Q25 */ + const Word32 cb[], /* i: codebook Q25 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ +); + +/* o: index of the winning codevector */ +Word16 vquant_fx( + Word16 x[], /* i: vector to quantize Q13 */ + const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ + Word16 xq[], /* o: quantized vector Q13 */ + const Word16 cb[], /* i: codebook Q13 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ +); + +Word16 w_vquant_fx( + Word16 x[], /* i: vector to quantize in Q10 */ + Word16 Qx, + const Word16 weights[], /* i: error weights in Q0 */ + Word16 xq[], /* o: quantized vector in Q15 */ + const Word16 cb[], /* i: codebook in Q15 */ + const Word16 cbsize, /* i: codebook size */ + const Word16 rev_vect /* i: reverse codebook vectors */ +); + +/* o : return index with max energy value in vector Q0 */ +Word16 emaximum_fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word16 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ +); + +/* o : return index with max energy value in vector Q0 */ +Word16 emaximum_32fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word32 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ +); + +/* o : mean of the elements of the vector */ +Word32 Mean32( + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ +); + +/* o : sum of all vector elements Qx*/ +Word32 sum32_fx( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +/* o : sum of all vector elements Qx*/ +Word16 sum16_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ +); + +Word16 own_random2_fx( + Word16 seed ); + +void iDiv_and_mod_32( + const Word32 Numer, /* i : 32 bits numerator */ + const Word16 Denom, /* i : 16 bits denominator */ + Word32 *Int_quotient, /* o : integer result of the division (int)(num/den) */ + Word32 *Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/ + const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1 */ +); + +void pz_filter_sp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word16 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + +Word32 root_a_fx( + Word32 a, + Word16 Q_a, + Word16 *exp_out ); + +Word32 root_a_over_b_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + +Word32 root_a_over_b_ivas_fx( + Word32 a, /* Q(Q_a) */ + Word16 Q_a, + Word32 b, /* Q(Q_b) */ + Word16 Q_b, + Word16 *exp_out ); + +void fir_fx( + const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd, /* i : 1 = update the memory, 0 = not */ + Word16 shift /* i : difference between Q15 and scaling of h[] */ +); + +void v_add_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_shr_32( + Word32 x1[], /* i : Input vector 1 */ + Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N, /* i : Vector length */ + Word16 shift /*shift value*/ +); + +void v_sub_32( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_add_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_sub_16( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +/* o: index of the winning codeword */ +Word16 squant_fx( + const Word16 x, /* i: scalar value to quantize */ + Word16 *xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ +); + +Word16 squant_int_fx( + UWord8 x, /* i : scalar value to quantize */ + UWord8 *xq, /* o : quantized value */ + const UWord8 *cb, /* i : codebook */ + const Word16 cbsize /* i : codebook size */ +); + +void pz_filter_dp_fx( + const Word16 b[], + const Word16 a[], + Word16 x[], + Word16 y[], + Word32 buf[], + Word16 PNR, + Word16 PDR, + Word16 N, + Word16 Qa ); + +void Copy_Scale_sig32_16( + const Word32 *src, /* i : signal to scale Qx */ + Word16 *dst, /* o : scaled signal Qx */ + Word16 len, /* i : size of x[] Q0 */ + Word16 exp0 ); /* i : exponent: x = round(x << exp) Qx ?exp */ + +void v_multc_att( + const Word16 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word16 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_att32( + const Word32 x[], /* i : Input vector Qx */ + const Word16 att, /* i : Constant Q15, <= MAX_16 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); + +void v_multc_att3232( + const Word32 x[], /* i : Input vector Qx */ + const Word32 att, /* i : Constant Q32, <= MAX_32 */ + Word32 y[], /* o : Output vector that contains att*x */ + const Word16 N /* i : Vector length */ +); + +void v_L_mult_1616( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_L_mult_3216( + const Word32 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void add_vec_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 Qx1, /* i : SCaling of input 1 */ + const Word16 x2[], /* i : Input vector 2 */ + const Word16 Qx2, /* i : SCaling of input 1 */ + Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */ + const Word16 Qy, /* i : SCaling of output 1 */ + const Word16 N /* i : Vector lenght */ +); + +/* o: Result (Normalized) */ +Word32 Add_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ +); + +/* o: Result (Normalized) */ +Word32 Mul_flt32_Q15( + Word32 value, /* i: Pseudo_float Value */ + Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i: Q15 value */ +); + +/* o: Result (Normalized) */ +Word32 Div_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ +); + +/* o: Result (Normalized) */ +Word32 Calc_Energy_Autoscaled( + const Word16 *signal, /* i: Signal */ + Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ + Word16 len, /* i: Frame Length */ + Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ +); + +Word16 Find_Max_Norm16( + const Word16 *src, + Word16 len ); + +Word16 Find_Max_Norm32( + const Word32 *src, + Word16 len ); + +/* o: Result in Q31 */ +Word32 Sqrt_Ratio32( + Word32 L_val1, /* i: Mantisa of Val1 */ + Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ +); + +/* result in Q'15 + 'exp' */ +Word16 Invert16( + Word16 val, + Word16 *exp ); + +Word16 find_rem( + Word16 n, + Word16 m, + Word16 *r ); + +Word32 find_remd( + Word32 n, + Word32 m, + Word32 *r ); + +Word16 rint_new_fx( + Word32 x /*Q16 */ +); + +Word16 erb_diff_search_fx( + Word16 *prev_erb, + const Word16 *curr_erb, + Word16 *dif_erb, + Word16 *pow_spec, + const Word16 *cb_fx, + Word16 cb_size, + Word16 cb_dim, + Word16 offset ); + +void Acelp_dec_total_exc( + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + const Word16 gain_code16, /* i : Gain code Q0 */ + const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */ + const Word16 i_subfr, /* i ; subfr */ + const Word16 *code_fx, /* i : code in Q9 */ + const Word16 L_subfr /* i : Subframne lenght */ +); + +UWord32 UL_inverse( + const UWord32 UL_val, + Word16 *exp ); + +UWord32 UL_div( + const UWord32 UL_num, + const UWord32 UL_den ); + +Word16 ratio( + const Word32 numer, + const Word32 denom, + Word16 *expo ); + +void hp400_12k8_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ +); + +void hp400_12k8_ivas_fx( + Word16 signal[], /* i/o: input signal / output is divided by 16 */ + const Word16 lg, /* i : lenght of signal */ + Word16 mem[] /* i/o: filter memory [6] */ +); + +Word16 dot_prod_satcontr( + const Word16 *x, + const Word16 *y, + Word16 qx, + Word16 qy, + Word16 *qo, + Word16 len ); + +void E_UTIL_f_convolve( + const Word16 x[], + const Word16 h[], + Word16 y[], + const Word16 size ); + +void floating_point_add( + Word32 *mx, /* io: mantissa of the addend Q31 */ + Word16 *ex, /* io: exponent of the addend Q0 */ + const Word32 my, /* i: mantissa of the adder Q31 */ + const Word16 ey /* i: exponent of the adder Q0 */ +); + +void delay_signal_fx( + Word16 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word16 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ +); + +void delay_signal32_fx( + Word32 x[], /* i/o: signal to be delayed */ + const Word16 len, /* i : length of the input signal */ + Word32 mem[], /* i/o: synchronization memory */ + const Word16 delay /* i : delay in samples */ +); + +Word16 lin_interp_ivas_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ +); + +Word16 lin_interp_fx( + const Word16 x, /* i : the value to be mapped */ + const Word16 x1, /* i : source range interval: low end */ + const Word16 y1, /* i : source range interval: high end */ + const Word16 x2, /* i : target range interval: low */ + const Word16 y2, /* i : target range interval: high */ + const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ +); + +Word16 ceil_log_2( + UWord64 val ); + +Word32 imax_pos_fx( + const Word32 *y /* i : Input vector for peak interpolation Qx*/ +); + +void msvq_enc_ivas_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) Q_cb */ + const Word16 Q_cb, /* i : Codebook Q */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word32 u_fx[], /* i : Vector to be encoded (prediction and mean removed) (exp : u_e) */ + const Word16 u_e, /* i : Exponent for Vector to be encoded */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from from one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8 */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 applyDCT_flag, /* i : applyDCT flag */ + Word32 *invTrfMatrix_fx, /* i/o: synthesis matrix Q31 */ + Word16 Idx[] /* o : Indices */ +); + +void msvq_dec_fx( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 stages, /* i : Number of stages */ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + const Word16 Idx[], /* i : Indices */ + const Word16 applyIDCT_flag, /* i : applyIDCT flag */ + const Word32 *invTrfMatrix, /* i : synthesis matrix */ + Word32 *uq, /* o : quantized vector */ + Word16 *uq_ind, /* o : quantized vector (fixed point) */ + Word16 exp ); + +void dec_FDCNG_MSVQ_stage1_fx( + Word16 j_full, /* i : index full range */ + Word16 n, /* i : dimension to generate */ + const Word32 *invTrfMatrix, /* i : IDCT matrix for synthesis Q31 */ + const DCTTYPE idcttype, /* i : specify which IDCT */ + Word32 *uq, /* o : synthesized stage1 vector Q20 */ + Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ +); + +void dctT2_N_apply_matrix_fx( + const Word32 *input, /* i : input in fdcng or DCT(fdcng) domain */ + Word32 *output, /* o : output in DCT(fdcng) or fdcng ordomain */ + const Word16 dct_dim, /* i : dct processing dim possibly truncated */ + const Word16 fdcngvq_dim, /* i : fdcng domain length */ + const Word32 *matrix, /* i : IDCT matrix */ + const Word16 matrix_row_dim, /* i : */ + const DCTTYPE dcttype /* i : matrix operation type */ +); + +Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb ); + +Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + +void v_mult_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 .* vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_sub_s16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +void v_sub32_fx( + const Word32 x1[], /* i : Input vector 1 */ + const Word32 x2[], /* i : Input vector 2 */ + Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); + +void ivas_swb_tbe_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_ICBWE_DEC_HANDLE hStereoICBWE, /* i/o: IC-BWE state structure */ + const Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation : Q_exc */ + Word16 Q_exc, + const Word16 voice_factors_fx[], /* i : voicing factors : Q15 */ + const Word32 old_syn_12k8_16k_fx[], /* i : low band synthesis : old_syn_fx */ + Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE : Q_white_exc*/ + Word32 *synth_fx, /* o : SHB synthesis/final synthesis : Qx */ + Word16 *pitch_buf_fx, /* i : Q6 */ + Word16 *Q_white_exc ); + +Word16 swb_bwe_dec_fx32( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word32 output_fx[], /* i : synthesis @internal Fs : Q11 */ + Word32 *synth_fx, /* i : ACELP core synthesis/final synthesis : Q11 */ + Word32 *hb_synth_fx, /* o : SHB synthesis/final synthesis : Q_syn_hb */ + Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + Word16 output_frame /* i : frame length */ +); + +ivas_error acelp_core_dec_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 output_fx[], /* o : synthesis @internal Fs */ + Word16 synth_fx16[], /* o : synthesis */ + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word16 *unbits, /* o : number of unused bits */ + Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const Word16 last_element_mode, /* i : last element mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 read_sid_info /* i : read SID info flag */ +); + +void wtda_fx32( + const Word32 *new_audio, /* i : input audio Q11 */ + Word32 *wtda_audio, /* o : windowed audio Q11 */ + Word32 *old_wtda, /* i/o: windowed audio from previous frame Q11 */ + const Word16 left_mode, /* i : window overlap of previous frame (0: full, 2: none, or 3: half) */ + const Word16 right_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ + const Word16 L /* i : length */ +); + +ivas_error core_switching_pre_dec_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 output_frame, /* i : frame length */ + const Word32 last_core_brate_st0, /* i : channel 0 last core bitrate */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 last_element_mode, /* i : last_element_mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + Word16 Q_old_synthFB, + Word16 *Q_olapBufferSynth, + Word16 *Q_olapBufferSynth2 ); + +void hp20_fx_32( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + +void hp20_fx_32_opt( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs ); + +void getTCXMode_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Decoder_State *st0, /* i : bitstream */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +); + +void getTCXWindowing_ivas_fx( + const Word16 core, /* i : current frame mode */ + const Word16 last_core, /* i : last frame mode */ + const Word16 element_mode, /* i : element mode */ + TCX_CONFIG_HANDLE hTcxCfg, /* i/o: TCX configuration handle */ + Decoder_State *st0 /* i : bitstream */ +); + +Word16 ari_start_decoding_14bits_prm_ivas_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); + +void generate_masking_noise_ivas_fx( + Word32 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 *exp_out, /* o : time-domain signal exp */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 length, /* i : frame size */ + const Word16 core, /* i : core */ + const Word16 return_noise, /* i : noise is returned instead of added */ + const Word16 secondary, /* i : flag to indicate secondary noise generation */ + const Word16 element_mode, /* i : element mode */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ +); + +void SynthesisSTFT_dirac_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 samples_out, + HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ +); + +void generate_stereo_masking_noise_fx( + Word16 *syn, /* i/o: time-domain signal */ + Word16 Q_syn, + Decoder_State *st, /* i/o: decoder state structure */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 fadeOut, /* i : only fade out of previous state */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const Word16 nchan_out /* i : number of output channels */ +); + +void SynthesisSTFT_fx( + Word32 *fftBuffer, /* i : FFT bins */ + Word32 *timeDomainOutput, + Word32 *olapBuffer, + const Word16 *olapWin, + const Word16 tcx_transition, + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ +); + +void FdCng_decodeSID_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +); + +void cldfb_restore_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +ivas_error cldfb_save_memory_ivas_fx( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); + +Word16 sr2fscale( + const Word32 sr_core /* i : internal sampling rate */ +); + +void Copy_Scale_sig32( + const Word32 x[], /* i : signal to scale input Qx */ + Word32 y[], /* o : scaled signal output Qx */ + const Word16 lg, /* i : size of x[] Q0 */ + const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */ +); + +void swb_pre_proc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word16 *new_swb_speech, /* o : original input signal at 32kHz - Q0 */ + Word32 *new_swb_speech_fx, /* o : original input signal at 32kHz - Q - q_reImBuffer */ + Word16 *shb_speech, /* o : SHB target signal (6-14kHz) at 16kHz- Q(Q_shb_spch) */ + Word16 *Q_shb_spch, + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer Q - q_reImbuffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer Q - q_reImbuffer */ + Word16 q_reImBuffer, /* i : scale data of real and imag CLDFB buffers */ + CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ +); + +void core_encode_update_ivas_fx( + Encoder_State *st /* i/o: Encoder state structure */ +); + +void updt_enc_common_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 Q_new /* i : CUrrent frame scaling */ +); + +/* o : Q(2x - 31 - gb) */ +Word32 sum2_f_32_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 gb /* i : guard bits */ +); + +Word32 sum2_16_exp_fx( + const Word16 *vec, /* i : input vector Q(15 - exp) */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ +); + +Word32 sum2_32_exp_fx( + const Word32 *vec, /* i : input vector, Qx */ + const Word16 lvec, /* i : length of input vector */ + Word16 *exp, /* i/o: exponent of vector */ + Word16 gb /* i : guard bits */ +); + +Word32 sum2_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *e ); + +void ProcessStereoIGF_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + Word32 *pITFMDCTSpectrum_fx[CPE_CHANNELS][NB_DIV], /* i : MDCT spectrum fir ITF */ + Word16 q_pITFMDCTSpectrum_1, + Word16 q_pITFMDCTSpectrum_2, + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i/o: exp of inv_spectrum_fx */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + +void IGFEncApplyStereo_fx( + STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo encoder structure */ + Word16 ms_mask[2][MAX_SFB], /* i : bandwise MS mask */ + const IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS], /* i : instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ + Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ + Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ + Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ + Word16 exp_inv_spectrum_fx[CPE_CHANNELS], /* i : exp of inverse spectrum */ + const Word16 frameno, /* i : flag indicating index of current subfr. */ + const Word16 sp_aud_decision0, /* i : sp_aud_decision0 */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 mct_on ); + +void IGFSaveSpectrumForITF_ivas_fx( + IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igfGridIdx, /* i : IGF grid index */ + const Word32 *pITFSpectrum, /* i : MDCT spectrum */ + Word16 exp_pITFSpectrum ); + +Word16 IGFEncWriteBitstream_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 *pBitOffset, /* i : ptr to bitOffset counter */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 isIndepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ +); + +Word16 IGFSCFEncoderEncode_ivas_fx( + IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 bitCount, /* i : offset to the first bit in bitbuffer which should be readed by iisArithDecoderDecode function */ + Word16 *sfe, /* i : ptr to an array which contain quantized scalefactor energies */ + const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ + const Word16 indepFlag /* i : if 1 frame is independent, 0 = frame is coded with data from previous frame */ +); + +Word16 ari_encode_14bits_ext_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s, + Word32 symbol, /* Q0 */ + UWord16 const *cum_freq /* Q0 */ +); + +Word16 ari_encode_14bits_sign_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Word32 bits, /* Q0 */ + Tastat *s, + Word16 sign /* Q0 */ +); + +Word16 ari_done_encoding_14bits_ivas_fx( + Word16 *ptr, /* Q0 */ + Word16 bp, /* Q0 */ + Tastat *s ); + +void IGFEncConcatenateBitstream( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ + const Word16 bsBits, /* i : number of IGF bits written to list of indices */ + BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ +); + +void hq_generic_hf_encoding_fx( + const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */ + Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */ + const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + Word16 *hq_generic_exc_clas, /* o : bwe excitation class */ + Word16 length ); + +Word16 ari_decode_14bits_pow_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + UWord16 base ); + +Word16 ari_decode_14bits_sign_ivas( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); + +void lsf_syn_mem_backup_ivas_fx( + Encoder_State *st_fx, /* i: state structure */ + Word16 *btilt_code_fx, /* i: tilt code Q15 */ + Word32 *gc_threshold_fx, /* i: Q16 */ + Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ + Word16 *next_force_sf_bck_fx, /* o: */ + Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ + Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *streaklimit, /* Q15 */ + Word16 *pstreaklen ); + +ivas_error config_acelp1_fx( + const Word16 enc_dec, /* i : encoder/decoder flag */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 core_brate_inp, /* i : core bitrate */ + const Word16 core, /* i : core */ + const Word16 extl, /* i : extension layer */ + const Word32 extl_brate, /* i : extension layer bitrate */ + const Word16 L_frame, /* i : frame length at internal Fs */ + const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ + ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ + const Word16 signaling_bits, /* i : number of signaling bits */ + const Word16 coder_type, /* i : coder type */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 tc_subfr, /* i : TC subfr ID */ + const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ + Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ + Word16 *unbits, /* o : number of unused bits */ + const Word16 element_mode, /* i : element mode */ + Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 idchan, /* i : stereo channel ID */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +#define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) +#define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ ); +#endif + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +ivas_error push_next_indice_( + const char *caller, +#else +ivas_error push_next_indice( +#endif + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +ivas_error push_next_bits_( + const char *caller, +#else +ivas_error push_next_bits( #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ - ); - - /*! r: index of next coefficient */ - Word16 get_next_coeff_mapped_ivas_fx( - Word16 ii[2], /* i/o: coefficient indexes Q0*/ - Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ - Word16 *idx, /* o : index in unmapped domain Q0*/ - CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ - ); - - void RCcontextMapping_encode2_no_mem_s17_LCS_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - Word16 lastnz, /* Q0 */ - const Word16 nbbits, /* Q0 */ - const Word16 resQMaxBits, /* Q0 */ - CONTEXT_HM_CONFIG *hm_cfg ); - - void writeTCXparam_fx( - Encoder_State *st, /* i/o: Encoder State handle */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ - Word16 param[], /* i : parameters */ - const Word16 nbits_header, - const Word16 nbits_start, - const Word16 nbits_lpc, - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ - Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ - const Word16 target_bitsTCX10[2], - const Word16 pre_past_flag ); - - void calculate_hangover_attenuation_gain_ivas_fx( - Encoder_State *st, /* i : encoder state structure */ - Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ - ); - - void init_coder_ace_plus_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate */ - const Word32 igf_brate, /* i : IGF configuration bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ - ); - - void core_coder_reconfig_ivas_fx( - Encoder_State *st, - const Word32 last_total_brate ); - - void core_coder_mode_switch_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word32 last_total_brate, /* i : last bitrate */ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - ); - - void configureFdCngEnc_ivas_fx( - HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ - const Word16 bwidth, /* Q0 */ - const Word32 total_brate /* Q0 */ - ); - - Word16 getTcxonly_ivas_fx( - const Word16 element_mode, /* i : IVAS element mode */ - const Word32 total_brate, /* i : total bitrate */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ - const Word16 is_ism_format /* i : flag indicating ISM format */ - ); - - void SetModeIndex_ivas_fx( - Encoder_State *st, /* i : Encoder state */ - const Word32 last_total_brate, /* i : last total bitrate Q0*/ - const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ - const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ - ); - - void IGFEncSetMode_ivas_fx( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word32 total_brate, /* i : encoder total bitrate */ - const Word16 bwidth, /* i : encoder audio bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void init_tcx_cfg_ivas_fx( - TCX_CONFIG_HANDLE hTcxCfg, - const Word32 total_brate, - const Word32 sr_core, - const Word32 input_Fs, - const Word16 L_frame, - const Word16 bwidth, - const Word16 L_frameTCX, - const Word16 fscale, - const Word16 preemph_fac, - const Word16 tcxonly, - const Word16 rf_mode, - const Word16 igf, - const Word16 infoIGFStopFreq, - const Word16 element_mode, - const Word16 ini_frame, - const Word16 MCT_flag ); - - Word16 msvq_stage1_dct_search_fx( - const Word32 *u_fx, /* i : target exp : u_e */ - const Word16 u_e, /* i : exp for target Q0 */ - const Word16 N, /* i : target length and IDCT synthesis length */ - const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ - const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ - Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ - const Word16 *midQ_truncQ_fx, /* i : midQ vector */ - const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ - const Word16 n_segm, /* i : number of segments */ - const Word16 *cols_per_segment, /* i : remaining length per segment */ - const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ - const Word16 *entries_per_segment, /* i : number of rows per segment */ - const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ - const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ - const Word16 npost_check, /* i : number of neigbours to check , should be even */ - Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ - Word16 *indices_st1_local, /* o : selected cand indices */ - Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ - Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ - Word16 *dist1_ptr_e ); - - Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( - const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ - const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ - const Word32 *u_fx, /* i : target signal */ - const Word16 u_e, /* i : exp for target signal */ - const Word16 maxC_st1, /* i : number of candidates in stage1 */ - Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ - Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ - ); - - void FEC_encode_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ - const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ - const Word16 coder_type, /* i : type of coder Q0*/ - Word16 clas, /* i : signal clas for current frame Q0*/ - const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ - const Word16 *res, /* i : LP residual signal frame Qx*/ - Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ - const Word16 L_frame, /* i : Frame length Q0*/ - const Word32 total_brate, /* i : total codec bitrate Q0*/ - const Word16 Q_synth /* i : input scaling */ - ); - - ivas_error IGF_Reconfig_fx( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void core_switching_post_enc_ivas_fx( - Encoder_State *st /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ +); + +/*! r: index of next coefficient */ +Word16 get_next_coeff_mapped_ivas_fx( + Word16 ii[2], /* i/o: coefficient indexes Q0*/ + Word32 *pp, /* o : peak(1)/hole(0) indicator Q0*/ + Word16 *idx, /* o : index in unmapped domain Q0*/ + CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */ +); + +void RCcontextMapping_encode2_no_mem_s17_LCS_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + Word16 lastnz, /* Q0 */ + const Word16 nbbits, /* Q0 */ + const Word16 resQMaxBits, /* Q0 */ + CONTEXT_HM_CONFIG *hm_cfg ); + +void writeTCXparam_fx( + Encoder_State *st, /* i/o: Encoder State handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + CONTEXT_HM_CONFIG hm_cfg[], /* i/o: HM config */ + Word16 param[], /* i : parameters */ + const Word16 nbits_header, + const Word16 nbits_start, + const Word16 nbits_lpc, + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ + Word16 p_param[2], /* i/o: pointer to parameters from previous bs writing */ + const Word16 target_bitsTCX10[2], + const Word16 pre_past_flag ); + +void calculate_hangover_attenuation_gain_ivas_fx( + Encoder_State *st, /* i : encoder state structure */ + Word16 *att, /* o : attenuation factor */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ +); + +void init_coder_ace_plus_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word32 igf_brate, /* i : IGF configuration bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ +); + +void core_coder_reconfig_ivas_fx( + Encoder_State *st, + const Word32 last_total_brate ); + +void core_coder_mode_switch_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word32 last_total_brate, /* i : last bitrate */ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ +); + +void configureFdCngEnc_ivas_fx( + HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: Contains the variables related to the FD-based CNG process */ + const Word16 bwidth, /* Q0 */ + const Word32 total_brate /* Q0 */ +); + +Word16 getTcxonly_ivas_fx( + const Word16 element_mode, /* i : IVAS element mode */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 is_ism_format /* i : flag indicating ISM format */ +); + +void SetModeIndex_ivas_fx( + Encoder_State *st, /* i : Encoder state */ + const Word32 last_total_brate, /* i : last total bitrate Q0*/ + const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ + const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ +); + +void IGFEncSetMode_ivas_fx( + const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word32 total_brate, /* i : encoder total bitrate */ + const Word16 bwidth, /* i : encoder audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void init_tcx_cfg_ivas_fx( + TCX_CONFIG_HANDLE hTcxCfg, + const Word32 total_brate, + const Word32 sr_core, + const Word32 input_Fs, + const Word16 L_frame, + const Word16 bwidth, + const Word16 L_frameTCX, + const Word16 fscale, + const Word16 preemph_fac, + const Word16 tcxonly, + const Word16 rf_mode, + const Word16 igf, + const Word16 infoIGFStopFreq, + const Word16 element_mode, + const Word16 ini_frame, + const Word16 MCT_flag ); + +Word16 msvq_stage1_dct_search_fx( + const Word32 *u_fx, /* i : target exp : u_e */ + const Word16 u_e, /* i : exp for target Q0 */ + const Word16 N, /* i : target length and IDCT synthesis length */ + const Word16 maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const Word16 max_dct_trunc, /* i : maximum of truncation lenghts */ + Word32 *invTrfMatrix_fx, /* i : IDCT synthesis matrix for dim N Q31 */ + const Word16 *midQ_truncQ_fx, /* i : midQ vector */ + const Word32 *dct_scaleF_fx, /* i : global scale factors Q10 */ + const Word16 n_segm, /* i : number of segments */ + const Word16 *cols_per_segment, /* i : remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ + const Word16 *entries_per_segment, /* i : number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ + const Word16 npost_check, /* i : number of neigbours to check , should be even */ + Word32 *st1_mse_ptr_fx, /* i : dynRAM buffer for MSEs exp : u_e */ + Word16 *indices_st1_local, /* o : selected cand indices */ + Word32 *st1_syn_vec_ptr_fx, /* i/o: buffer for IDCT24 synthesis i :exp : u_e */ + Word32 *dist1_ptr_fx, /* o : resulting stage 1 MSEs in DCT-N domain */ + Word16 *dist1_ptr_e ); + +Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( + const Word32 *st1_syn_vec_ptr_fx, /* i : IDCT24 synthesis vectors */ + const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ + const Word32 *u_fx, /* i : target signal */ + const Word16 u_e, /* i : exp for target signal */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ + Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ + Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ +); + +void FEC_encode_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ + const Word16 *synth, /* i : pointer to synthesized speech for E computation Q_Synth*/ + const Word16 coder_type, /* i : type of coder Q0*/ + Word16 clas, /* i : signal clas for current frame Q0*/ + const Word16 *fpit, /* i : close loop fractional pitch buffer Q6*/ + const Word16 *res, /* i : LP residual signal frame Qx*/ + Word16 *last_pulse_pos, /* i/o: Position of the last pulse Q0*/ + const Word16 L_frame, /* i : Frame length Q0*/ + const Word32 total_brate, /* i : total codec bitrate Q0*/ + const Word16 Q_synth /* i : input scaling */ +); + +ivas_error IGF_Reconfig_fx( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void core_switching_post_enc_ivas_fx( + Encoder_State *st /* i/o: encoder state structure */ #ifndef CLEANUP_ACELP_ENC - , - Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ - Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ - Word16 A_fx[], /* i : unquant. LP filter coefs. */ - Word16 Q_new + , + Word16 *old_inp_12k8_fx, /* i : old input signal @12.8kHz */ + Word16 *old_inp_16k_fx, /* i : old input signal @16kHz */ + Word16 A_fx[], /* i : unquant. LP filter coefs. */ + Word16 Q_new #endif - ); - - void residu_ivas_fx( - const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ - const Word16 a_exp, - const Word16 m, /* i : order of LP filter */ - const Word32 *x, /* i : input signal (usually speech) Qx*/ - Word32 *y, /* o : output signal (usually residual) Qx*/ - const Word16 l /* i : size of filtering */ - ); - - void WriteToBitstream_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - void WriteToBitstream_ivas_fx( - ParamsBitMap const *paramsBitMap, - const Word16 nArrayLength, - const Word16 **pStream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); - - - /*===========================================================================================*/ - /*----------------------------------------------------------------------------------* - * MODE1 prototypes - *----------------------------------------------------------------------------------*/ - - /*! r: output random value */ - Word16 own_random( - Word16 *seed /* i/o: random seed */ - ); - - /*! r: sum of all vector elements */ - Word16 sum_s( - const Word16 *vec, /* i : input vector */ - const Word16 lvec /* i : length of input vector */ - ); - - void set_c( - Word8 y[], /* i/o: Vector to set */ - const Word8 a, /* i : Value to set the vector to */ - const Word32 N /* i : Length of the vector */ - ); - - void set_s( - Word16 y[], /* i/o: Vector to set */ - const Word16 a, /* i : Value to set the vector to */ - const Word16 N /* i : Lenght of the vector */ - ); - - void set_l( - Word32 y[], /* i/o: Vector to set */ - const Word32 a, /* i : Value to set the vector to */ - const Word16 N /* i : Length of the vector */ - ); - - void set_zero_fx( - Word32 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ - ); - - void set_zero2_fx( - Word32 *vec, /* o : input vector */ - const Word32 lvec /* i : length of the vector */ - ); - - void set16_zero_fx( - Word16 *vec, /* o : input vector */ - const Word16 lvec /* i : length of the vector */ - ); - - void mvs2s( - const Word16 x[], /* i : input vector */ - Word16 y[], /* o : output vector */ - const Word16 n /* i : vector size */ - ); - - void mvl2l( - const Word32 x[], /* i : input vector */ - Word32 y[], /* o : output vector */ - const Word16 n /* i : vector size */ - ); - - Word16 maximumAbs_l( - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ - ); - - /*! r: index of the minimum value in the input vector */ - Word16 minimum_s( - const Word16 *vec, /* i : Input vector */ - const Word16 lvec, /* i : Vector length */ - Word16 *min_val /* o : minimum value in the input vector */ - ); - - void sort_l( - Word32 *x, /* i/o: Vector to be sorted */ - Word16 len /* i/o: vector length */ - ); - - ivas_error push_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 id, /* i : ID of the indice */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ - ); - - ivas_error push_next_indice_( +); + +void residu_ivas_fx( + const Word16 *a, /* i : LP filter coefficients Q31-a_exp*/ + const Word16 a_exp, + const Word16 m, /* i : order of LP filter */ + const Word32 *x, /* i : input signal (usually speech) Qx*/ + Word32 *y, /* o : output signal (usually residual) Qx*/ + const Word16 l /* i : size of filtering */ +); + +void WriteToBitstream_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + +void WriteToBitstream_ivas_fx( + ParamsBitMap const *paramsBitMap, + const Word16 nArrayLength, + const Word16 **pStream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); + + +/*===========================================================================================*/ +/*----------------------------------------------------------------------------------* + * MODE1 prototypes + *----------------------------------------------------------------------------------*/ + +/*! r: output random value */ +Word16 own_random( + Word16 *seed /* i/o: random seed */ +); + +/*! r: sum of all vector elements */ +Word16 sum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ +); + +void set_c( + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word32 N /* i : Length of the vector */ +); + +void set_s( + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ +); + +void set_l( + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ +); + +void set_zero_fx( + Word32 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); + +void set_zero2_fx( + Word32 *vec, /* o : input vector */ + const Word32 lvec /* i : length of the vector */ +); + +void set16_zero_fx( + Word16 *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ +); + +void mvs2s( + const Word16 x[], /* i : input vector */ + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ +); + +void mvl2l( + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 n /* i : vector size */ +); + +Word16 maximumAbs_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ +); + +/*! r: index of the minimum value in the input vector */ +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ +); + +void sort_l( + Word32 *x, /* i/o: Vector to be sorted */ + Word16 len /* i/o: vector length */ +); + +ivas_error push_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); + +ivas_error push_next_indice_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ - ); + BSTR_ENC_HANDLE hBstr, + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ +); - ivas_error push_next_bits_( +ivas_error push_next_bits_( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, + const char *caller, #endif - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ - const Word16 nb_bits /* i : number of bits to pack */ - ); - - /*! r: maximum number of indices */ - Word16 get_ivas_max_num_indices_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ - ); - - /*! r: maximum number of indices */ - Word16 get_BWE_max_num_indices( - const Word32 extl_brate /* i : extensiona layer bitrate */ - ); - - /*! r: maximum number of indices */ - Word16 get_ivas_max_num_indices_metadata_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ - ); - ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ - ); - - ivas_error check_ind_list_limits( - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ - ); - - void move_indices( - INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ - INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const Word16 nb_indices /* i : number of moved indices */ - ); - - /*! r: index of the indice in the list, -1 if not found */ - Word16 find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const Word16 id, /* i : ID of the indice */ - UWord16 *value, /* o : value of the quantized indice */ - Word16 *nb_bits /* o : number of bits used to quantize the indice */ - ); - - /*! r: number of deleted indices */ - UWord16 delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 id /* i : ID of the indice */ - ); - - /*! r: value of the indice */ - UWord16 get_indice_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ - ); - - void reset_indices_dec( - Decoder_State *st /* i/o: decoder state structure */ - ); - - Word16 rate2EVSmode( - const Word32 brate, /* i : bitrate */ - Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ - ); - - /*! r: 1 = OK, 0 = something wrong */ - ivas_error read_indices_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - UWord16 bit_stream[], /* i : bitstream buffer */ - UWord16 num_bits, /* i : number of bits in bitstream */ - Word16 *prev_ft_speech, - Word16 *CNG, - Word16 bfi /* i : bad frame indicator */ - ); - - void ivas_set_bitstream_pointers( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - ); - - Decoder_State **reset_elements( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - ); - - void convertSerialToBytestream_fx( - const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ - const UWord16 num_bits, /* i : number of bits in the input bitstream */ - UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ - ); - - void mdct_switching_dec_fx( - Decoder_State *st /* i/o: decoder state structure */ - ); - - Word16 print_disclaimer( - FILE *fPtr ); - - void preemph_ivas_fx( - Word32 *signal, /* i/o: signal Qx*/ - const Word16 mu, /* i : preemphasis factor Q15*/ - const Word16 L, /* i : vector size Q0*/ - Word32 *mem /* i/o: memory (x[-1]) Qx*/ - ); - - void create_offset( - UWord32 *offset_scale1, - UWord32 *offset_scale2, - const Word16 mode, - const Word16 prediction_flag ); - - void BASOP_cfft_ivas( - Word32 *re, /* i/o: real part */ - Word32 *im, /* i/o: imag part */ - Word16 s, /* i : stride real and imag part */ - Word16 *scale /* i : scalefactor */ - ); - - Word32 ar_div_ivas( - Word32 num, - Word32 denum ); - - Word32 Mult_32_16( - Word32 a, - Word16 b ); - - Word32 Mult_32_32( - Word32 a, - Word32 b ); + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ + const Word16 nb_bits /* i : number of bits to pack */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); + +/*! r: maximum number of indices */ +Word16 get_BWE_max_num_indices( + const Word32 extl_brate /* i : extensiona layer bitrate */ +); + +/*! r: maximum number of indices */ +Word16 get_ivas_max_num_indices_metadata_fx( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ +); +ivas_error ind_list_realloc( + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ +); + +ivas_error check_ind_list_limits( + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +); + +void move_indices( + INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ + INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ + const Word16 nb_indices /* i : number of moved indices */ +); + +/*! r: index of the indice in the list, -1 if not found */ +Word16 find_indice( + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + const Word16 id, /* i : ID of the indice */ + UWord16 *value, /* o : value of the quantized indice */ + Word16 *nb_bits /* o : number of bits used to quantize the indice */ +); + +/*! r: number of deleted indices */ +UWord16 delete_indice( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 id /* i : ID of the indice */ +); + +/*! r: value of the indice */ +UWord16 get_indice_fx( + Decoder_State *st, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +void reset_indices_dec( + Decoder_State *st /* i/o: decoder state structure */ +); + +Word16 rate2EVSmode( + const Word32 brate, /* i : bitrate */ + Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ +); + +/*! r: 1 = OK, 0 = something wrong */ +ivas_error read_indices_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 bit_stream[], /* i : bitstream buffer */ + UWord16 num_bits, /* i : number of bits in bitstream */ + Word16 *prev_ft_speech, + Word16 *CNG, + Word16 bfi /* i : bad frame indicator */ +); + +void ivas_set_bitstream_pointers( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +Decoder_State **reset_elements( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void convertSerialToBytestream_fx( + const UWord16 *const serial, /* i : input serial bitstream with values 0 and 1 */ + const UWord16 num_bits, /* i : number of bits in the input bitstream */ + UWord8 *const bytestream /* o : output compact bitstream (bytestream) */ +); + +void mdct_switching_dec_fx( + Decoder_State *st /* i/o: decoder state structure */ +); + +Word16 print_disclaimer( + FILE *fPtr ); + +void preemph_ivas_fx( + Word32 *signal, /* i/o: signal Qx*/ + const Word16 mu, /* i : preemphasis factor Q15*/ + const Word16 L, /* i : vector size Q0*/ + Word32 *mem /* i/o: memory (x[-1]) Qx*/ +); + +void create_offset( + UWord32 *offset_scale1, + UWord32 *offset_scale2, + const Word16 mode, + const Word16 prediction_flag ); + +void BASOP_cfft_ivas( + Word32 *re, /* i/o: real part */ + Word32 *im, /* i/o: imag part */ + Word16 s, /* i : stride real and imag part */ + Word16 *scale /* i : scalefactor */ +); + +Word32 ar_div_ivas( + Word32 num, + Word32 denum ); + +Word32 Mult_32_16( + Word32 a, + Word16 b ); + +Word32 Mult_32_32( + Word32 a, + Word32 b ); #ifdef DEBUGGING - void read_next_force( - int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ - FILE *f_force, /* i : force switching profile (0 if N/A) */ - int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ - ); +void read_next_force( + int16_t *force, /* i/o: force value (0/1, 0 = speech, 1 = music)*/ + FILE *f_force, /* i : force switching profile (0 if N/A) */ + int32_t *force_profile_cnt /* i/o: counter of frames for force switching profile file */ +); #endif - ivas_error init_encoder_fx( - Encoder_State *st, /* i/o: state structure */ - Encoder_Struct *st_ivas, /* i/o: encoder state structure */ - const Word16 idchan, /* i : channel ID */ - const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const Word32 element_brate /* i : element bitrate */ - ); - - ivas_error acelp_core_enc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 inp[], /* i : input signal of the current frame Q_new*/ - Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ - const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ - Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ - Word16 *q_old_syn_12k8_16, - Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits Q0*/ - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ - const Word16 Q_new ); - - void flip_and_downmix_generic_fx32( - Word32 input[], /* i : input spectrum Qx*/ - Word32 output[], /* o : output spectrum Qx*/ - const Word16 length, /* i : length of spectra */ - Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ - Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ - Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ - ); - - /* o : Q(2x - 31 - gb) */ - Word16 quant_2p_2N1_fx( - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ - ); - - void bands_and_bit_alloc_ivas_fx( - const Word16 cor_strong_limit, /* i : HF correlation */ - const Word16 noise_lev, /* i : dwn scaling factor */ - const Word32 core_brate, /* i : core bit rate */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ - const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ - Word16 *max_ener_band, /* o : Sorted order */ - Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ - Word16 *nb_subbands, /* o : Number of subband allowed */ - const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ - Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ - Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ - const Word16 coder_type, /* i : coding type */ - const Word16 bwidth, /* i : input signal bandwidth */ - const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ - const Word16 L_frame, /* i : frame length */ - const Word16 element_mode, /* i : element mode */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ - ); - - void ivas_find_wsp_fx( - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_subfr, /* i : length of subframe Q0*/ - const Word16 nb_subfr, /* i : number of subframes Q0*/ - const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ - Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ - const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ - const Word16 tilt_fact, /* i : tilt factor Q15 */ - Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ - Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ - const Word16 gamma, /* i : weighting factor Q15 */ - const Word16 L_look /* i : look-ahead Q0*/ - ); - - Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( - Word16 *x, /* Q0 */ - const Word16 nt, /* Q0 */ - const Word16 target, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem ); - - Word16 RCcontextMapping_encode2_estimate_bandWise_fx( - Word16 *x, /* Q0 */ - const Word16 start_line, /* Q0 */ - const Word16 end_line, /* Q0 */ - HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ - ); - - /*! r: Q15 */ - Word16 expfp_evs_fx( - const Word16 x, /* i : mantissa Q15-e */ - const Word16 x_e /* i : exponent Q0 */ - ); - - void tcx_arith_render_envelope_ivas_fx( - const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ - const Word16 L_frame, /* i : number of spectral lines Q0*/ - const Word16 L_spec, /* i : length of the coded spectrum Q0*/ - const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ - const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ - const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ - Word32 env[] /* o : shaped signal envelope Q16*/ - ); - - void tcx_arith_decode_envelope_ivas_fx( - Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ - Word16 *q_spectrum_e, /* o : MDCT exponent */ - const Word16 L_frame, /* i : frame or MDCT length */ - Word16 L_spec, /* i : length w/o BW limitation */ - const Word16 A_ind[], /* i : quantised LPC coefficients */ - const Word16 target_bits, /* i : number of available bits */ - Word16 prm[], /* i : bitstream parameters */ - const Word16 use_hm, /* i : use HM in current frame? */ - const Word16 prm_hm[], /* i : HM parameter area */ - Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ - Word16 *arith_bits, /* o : bits used for ari. coding */ - Word16 *signaling_bits, /* o : bits used for signaling */ - const Word16 low_complexity /* i : low-complexity flag */ - ); - - void UnmapIndex_fx( - const Word16 PeriodicityIndex, /* Q0 */ - const Word16 Bandwidth, /* Q0 */ - const Word16 LtpPitchLag, /* Q0 */ - const Word8 SmallerLags, /* Q0 */ - Word16 *FractionalResolution, /* Q0 */ - Word32 *Lag /* Q0 */ - ); +ivas_error init_encoder_fx( + Encoder_State *st, /* i/o: state structure */ + Encoder_Struct *st_ivas, /* i/o: encoder state structure */ + const Word16 idchan, /* i : channel ID */ + const Word16 vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode, /* i : ISM mode */ + const Word32 element_brate /* i : element bitrate */ +); + +ivas_error acelp_core_enc_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 inp[], /* i : input signal of the current frame Q_new*/ + Word16 A[NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw[NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquant. for subframes Q12*/ + const Word32 epsP[M + 1], /* i : LP prediction errors Qx*/ + Word16 lsp_new[M], /* i : LSPs at the end of the frame Q15*/ + Word16 lsp_mid[M], /* i : LSPs in the middle of the frame Q15*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 attack_flag, /* i : attack flag (GSC or TC) Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation st->prev_Q_bwe_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE q_old_syn_12k8_16*/ + Word16 *q_old_syn_12k8_16, + Word16 pitch_buf[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Word16 *unbits, /* o : number of unused bits Q0*/ + STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ + Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel X2.56*/ + const Word16 Q_new ); + +void flip_and_downmix_generic_fx32( + Word32 input[], /* i : input spectrum Qx*/ + Word32 output[], /* o : output spectrum Qx*/ + const Word16 length, /* i : length of spectra */ + Word32 mem1_ext[HILBERT_ORDER1], /* i/o: memory Qx*/ + Word32 mem2_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word32 mem3_ext[2 * HILBERT_ORDER2], /* i/o: memory Qx*/ + Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */ +); + +/* o : Q(2x - 31 - gb) */ +Word16 quant_2p_2N1_fx( + const Word16 pos1, /* i: position of the pulse 1 */ + const Word16 pos2, /* i: position of the pulse 2 */ + const Word16 N /* i: number of bits FOR position */ +); + +void bands_and_bit_alloc_ivas_fx( + const Word16 cor_strong_limit, /* i : HF correlation */ + const Word16 noise_lev, /* i : dwn scaling factor */ + const Word32 core_brate, /* i : core bit rate */ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q */ + Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */ + const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */ + Word16 *max_ener_band, /* o : Sorted order */ + Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */ + Word16 *nb_subbands, /* o : Number of subband allowed */ + const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */ + Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */ + Word16 *pvq_len, /* o : Number of bin covered with the PVQ */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 GSC_noisy_speech, /* i : GSC noisy speech flag */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); + +void ivas_find_wsp_fx( + const Word16 L_frame, /* i : length of the frame Q0*/ + const Word16 L_subfr, /* i : length of subframe Q0*/ + const Word16 nb_subfr, /* i : number of subframes Q0*/ + const Word16 *A_fx, /* i : A(z) filter coefficients Q12 */ + Word16 *Aw_fx, /* o : weighted A(z) filter coefficients Q12 */ + const Word16 *speech_fx, /* i : pointer to the denoised speech frame Q_new */ + const Word16 tilt_fact, /* i : tilt factor Q15 */ + Word16 *wsp_fx, /* o : poitnter to the weighted speech frame Q_new */ + Word16 *mem_wsp_fx, /* i/o: W(Z) denominator memory Q_new */ + const Word16 gamma, /* i : weighting factor Q15 */ + const Word16 L_look /* i : look-ahead Q0*/ +); + +Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx( + Word16 *x, /* Q0 */ + const Word16 nt, /* Q0 */ + const Word16 target, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem ); + +Word16 RCcontextMapping_encode2_estimate_bandWise_fx( + Word16 *x, /* Q0 */ + const Word16 start_line, /* Q0 */ + const Word16 end_line, /* Q0 */ + HANDLE_RC_CONTEXT_MEM hContextMem /* Q0 */ +); + +/*! r: Q15 */ +Word16 expfp_evs_fx( + const Word16 x, /* i : mantissa Q15-e */ + const Word16 x_e /* i : exponent Q0 */ +); + +void tcx_arith_render_envelope_ivas_fx( + const Word16 A_ind[], /* i : LPC coefficients of signal envelope Q12*/ + const Word16 L_frame, /* i : number of spectral lines Q0*/ + const Word16 L_spec, /* i : length of the coded spectrum Q0*/ + const Word16 preemph_fac, /* i : pre-emphasis factor Q15*/ + const Word16 gamma_w, /* i : A_ind -> weighted envelope factor Q15*/ + const Word16 gamma_uw, /* i : A_ind -> non-weighted envelope factor Q14*/ + Word32 env[] /* o : shaped signal envelope Q16*/ +); + +void tcx_arith_decode_envelope_ivas_fx( + Decoder_State *st, /* i/o: coder state */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word16 *q_spectrum_e, /* o : MDCT exponent */ + const Word16 L_frame, /* i : frame or MDCT length */ + Word16 L_spec, /* i : length w/o BW limitation */ + const Word16 A_ind[], /* i : quantised LPC coefficients */ + const Word16 target_bits, /* i : number of available bits */ + Word16 prm[], /* i : bitstream parameters */ + const Word16 use_hm, /* i : use HM in current frame? */ + const Word16 prm_hm[], /* i : HM parameter area */ + Word16 tcxltp_pitch, /* i : TCX LTP pitch in FD, -1 if n/a*/ + Word16 *arith_bits, /* o : bits used for ari. coding */ + Word16 *signaling_bits, /* o : bits used for signaling */ + const Word16 low_complexity /* i : low-complexity flag */ +); + +void UnmapIndex_fx( + const Word16 PeriodicityIndex, /* Q0 */ + const Word16 Bandwidth, /* Q0 */ + const Word16 LtpPitchLag, /* Q0 */ + const Word8 SmallerLags, /* Q0 */ + Word16 *FractionalResolution, /* Q0 */ + Word32 *Lag /* Q0 */ +); #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) - Word32 tcx_hm_render_fx( - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - Word16 p[] /* o: harmonic model Q13 */ - ); - - void tcx_hm_modify_envelope_fx( - const Word16 gain, /* i: HM gain Q11 */ - const Word32 lag, /* i: pitch lag Q0 */ - const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ - const Word16 p[], /* i: harmonic model Q13 */ - Word32 env[], /* i/o: envelope Q16 */ - const Word16 L_frame /* i: number of spectral lines Q0 */ - ); - - void tcx_hm_decode( - const Word16 L_frame, /* i : number of spectral lines */ - Word32 env[], /* i/o: envelope shape (Q16) */ - const Word16 targetBits, /* i : target bit budget */ - const Word16 coder_type, /* i : GC/VC coder type */ - const Word16 prm_hm[], /* i : HM parameters */ - const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ - Word16 *hm_bits /* o : bit consumption */ - ); - - void writeTCXMode_fx( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - Word16 *nbits_start /* o : nbits start Q0*/ - ); - - void writeTCXWindowing_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 overlap_mode /* i : overlap mode Q0*/ - ); - - void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const Word16 param_lpc[], /* i : LPC parameters to write */ - const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ - const Word16 no_param_lpc, /* i : number of LPC parameters */ - Word16 *nbits_lpc /* o : LPC bits written */ - ); - - void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); - void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); - void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); - void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); - - Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); - - Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); - Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); - - void ResetTnsData_flt( - STnsData *pTnsData ); - - void ClearTnsFilterCoefficients_flt( - STnsFilter *pTnsFilter ); - - void EncodeTnsData( - STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ - Word16 *stream, /* o : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - Word16 *pnBits /* o : number of written bits */ - ); - - Word16 DecodeTnsData_ivas( - STnsConfig const *pTnsConfig, - const Word16 *stream, - Word16 *pnSize, - STnsData *pTnsData ); - - void WriteTnsData( - const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ - const Word16 *stream, /* i : internal data stream */ - Word16 *pnSize, /* o : number of written parameters */ - BSTR_ENC_HANDLE hBstr, /* o : bitstream */ - Word16 *pnBits /* o : number of written bits */ - ); - - void ReadTnsData_ivas( - STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - - void analysisCldfbEncoder_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word32 *timeIn, /*q11*/ - Word16 timeInq, /*q0*/ - Word16 samplesToProcess, /*q0*/ - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 *ppBuf_Ener, - Word16 *enerBuffSum_exp, - CLDFB_SCALE_FACTOR *scale ); - - ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const Word32 sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ - ); - - void resampleCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ - const Word32 newSamplerate /* i : new samplerate to operate */ - ); - - ivas_error cldfb_save_memory_ivas( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ - ); - - /*! r: flag indicating a valid bitrate */ - Word16 is_EVS_bitrate( - const Word32 ivas_total_brate, /* i : EVS total bitrate */ - Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ - ); - - ivas_error IGF_Reconfig( - IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const Word16 igf, /* i : IGF on/off */ - const Word16 reset, /* i : reset flag */ - const Word32 brate, /* i : bitrate for configuration */ - const Word16 bwidth, /* i : signal bandwidth */ - const Word16 element_mode, /* i : IVAS element mode */ - const Word16 rf_mode /* i : flag to signal the RF mode */ - ); - - void ordr_esti( - const Word16 k, /* i : sub-vector index */ - Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ - Word16 svOrder[], /* i/o: AVQ sub-vector order */ - const Word16 Nsv /* i : total sub-vectors in a sub-frames */ - ); - - /*===========================================================================================*/ +Word32 tcx_hm_render_fx( + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + Word16 p[] /* o: harmonic model Q13 */ +); + +void tcx_hm_modify_envelope_fx( + const Word16 gain, /* i: HM gain Q11 */ + const Word32 lag, /* i: pitch lag Q0 */ + const Word16 fract_res, /* i: fractional resolution of the lag Q0 */ + const Word16 p[], /* i: harmonic model Q13 */ + Word32 env[], /* i/o: envelope Q16 */ + const Word16 L_frame /* i: number of spectral lines Q0 */ +); + +void tcx_hm_decode( + const Word16 L_frame, /* i : number of spectral lines */ + Word32 env[], /* i/o: envelope shape (Q16) */ + const Word16 targetBits, /* i : target bit budget */ + const Word16 coder_type, /* i : GC/VC coder type */ + const Word16 prm_hm[], /* i : HM parameters */ + const Word16 LtpPitchLag, /* i : LTP pitch lag or -1 if none */ + Word16 *hm_bits /* o : bit consumption */ +); + +void writeTCXMode_fx( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + Word16 *nbits_start /* o : nbits start Q0*/ +); + +void writeTCXWindowing_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 overlap_mode /* i : overlap mode Q0*/ +); + +void writeLPCparam( + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ +); + +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); +void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); +void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); + +Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); +Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); +Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); + +Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); +Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); + +void ResetTnsData_flt( + STnsData *pTnsData ); + +void ClearTnsFilterCoefficients_flt( + STnsFilter *pTnsFilter ); + +void EncodeTnsData( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + STnsData const *pTnsData, /* i : TNS data struct (quantized param) */ + Word16 *stream, /* o : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + Word16 *pnBits /* o : number of written bits */ +); + +Word16 DecodeTnsData_ivas( + STnsConfig const *pTnsConfig, + const Word16 *stream, + Word16 *pnSize, + STnsData *pTnsData ); + +void WriteTnsData( + const STnsConfig *pTnsConfig, /* i : TNS Configuration struct */ + const Word16 *stream, /* i : internal data stream */ + Word16 *pnSize, /* o : number of written parameters */ + BSTR_ENC_HANDLE hBstr, /* o : bitstream */ + Word16 *pnBits /* o : number of written bits */ +); + +void ReadTnsData_ivas( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void analysisCldfbEncoder_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + Word32 *timeIn, /*q11*/ + Word16 timeInq, /*q0*/ + Word16 samplesToProcess, /*q0*/ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], + Word32 *ppBuf_Ener, + Word16 *enerBuffSum_exp, + CLDFB_SCALE_FACTOR *scale ); + +ivas_error openCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ + CLDFB_TYPE type, /* i : analysis or synthesis */ + const Word32 sampling_rate, /* i : sampling rate */ + CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ +); + +void resampleCldfb_ivas( + HANDLE_CLDFB_FILTER_BANK hs, /* i/o: filter bank handle */ + const Word32 newSamplerate /* i : new samplerate to operate */ +); + +ivas_error cldfb_save_memory_ivas( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +); + +/*! r: flag indicating a valid bitrate */ +Word16 is_EVS_bitrate( + const Word32 ivas_total_brate, /* i : EVS total bitrate */ + Word16 *Opt_AMR_WB /* i : AMR-WB IO flag */ +); + +ivas_error IGF_Reconfig( + IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder */ + const Word16 igf, /* i : IGF on/off */ + const Word16 reset, /* i : reset flag */ + const Word32 brate, /* i : bitrate for configuration */ + const Word16 bwidth, /* i : signal bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); + +void ordr_esti( + const Word16 k, /* i : sub-vector index */ + Word16 *Mpos, /* i/o: dominant sub-vector position from ACV */ + Word16 svOrder[], /* i/o: AVQ sub-vector order */ + const Word16 Nsv /* i : total sub-vectors in a sub-frames */ +); + +/*===========================================================================================*/ #endif diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 7073ee69d..610b9cae0 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -242,7 +242,7 @@ void tbe_celp_exc( #endif #ifdef CLEANUP_ACELP_ENC -void tbe_celp_exc( +void tbe_celp_exc_fx( #else void tbe_celp_exc_ivas( #endif diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 9a4c5536e..049626e59 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -936,10 +936,6 @@ static void decod_gen_voic_core_switch_fx( gain_dec_mless_fx( st_fx, L_frame, GENERIC, 0, -1, code, st_fx->old_Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code ); } - /* _ (Word16*) gain_pit : quantized pitch gain (Q14) */ - /* _ (Word32*) gain_code : quantized codebook gain (Q16) */ - /* _ (Word16*) gain_inov : gain of the innovation (used for normalization) (Q12) */ - /* _ (Word32*) norm_gain_code : norm. gain of the codebook excitation (Q16) */ #ifdef CLEANUP_ACELP_ENC st_fx->tilt_code_fx = est_tilt_fx( exc, gain_pit, code, gain_code, &voice_fac, *Q_exc, L_SUBFR ); /*Q15*/ #else diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 9870d45cb..9c1cd74ac 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -354,7 +354,7 @@ void decoder_acelp_fx( IF( st->igf != 0 ) { #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); + tbe_celp_exc_fx( EVS_MONO, 0, st->L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); #else tbe_celp_exc( st->L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); #endif diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 983f6d8e6..0288e3d85 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -175,7 +175,7 @@ ivas_error decod_gen_voic_fx( } #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); + tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #endif diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index f2764e6e3..43a948bba 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -170,30 +170,26 @@ void decod_tran_fx( /* update LP filtered gains for the case of frame erasures */ #ifdef CLEANUP_ACELP_ENC lp_gain_updt_fx( st_fx->element_mode, i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); + + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); + move16(); #else IF( st_fx->element_mode == EVS_MONO ) { lp_gain_updt_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); -#ifndef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); move16(); -#endif } ELSE { lp_gain_updt_ivas_fx( i_subfr, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame_fx ); -#ifndef CLEANUP_ACELP_ENC + st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR, 0 ); move16(); -#endif } #endif -#ifdef CLEANUP_ACELP_ENC - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc, L_SUBFR ); - move16(); -#endif - /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index fffead087..c145610f8 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -1259,6 +1259,7 @@ Word32 gain_dec_gaus_fx( L_enr_q = L_mult( index, stepSize ); /* Q0 * QstepSize_Exp -> QstepSize_Exp+1 */ L_enr_q = L_shl( L_enr_q, sub( 24 - 1, stepSize_Exp ) ); /* QstepSize_Exp+1 -> Q24 */ L_enr_q = L_add( L_enr_q, L_shl( L_deposit_h( lowBound ), 8 ) ); /* Q24 */ + /*------------------------------------------------------------* * gain = pow(10.0, enr/20) * = pow(2, 3.321928*enr/20) @@ -1416,7 +1417,6 @@ void gain_dec_amr_wb_fx( Word32 L_tmp; Word16 expg, exp_gcode0, fracg; - /**gain_inov = 1.0f/ (float)sqrt( ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR );*/ L_tmp = Dot_product12( code, code, L_SUBFR, &expg ); /*Q31 - expg*/ @@ -1465,6 +1465,7 @@ void gain_dec_amr_wb_fx( * = pow(2, 3.321928*gcode0/20) * = pow(2, 0.166096*gcode0) *-----------------------------------------------------------------*/ + L_tmp = L_mult( gcode0, 21771 ); /* *0.166096 in Q17 -> Q27 */ L_tmp = L_shr( L_tmp, 9 + 2 ); /* From Q27 to Q16 */ L_Extract( L_tmp, &exp_gcode0, &fracg ); /* Extract exponent of gcode0 */ @@ -1510,12 +1511,14 @@ void gain_dec_amr_wb_fx( past_qua_en[i] = past_qua_en[i - 1]; move16(); } + /*past_qua_en[0] = (float)(20.0*log10(qua_en));*/ /*----------------------------------------------------------* * past_qua_en[0] = 20*log10(t_qua_gain[indice*2+1]) * = 6.0206*log2(t_qua_gain[indice*2+1]) * = 6.0206*(log2(t_qua_gain[indice*2+1]Q11 -11) *----------------------------------------------------------*/ + tmp = norm_l( qua_en ); fracg = Log2_norm_lc( L_shl( qua_en, tmp ) ); expg = sub( 30, tmp ); @@ -1529,6 +1532,7 @@ void gain_dec_amr_wb_fx( /*-----------------------------------------------------------------* * Normalized code gain *-----------------------------------------------------------------*/ + /**norm_gain_code = *gain_code / *gain_inov;*/ expg = sub( norm_s( *gain_inov ), 1 ); expg = s_max( expg, 0 ); diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index a25e259c0..5f5912fb1 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -268,7 +268,7 @@ void decod_gen_2sbfr_fx( IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) && !( st->tdm_LRTD_flag ) ) ) { #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); + tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); #else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); #endif diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 9fa47424f..5a2916434 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -499,13 +499,8 @@ ivas_error acelp_core_enc_fx( } ELSE IF( EQ_16( coder_type, TRANSITION ) ) { -#ifdef CLEANUP_ACELP_ENC - tc_subfr_fx = encod_tran_ivas_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, - exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ -#else tc_subfr_fx = encod_tran_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, tc_subfr_fx, position, unbits_fx, shift, Q_new ); /* Q0 */ -#endif } ELSE IF( hSC_VBR->ppp_mode ) { @@ -533,13 +528,8 @@ ivas_error acelp_core_enc_fx( hTdCngEnc->burst_ho_cnt = 0; move16(); /* VOICED frames in SC-VBR when bumped up*/ -#ifdef CLEANUP_ACELP_ENC encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#else - encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, - exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#endif } } ELSE IF( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_24k40 ) ) ) @@ -551,13 +541,8 @@ ivas_error acelp_core_enc_fx( ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ -#ifdef CLEANUP_ACELP_ENC - encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, - exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#else encod_gen_voic_fx( st_fx, inp_fx, Aw_fx, Aq_fx, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf_fx, voice_factors_fx, bwe_exc_fx, unbits_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, shift, Q_new ); -#endif } /* update st->mem_syn1 for ACELP core switching */ @@ -1373,7 +1358,11 @@ ivas_error acelp_core_enc_ivas_fx( } ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { +#ifdef CLEANUP_ACELP_ENC + encod_tran_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); +#else encod_tran_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tc_subfr, position, unbits, 0, Q_new ); +#endif } ELSE IF( ppp_mode ) { diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 5e9dc4cd8..98ab17afb 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -377,7 +377,6 @@ static void encod_gen_voic_core_switch_fx( * ACELP subframe loop *------------------------------------------------------------------*/ - Copy( res, exc, L_SUBFR ); /* Q1 */ IF( EQ_16( L_frame, L_FRAME16k ) ) @@ -422,6 +421,7 @@ static void encod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * LP filtering of the adaptive excitation, codebook target computation *-----------------------------------------------------------------*/ + lp_flag = st_fx->acelp_cfg.ltf_mode; /* Q0 */ lp_select = lp_filt_exc_enc_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ @@ -445,6 +445,7 @@ static void encod_gen_voic_core_switch_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ + IF( EQ_16( L_frame, L_FRAME ) ) { gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, 0, -1, xn, y1, shift_wsp, y2, code, st_fx->old_Es_pred_fx, diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 3195a0b60..0fbd01b3a 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -263,7 +263,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc,0 ); + tbe_celp_exc_fx( EVS_MONO, 0, L_frame, L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, 0 ); #else tbe_celp_exc( L_frame, i_subfr, T0, T0_frac, &error, bwe_exc ); #endif diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index e5e12159f..89566c413 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -240,11 +240,7 @@ void encod_gen_voic_fx( *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ -#ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); -#else tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); -#endif /*-----------------------------------------------------------------* * Find adaptive exitation @@ -295,14 +291,9 @@ void encod_gen_voic_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, - gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift, 0 ); -#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr_fx, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn2_fx, code_fx, y2_fx, &unbits_PI_fx, L_SUBFR, shift ); -#endif /*-----------------------------------------------------------------* * Gain encoding @@ -565,7 +556,7 @@ void encod_gen_voic_ivas_fx( shift_wsp = add( Q_new, shift ); #ifdef CLEANUP_ACELP_ENC test(); - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) ) #else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) #endif @@ -649,7 +640,7 @@ void encod_gen_voic_ivas_fx( move16(); #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); + tbe_celp_exc_fx( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #else tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index f98b21729..bd9c429b2 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -385,13 +385,8 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); -#else inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); -#endif } ELSE #endif @@ -400,13 +395,8 @@ void enc_pit_exc_fx( * Innovation encoding *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, 0 ); -#else inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); -#endif } #endif @@ -429,24 +419,14 @@ void enc_pit_exc_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); -#else inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); -#endif } ELSE #endif { -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); -#else inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); -#endif } #endif diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 0d0d7a2d2..975f62337 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -187,13 +187,8 @@ Word16 encod_tran_fx( * ACELP codebook search + pitch sharpening *-----------------------------------------------------------------*/ -#ifdef CLEANUP_ACELP_ENC - inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, - i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, 0 ); -#else inov_encode_fx( st_fx, st_fx->core_brate, 0, L_frame_fx, st_fx->last_L_frame, st_fx->coder_type, st_fx->bwidth, st_fx->sharpFlag, i_subfr, tc_subfr, p_Aq, gain_pit, cn, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); -#endif test(); test(); @@ -425,7 +420,7 @@ Word16 encod_tran_fx( #endif #ifdef CLEANUP_ACELP_ENC -Word16 encod_tran_ivas_fx( +Word16 encod_tran_fx( #else Word16 encod_tran_ivas_fx( #endif @@ -535,7 +530,7 @@ Word16 encod_tran_ivas_fx( shift_wsp = add( Q_new, shift ); #ifdef CLEANUP_ACELP_ENC test(); - if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && st_fx->element_mode != EVS_MONO ) + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && NE_32( st_fx->element_mode, EVS_MONO ) ) #else if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) #endif @@ -565,9 +560,6 @@ Word16 encod_tran_ivas_fx( Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 ); Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ - - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn, L_SUBFR, shift ); } ELSE #endif @@ -585,11 +577,11 @@ Word16 encod_tran_ivas_fx( } Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); - - /* scaling of xn[] to limit dynamic at 12 bits */ - Scale_sig( xn, L_SUBFR, shift ); } + /* scaling of xn[] to limit dynamic at 12 bits */ + Scale_sig( xn, L_SUBFR, shift ); + /*-----------------------------------------------------------------* * TC: subframe determination & * adaptive/glottal part of excitation construction diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index c5de16ceb..a1da64adf 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -400,7 +400,7 @@ Word16 inov_encode_ivas_fx( } #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) #endif { maximum_abs_16_fx( xn2, L_subfr, &max_xn2 ); @@ -632,7 +632,7 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) #endif { Qh2 = sub( 14, norm_s( h2[0] ) ); diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 970e5001f..b1018b917 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -290,7 +290,7 @@ void encod_gen_2sbfr_fx( Scale_sig( h1, 2 * L_SUBFR, sub( 13, q_h1 ) ); // Q13 #ifdef CLEANUP_ACELP_ENC - tbe_celp_exc( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); + tbe_celp_exc_fx( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); #else tbe_celp_exc_ivas( st->element_mode, st->idchan, L_frame, 2 * L_SUBFR, i_subfr, T0, T0_frac, &error, bwe_exc, st->tdm_LRTD_flag ); #endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index dcfb5e4c0..ce74ed5a5 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1880,6 +1880,7 @@ void encod_nelp_ivas_fx( Word16 shift ); Word16 encod_tran_fx( +#ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -1900,6 +1901,7 @@ Word16 encod_tran_fx( ); Word16 encod_tran_ivas_fx( +#endif Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -2074,8 +2076,8 @@ ivas_error encod_ppp_ivas_fx( Word16 Q_new, Word16 shift ); -#ifndef CLEANUP_ACELP_ENC void encod_gen_voic_fx( +#ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : i speech Q0*/ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes Q12*/ @@ -2093,10 +2095,7 @@ void encod_gen_voic_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 shift, Word16 Q_new ); -#endif -#ifdef CLEANUP_ACELP_ENC -void encod_gen_voic_fx( -#else + void encod_gen_voic_ivas_fx( #endif Encoder_State *st_fx, /* i/o: state structure */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index fce2df6c5..5ec3fe688 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -20,6 +20,7 @@ static void tc_enc_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_su static void tc_enc_ivas_fx( Encoder_State *st_fx, const Word16 i_subfr, Word16 *tc_subfr, Word16 *position, const Word16 *h1_fx, const Word16 *xn_fx, Word16 *exc_fx, Word16 *yy1_fx, Word16 *T0_min, Word16 *T0_max, Word16 *T0, Word16 *T0_frac, Word16 *gain_pit_fx, Word16 g_corr_fx[], Word16 *bwe_exc_fx, Word16 Q_new ); #endif + /*==========================================================================*/ /* FUNCTION : void transition_enc_fx () */ /*--------------------------------------------------------------------------*/ @@ -165,7 +166,7 @@ void transition_enc_fx( *clip_gain = 0; move16(); #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { g_corr_fx[0] = MAX16B /* 1.0f in Q15 */; move16(); @@ -413,7 +414,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -470,7 +471,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -543,7 +544,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -577,7 +578,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -623,7 +624,7 @@ void transition_enc_fx( /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } @@ -868,7 +869,7 @@ void transition_enc_fx( *clip_gain = 0; move16(); #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { g_corr_fx[0] = 328 /* 0.01f in Q15 */; move16(); @@ -901,7 +902,7 @@ void transition_enc_fx( { /* Find the adaptive codebook vector - ACELP long-term prediction */ #ifdef CLEANUP_ACELP_ENC - IF( st_fx->element_mode > EVS_MONO ) + IF( NE_32( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } -- GitLab From 0e8ed3443a70131fbd6bb18c16d6dbac64736861 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 6 Jan 2026 14:31:06 +0100 Subject: [PATCH 13/14] fix --- lib_enc/enc_gen_voic_fx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 89566c413..cead9d24c 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -685,6 +685,14 @@ void encod_gen_voic_ivas_fx( push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); } +#ifdef CLEANUP_ACELP_ENC + IF( st_fx->element_mode == EVS_MONO ) + { + /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ + st_fx->hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, st_fx->hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + } +#endif + /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ -- GitLab From d7f61056faa03fada02ef45d51d867db53481f38 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 Jan 2026 19:33:22 +0100 Subject: [PATCH 14/14] inov_decode_ivas_fx() leftover --- lib_com/prot_fx.h | 3 ++- lib_dec/inov_dec_fx.c | 3 ++- lib_dec/ivas_td_low_rate_dec_fx.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8f3f5eca5..8285b23b0 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7129,6 +7129,7 @@ void inov_decode_fx( const Word16 L_subfr /* i : subframe length Q0 */ ); +#ifndef CLEANUP_ACELP_ENC void inov_decode_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate Q0 */ @@ -7142,7 +7143,7 @@ void inov_decode_ivas_fx( Word16 *code, /* o : algebraic excitation Q12 */ const Word16 L_subfr /* i : subframe length Q0 */ ); - +#endif void dec_acelp_4t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 nbbits, /* i : number of bits per codebook */ diff --git a/lib_dec/inov_dec_fx.c b/lib_dec/inov_dec_fx.c index 4d44e5b5b..30479dd04 100644 --- a/lib_dec/inov_dec_fx.c +++ b/lib_dec/inov_dec_fx.c @@ -191,7 +191,7 @@ void inov_decode_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); return; } - +#ifndef CLEANUP_ACELP_ENC /*======================================================================*/ /* FUNCTION : inov_decode_ivas_fx() */ /*-----------------------------------------------------------------------*/ @@ -376,3 +376,4 @@ void inov_decode_ivas_fx( cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, code, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_subfr ); return; } +#endif diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 5f5912fb1..92d6d3153 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -297,7 +297,11 @@ void decod_gen_2sbfr_fx( * Innovation decoding *--------------------------------------------------------------*/ +#ifdef CLEANUP_ACELP_ENC + inov_decode_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); +#else inov_decode_ivas_fx( st, st->core_brate, 0, L_frame, sharpFlag, i_subfr, p_Aq, st->tilt_code_fx, *pt_pitch, code, 2 * L_SUBFR ); +#endif /*--------------------------------------------------------------* * Gain decoding -- GitLab