diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index 8162a98d3fa3147ea128100fddad063e0f8cd18d..e9abb7651e854e529e6ebfbb5a43857cb5d4696a 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -439,6 +439,7 @@ static Word16 fcb_table( * Routine to allocate fixed innovation codebook bit-budget *--------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES static ivas_error acelp_FCB_allocator( Word16 *nBits, /* i/o: available bit-budget */ Word16 fixed_cdk_index[], /* o : codebook index Q0 */ @@ -599,7 +600,7 @@ static ivas_error acelp_FCB_allocator( return error; } - +#endif static ivas_error acelp_FCB_allocator_ivas( Word16 *nBits, /* i/o: available bit-budget */ Word16 fixed_cdk_index[], /* o : codebook index Q0 */ @@ -761,6 +762,7 @@ static ivas_error acelp_FCB_allocator_ivas( * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz *--------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES ivas_error config_acelp1( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ @@ -1885,7 +1887,7 @@ ivas_error config_acelp1( * - should be in range of <6700; 24350> for ACELP@12.8kHz * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz *--------------------------------------------------------------------*/ - +#endif ivas_error config_acelp1_IVAS( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 54fef9e37ca4a881fd62c05b38e13e81d641476f..582fd3c8a763b3b305570f79ea874eab67d1e067 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -38,6 +38,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void Inac_swtch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ @@ -155,8 +157,7 @@ void Inac_swtch_ematch_fx( return; } - - +#endif void Inac_switch_ematch_ivas_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ @@ -250,31 +251,68 @@ void Inac_switch_ematch_ivas_fx( exp = sub( exp, 14 ); IF( LT_16( i, 2 ) ) { - FOR( j = 0; j < 8; j++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( element_mode, EVS_MONO ) ) { - L_tmp = L_mult0( *pt_exc, ftmp ); - L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ - *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ - move16(); - pt_exc++; + FOR( j = 0; j < 8; j++ ) + { + L_tmp = L_mult( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } + } + ELSE +#endif + { + FOR( j = 0; j < 8; j++ ) + { + L_tmp = L_mult0( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } } } ELSE { - FOR( j = 0; j < 16; j++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( element_mode, EVS_MONO ) ) { - L_tmp = L_mult0( *pt_exc, ftmp ); - L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ - *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ - move16(); - pt_exc++; + FOR( j = 0; j < 16; j++ ) + { + L_tmp = L_mult( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } + } + ELSE +#endif + { + FOR( j = 0; j < 16; j++ ) + { + L_tmp = L_mult0( *pt_exc, ftmp ); + L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc) -> Q(15+Q_exc)*/ + *pt_exc = round_fx_sat( L_tmp ); /*Q_exc - 1*/ + move16(); + pt_exc++; + } } } } /* Going back to time */ - Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc - Scale_sig( exc2, 240, 1 ); // Q_exc +#ifdef REMOVE_EVS_DUPLICATES + IF( GT_16( element_mode, EVS_MONO ) ) +#endif + { + Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc + Scale_sig( exc2, 240, 1 ); // Q_exc + } edct_16fx( dct_exc_tmp, exc2, L_frame, 5, element_mode ); } diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 2e00e4641e177d2e17d2bbecbe6c93f93c522e1a..61aa1333c1426b3362ddd3a552ba811aa9db4220 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1332,32 +1332,51 @@ void highband_exc_dct_in_ivas_fx( } } - Word16 Q_tmp = *Q_exc; - move16(); - Word16 Q_old = *Q_exc; - move16(); - Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); - IF( exc_wo_nf != NULL ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( element_mode, EVS_MONO ) ) { - Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp ); - IF( GT_16( Q_tmp, *Q_exc ) ) - { - Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) ); - } - ELSE IF( LT_16( Q_tmp, *Q_exc ) ) + Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); + + IF( exc_wo_nf != NULL ) { - Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) ); - *Q_exc = Q_tmp; - move16(); + Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } - Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); - Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); } ELSE { - Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); +#endif + Word16 Q_tmp = *Q_exc; + move16(); + Word16 Q_old = *Q_exc; + move16(); + Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); + + IF( exc_wo_nf != NULL ) + { + Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp ); + IF( GT_16( Q_tmp, *Q_exc ) ) + { + Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) ); + } + ELSE IF( LT_16( Q_tmp, *Q_exc ) ) + { + Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) ); + *Q_exc = Q_tmp; + move16(); + } + Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); + Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame ); + } + ELSE + { + Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); + } +#ifdef REMOVE_EVS_DUPLICATES } +#endif + /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum @@ -1397,7 +1416,12 @@ void highband_exc_dct_in_ivas_fx( Q_hb_exc = 0; move16(); envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, *Q_exc, &Q_hb_exc ); +#ifdef REMOVE_EVS_DUPLICATES + test(); + IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) ) +#else IF( GT_16( *Q_exc, Q_hb_exc ) ) +#endif { Scale_sig( exc_wo_nf, L_frame, sub( Q_hb_exc, *Q_exc ) ); *Q_exc = Q_hb_exc; diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index 43c3c30382e30f25aef125500cf857769ee6e8a3..63c0bb1a5d6427804b73990d31db6a6e1d53f8bc --- a/lib_com/options.h +++ b/lib_com/options.h @@ -1,91 +1,93 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#ifndef OPTIONS_H -#define OPTIONS_H - -/* clang-format off */ - -/* ################### Start DEBUGGING switches ######################## */ - -/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ -#ifdef DEBUGGING -#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ -#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ -#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ -/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ -/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ -#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ -#endif - -#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ - -/*#define WMOPS*/ /* Activate complexity and memory counters */ -#ifdef WMOPS -/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ -/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ -/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ -#endif - -/* #################### End DEBUGGING switches ############################ */ - -#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS -#define BASOP_NOGLOB_DECLARE_LOCAL -#endif - -#define FIX_867_CLDFB_NRG_SCALE - -#define FIX_1378_ACELP_OUT_OF_BOUNDS - -/* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ -/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ -#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */ -//#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ -#define HARM_PUSH_BIT -#define HARM_ENC_INIT -//#define HARM_SCE_INIT -#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ -#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ -#define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ - -#define TEST_HR - -#endif +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#ifndef OPTIONS_H +#define OPTIONS_H + +/* clang-format off */ + +/* ################### Start DEBUGGING switches ######################## */ + +/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ +#ifdef DEBUGGING +#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ +#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ +#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ +/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ +/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ +#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ +#endif + +#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ + +/*#define WMOPS*/ /* Activate complexity and memory counters */ +#ifdef WMOPS +/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ +/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ +/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ +/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ +#endif + +/* #################### End DEBUGGING switches ############################ */ + +#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS +#define BASOP_NOGLOB_DECLARE_LOCAL +#endif + +#define FIX_867_CLDFB_NRG_SCALE + +#define FIX_1378_ACELP_OUT_OF_BOUNDS + +/* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ +#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ +#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ +#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ +/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ +#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */ +//#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ +#define HARM_PUSH_BIT +#define HARM_ENC_INIT +//#define HARM_SCE_INIT +#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ +#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ +#define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ + +#define TEST_HR + + +#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ +#endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 4257b7e79fb16242288d0686fadb189565c7e78c..e4d9b3dab41aee18e74813c80bdc38d23d801c0d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3286,6 +3286,7 @@ void synthesise_fb_high_band_fx( Word16 bpf_memory_Q[], Word16 Qout ); +#ifndef REMOVE_EVS_DUPLICATES void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ #ifdef ADD_IVAS_TBE_CODE @@ -3313,6 +3314,7 @@ void prep_tbe_exc_fx( const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ #endif ); +#endif void prep_tbe_exc_ivas_fx( const Word16 L_frame_fx, /* i : length of the frame */ @@ -4856,6 +4858,7 @@ Word16 BITS_ALLOC_config_acelp( const Word16 narrowband, const Word16 nb_subfr ); +#ifndef REMOVE_EVS_DUPLICATES ivas_error config_acelp1( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ @@ -4883,7 +4886,7 @@ ivas_error config_acelp1( const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); - +#endif Word16 set_ACELP_flag( const Word16 element_mode, /* i : element mode */ const Word32 element_brate, /* i : element bitrate */ @@ -5830,6 +5833,7 @@ void tcx_ltp_post_fx32( Word32 *tcx_buf, /* sig_q */ Word16 sig_q ); +#ifndef REMOVE_EVS_DUPLICATES // gs_inact_switching_fx.c void Inac_swtch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ @@ -5843,6 +5847,7 @@ void Inac_swtch_ematch_fx( const short last_core, /* i : Last core used */ const short last_codec_mode /* i : Last codec mode */ ); +#endif void Inac_switch_ematch_ivas_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ @@ -6089,6 +6094,7 @@ void td_bwe_dec_init_fx( const Word32 output_Fs /* i : output sampling rate */ ); +#ifndef REMOVE_EVS_DUPLICATES // lsf_dec_fx.c void lsf_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ @@ -6102,7 +6108,7 @@ void lsf_dec_fx( , const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ); - +#endif void lsf_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 tc_subfr, /* i : TC subframe index Q0*/ @@ -6258,6 +6264,7 @@ void lsf_mid_dec_fx( Word16 lsp_mid[] /* o : quantized LSPs Q15*/ ); +#ifndef REMOVE_EVS_DUPLICATES // cng_dec_fx.c void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ @@ -6268,7 +6275,7 @@ void CNG_dec_fx( Word16 *allow_cn_step, /* o : allow CN step Q0 */ Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ Word32 *q_env ); - +#endif void CNG_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 last_element_mode, /* i : last element mode Q0 */ @@ -6697,6 +6704,7 @@ void nb_post_filt_fx( const Word16 disable_hpf /* i : flag to diabled HPF */ ); +#ifndef REMOVE_EVS_DUPLICATES void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -6707,7 +6715,7 @@ void formant_post_filt_fx( Word32 rate, /* (i) : bit-rate */ const Word16 off_flag /* i : off flag */ ); - +#endif void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -6882,6 +6890,7 @@ void PulseResynchronization_fx( Word32 /*float*/ const pitchEnd /*i Q16*/ ); +#ifndef REMOVE_EVS_DUPLICATES // gs_dec_fx.c void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -6896,7 +6905,7 @@ void decod_audio_fx( , Word16 *gain_buf /*Q14*/ ); - +#endif void decod_audio_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ @@ -6915,6 +6924,7 @@ void decod_audio_ivas_fx( const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ ); +#ifndef REMOVE_EVS_DUPLICATES 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*/ @@ -6927,7 +6937,7 @@ void gsc_dec_fx( 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 ); - +#endif void gsc_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ @@ -6995,6 +7005,7 @@ void gain_dec_mless_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ ); +#ifndef REMOVE_EVS_DUPLICATES void gain_dec_lbr_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -7009,6 +7020,7 @@ void gain_dec_lbr_fx( , const Word16 L_subfr /* i : subfr lenght */ ); +#endif void gain_dec_lbr_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7143,6 +7155,7 @@ void re8_PPV_fx( Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ ); +#ifndef REMOVE_EVS_DUPLICATES // dec_pit_exc_fx.c void dec_pit_exc_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -7157,7 +7170,7 @@ void dec_pit_exc_fx( , Word16 *gain_buf /*Q14*/ ); - +#endif void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ @@ -7212,6 +7225,7 @@ void Mode2_delta_pit_dec( Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ ); +#ifndef REMOVE_EVS_DUPLICATES Word16 pit_decode_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -7226,7 +7240,7 @@ Word16 pit_decode_fx( /* o : floating pitch value Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ const Word16 L_subfr /* i : subframe length */ ); - +#endif /* o : floating pitch value */ Word16 pit_decode_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7589,6 +7603,7 @@ void configureFdCngDec_fx( const Word16 Last_L_frame, const Word16 element_mode ); +#ifndef REMOVE_EVS_DUPLICATES /* Apply the CLDFB-based CNG */ Word16 ApplyFdCng_fx( Word16 *timeDomainInput, /* i : pointer to time domain i */ @@ -7602,7 +7617,7 @@ Word16 ApplyFdCng_fx( Decoder_State *st, const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */ Word16 is_music ); - +#endif Word16 ApplyFdCng_ivas_fx( Word16 *timeDomainInput, /* i : pointer to time domain input */ Word16 Q, @@ -8201,6 +8216,7 @@ void FEC_pitch_estim_fx( Word16 element_mode /* i : element mode */ ); +#ifndef REMOVE_EVS_DUPLICATES // FEC_scale_sync_fx.c void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ @@ -8231,7 +8247,7 @@ void FEC_scale_syn_fx( 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 */ ); - +#endif void FEC_scale_syn_ivas_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -8258,6 +8274,9 @@ void FEC_scale_syn_ivas_fx( Word16 *mem_syn, /* o: initial synthesis filter states */ Word16 Q_exc, Word16 Q_syn, +#ifdef REMOVE_EVS_DUPLICATES + const Word16 element_mode, /* i : element mode */ +#endif 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 */ ); @@ -8545,6 +8564,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ ); +#ifndef REMOVE_EVS_DUPLICATES // dec_uv_fx.c void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -8557,7 +8577,7 @@ void decod_unvoiced_fx( 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 ); - +#endif void decod_unvoiced_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ @@ -8601,6 +8621,7 @@ void gaus_L2_dec( Word16 *seed_acelp /*i/o : random seed Q0 */ ); +#ifndef REMOVE_EVS_DUPLICATES // dec_gen_voic_fx.c ivas_error decod_gen_voic_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ @@ -8617,7 +8638,7 @@ ivas_error decod_gen_voic_fx( Word16 *unbits, /* number of unused bits */ Word16 *gain_buf /*Q14*/ ); - +#endif ivas_error decod_gen_voic_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ @@ -9560,6 +9581,8 @@ void d_gain_pred_fx( Word16 *Es_pred, /* o : predicited scaled innovation energy */ Word16 **pt_indice /* i/o: pointer to the buffer of indices */ ); + +#ifndef REMOVE_EVS_DUPLICATES // acelp_core_dec_fx.c ivas_error acelp_core_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -9585,7 +9608,7 @@ ivas_error acelp_core_dec_fx( STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ const Word16 read_sid_info /* i : read SID info flag */ ); - +#endif // evs_dec_fx.c ivas_error evs_dec_fx( Decoder_State *st_fx, /* i/o : Decoder state structure */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 238b478c5abce7058655ca0592e3f89969e1e201..869d73733629d32357fc04346799cfaf2a981112 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7315,6 +7315,7 @@ void tbe_celp_exc( /* _ None */ /*======================================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ #ifdef ADD_IVAS_TBE_CODE @@ -7483,7 +7484,7 @@ void prep_tbe_exc_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ - +#endif void prep_tbe_exc_ivas_fx( const Word16 L_frame_fx, /* i : length of the frame */ #if 1 // def ADD_IVAS_TBE_CODE diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index 612816efd236c6ca1a51dcca0933ec4d1b7b6284..a23c9aa90bf6b582ad1425094a242689ec6f4058 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -511,6 +511,9 @@ void FEC_exc_estim_fx( /* st_fx->L_frame / L_SUBFR */ tmp = shr( st_fx->L_frame, 6 ); /* Replication of the last spectrum, with a slight downscaling of its dynamic */ +#ifdef REMOVE_EVS_DUPLICATES + gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); +#else IF( st_fx->element_mode == EVS_MONO ) { gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); @@ -519,6 +522,7 @@ void FEC_exc_estim_fx( { gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); } +#endif *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ move16(); /* Transform back to time domain */ diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index d664aa9fbb2ea39a35ea23477c0ec2e3517e40c9..714a60166865e38fd8efe3676fef761aa8b67345 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -50,6 +50,7 @@ /* _ None */ /*========================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -614,7 +615,7 @@ void FEC_scale_syn_fx( return; } - +#endif void FEC_scale_syn_ivas_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -641,6 +642,9 @@ void FEC_scale_syn_ivas_fx( Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/ Word16 Q_exc, Word16 Q_syn, +#ifdef REMOVE_EVS_DUPLICATES + const Word16 element_mode, /* i : element mode */ +#endif 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 */ ) @@ -735,8 +739,15 @@ void FEC_scale_syn_ivas_fx( /*-----------------------------------------------------------------* * Find the energy/gain at the end of the frame *-----------------------------------------------------------------*/ + tmp = sub( 3, getScaleFactor16( synth, L_frame ) ); + +#ifdef REMOVE_EVS_DUPLICATES + test(); + IF( tmp > 0 && GT_16( element_mode, EVS_MONO ) ) +#else IF( tmp > 0 ) +#endif { Word16 synth_tmp[L_FRAME16k]; Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 7a3c786448fbef596e0b6b44660224d4e66e8b4e..0fbedff60385b942088c7d38fff83ad9ef0c1e65 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -10,6 +10,8 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" /* Common constants */ #include "cnst.h" /* Common constants */ + +#ifndef REMOVE_EVS_DUPLICATES /*==========================================================================*/ /* FUNCTION : void acelp_core_dec_fx () */ /*--------------------------------------------------------------------------*/ @@ -1539,3 +1541,4 @@ ivas_error acelp_core_dec_fx( return IVAS_ERR_OK; } +#endif diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 38999e99e4f462d9b9c0af182a5532afb935d672..ad8ca9b504ddd874b3086a35b4517494ecda4b9d 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -45,12 +45,13 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * acelp_core_dec_ivas_fx() * * ACELP core decoder *-------------------------------------------------------------------*/ -static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 old_NoiseExp ); + ivas_error acelp_core_dec_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ @@ -76,7 +77,6 @@ ivas_error acelp_core_dec_ivas_fx( ) { Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; - Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ Word16 output_frame; /* frame length at output sampling freq. */ @@ -121,16 +121,17 @@ ivas_error acelp_core_dec_ivas_fx( Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; Word16 *old_exc_s_fx; /* Start of last excitation frame */ Word16 *p_tdm_Pri_pitch_buf_fx; - Word16 local_element_mode; + Word16 tmp, exp, local_element_mode; ivas_error error; - Word32 bpf_error_signal_fx[L_FRAME16k]; - set32_fx( bpf_error_signal_fx, 0, L_FRAME16k ); Word16 bpf_error_signal_16fx[L_FRAME16k]; + Word16 Q_real; + Word32 max_real, max_imag, max_val; + + set32_fx( bpf_error_signal_fx, 0, L_FRAME16k ); set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k ); set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) ); set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) ); - Word16 tmp; error = IVAS_ERR_OK; move32(); @@ -152,6 +153,7 @@ ivas_error acelp_core_dec_ivas_fx( /*----------------------------------------------------------------* * stereo SID and CNG frames processing *----------------------------------------------------------------*/ + test(); test(); IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) @@ -159,13 +161,16 @@ ivas_error acelp_core_dec_ivas_fx( IF( EQ_16( st->cng_type, FD_CNG ) ) { configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); + Word16 old_NoiseEstExp; old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; move16(); + /* Only run parameter decoding in SID frames */ IF( EQ_32( st->core_brate, SID_2k40 ) ) { FdCng_decodeSID_ivas_fx( st ); + Word16 n1, n2; n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART ); n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); @@ -182,6 +187,7 @@ ivas_error acelp_core_dec_ivas_fx( STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); move32(); } + ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); } ELSE @@ -222,6 +228,7 @@ ivas_error acelp_core_dec_ivas_fx( realBuffer_fx[i] = realBufferTmp_fx[i]; imagBuffer_fx[i] = imagBufferTmp_fx[i]; } + /*----------------------------------------------------------------* * Initialization *----------------------------------------------------------------*/ @@ -235,9 +242,9 @@ ivas_error acelp_core_dec_ivas_fx( syn1_tmp_fx[1] = 0; move16(); syn1_fx = syn1_tmp_fx + 2; - st->bpf_off = 0; move16(); + test(); test(); test(); @@ -271,6 +278,7 @@ ivas_error acelp_core_dec_ivas_fx( st->hGSCDec->Last_frame_ener_fx = MAX_32; move32(); } + test(); test(); test(); @@ -344,6 +352,7 @@ ivas_error acelp_core_dec_ivas_fx( int_fs = INT_FS_16k; move16(); } + test(); /* reset post-filter in case of switching */ if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) ) @@ -362,6 +371,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); } test(); + /* TD stereo parameters */ IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { @@ -393,6 +403,7 @@ ivas_error acelp_core_dec_ivas_fx( /*----------------------------------------------------------------* * Updates in case of internal sampling rate switching *----------------------------------------------------------------*/ + test(); test(); IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) @@ -480,7 +491,7 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE { - Word16 exp = 0; + exp = 0; move16(); IF( EQ_16( st->last_L_frame, L_FRAME32k ) ) { @@ -543,7 +554,7 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE { - Word16 exp = 0; + exp = 0; move16(); IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) ) { @@ -562,12 +573,14 @@ ivas_error acelp_core_dec_ivas_fx( exp = 1; move16(); } + st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx ); move16(); st->bfi_pitch_frame = L_FRAME16k; move16(); } } + test(); test(); if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) ) @@ -597,6 +610,7 @@ ivas_error acelp_core_dec_ivas_fx( /*----------------------------------------------------------------* * Decoding of GSC IVAS mode *----------------------------------------------------------------*/ + test(); test(); test(); @@ -615,6 +629,7 @@ ivas_error acelp_core_dec_ivas_fx( /*----------------------------------------------------------------* * Decoding of inactive CNG frames *----------------------------------------------------------------*/ + test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { @@ -627,6 +642,7 @@ ivas_error acelp_core_dec_ivas_fx( /* comfort noise generation */ local_element_mode = st->element_mode; move16(); + test(); test(); if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) ) @@ -641,11 +657,23 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { - Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; - move16(); - FdCng_decodeSID_ivas_fx( st ); - rescale_fdCngDec( st->hFdCngDec, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); + } + ELSE +#endif + { + Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; + move16(); + + FdCng_decodeSID_ivas_fx( st ); + + Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); + Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx + } + *sid_bw = 0; move16(); } @@ -661,6 +689,8 @@ ivas_error acelp_core_dec_ivas_fx( move32(); } + ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + Word16 new_sidNoiseEstExp = 31 - Q4; move16(); Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp) @@ -690,6 +720,7 @@ ivas_error acelp_core_dec_ivas_fx( noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1]; move32(); + FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) { st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx; @@ -697,7 +728,16 @@ ivas_error acelp_core_dec_ivas_fx( } } - generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 ); + } + ELSE +#endif + { + generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); + } FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); @@ -714,12 +754,25 @@ ivas_error acelp_core_dec_ivas_fx( } i = st->Q_exc; move16(); + test(); IF( st->hMusicPF && st->hGSCDec ) { - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, - L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS? + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, + st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + } + ELSE +#endif + { + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, + L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + } } + IF( st->hPFstat != NULL ) { Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale, @@ -730,6 +783,7 @@ ivas_error acelp_core_dec_ivas_fx( Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale, &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL ); } + Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc /* update past excitation signals for LD music post-filter */ @@ -740,27 +794,52 @@ ivas_error acelp_core_dec_ivas_fx( /* Update music post processing values */ /* Filter energies update */ - FOR( i = 0; i < DCT_L_POST; i++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15 - move16(); + FOR( i = 0; i < DCT_L_POST; i++ ) + { + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); + move16(); + } + } + ELSE +#endif + { + FOR( i = 0; i < DCT_L_POST; i++ ) + { + st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15 + move16(); + } } } - /* synthesis at 12.8kHz sampling rate */ move16(); syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn ); - st->Q_syn_cng = st->Q_syn; - move16(); - st->Q_exc_cng = st->Q_exc; - move16(); + /* reset the decoder */ CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); - /* update st->mem_syn1 for ACELP core switching */ - Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1) + +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /* update st_fx->mem_syn1 for ACELP core switching */ + Copy( st->mem_syn3_fx, st->mem_syn1_fx, M ); + } + ELSE +#endif + { + st->Q_syn_cng = st->Q_syn; + move16(); + st->Q_exc_cng = st->Q_exc; + move16(); + + /* update st->mem_syn1 for ACELP core switching */ + Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1) + } /* update old synthesis for classification */ Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); @@ -790,6 +869,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); uc_two_stage_flag = 0; move16(); + test(); IF( !st->nelp_mode_dec && !st->ppp_mode_dec ) { @@ -844,8 +924,10 @@ ivas_error acelp_core_dec_ivas_fx( st->last_code_preq = 0; move16(); } + st->use_acelp_preq = 0; move16(); + /*-----------------------------------------------------------------* * LSF de-quantization and interpolation *-----------------------------------------------------------------*/ @@ -893,10 +975,12 @@ ivas_error acelp_core_dec_ivas_fx( /* LSP interpolation and conversion of LSPs to A(z) */ int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 ); + /* Check LSF stability (distance between old LSFs and current LSFs) */ st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); move16(); } + test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { @@ -911,6 +995,7 @@ ivas_error acelp_core_dec_ivas_fx( Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */ } + test(); IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) { @@ -933,8 +1018,10 @@ ivas_error acelp_core_dec_ivas_fx( { last_pulse_pos = 0; move16(); + /* decode the last glottal pulse position */ T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits ); + test(); test(); IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) ) @@ -960,6 +1047,7 @@ ivas_error acelp_core_dec_ivas_fx( * In case of first frame after an erasure and transition from voiced to unvoiced or inactive * redo the LPC interpolation *------------------------------------------------------------*/ + test(); test(); test(); @@ -984,6 +1072,7 @@ ivas_error acelp_core_dec_ivas_fx( /*------------------------------------------------------------* * Decode excitation according to coding type *------------------------------------------------------------*/ + test(); test(); IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ @@ -1005,18 +1094,20 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE IF( st->nelp_mode_dec ) { - /* SC-VBR - NELP frames */ Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 st->Q_exc = 0; move16(); + /* SC-VBR - NELP frames */ decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames */ decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx ); + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } ELSE IF( st->ppp_mode_dec ) @@ -1024,6 +1115,7 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 st->Q_exc = 0; move16(); + /* SC-VBR - PPP frames */ IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) ) { @@ -1041,6 +1133,7 @@ ivas_error acelp_core_dec_ivas_fx( /* AUDIO and INACTIVE frames (coded by GSC technology) */ decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } ELSE @@ -1075,6 +1168,7 @@ ivas_error acelp_core_dec_ivas_fx( /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ + test(); test(); test(); @@ -1104,6 +1198,7 @@ ivas_error acelp_core_dec_ivas_fx( { Word16 last_coder_type = st->last_coder_type; move16(); + test(); test(); test(); @@ -1115,14 +1210,32 @@ ivas_error acelp_core_dec_ivas_fx( Word16 qdct = 0; move16(); + /* Extrapolation of the last future part, windowing and high resolution DCT transform */ - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx, + st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); + } + ELSE +#endif + { + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); + } /* LD music post-filter */ LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ - Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS +#endif + { + Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ + } + Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx ); @@ -1138,6 +1251,7 @@ ivas_error acelp_core_dec_ivas_fx( i = 0; move16(); } + /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */ Word16 k = 0; move16(); @@ -1168,11 +1282,10 @@ ivas_error acelp_core_dec_ivas_fx( /*------------------------------------------------------------* * FEC - Estimate the classification information *------------------------------------------------------------*/ - FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, - psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, - NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, - st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, - 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode ); + + FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, + NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode ); + /*------------------------------------------------------------* * FEC - Estimate pitch *------------------------------------------------------------*/ @@ -1185,11 +1298,16 @@ ivas_error acelp_core_dec_ivas_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ - Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 + FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, +#ifdef REMOVE_EVS_DUPLICATES + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); +#else exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif + test(); test(); test(); @@ -1215,6 +1333,7 @@ ivas_error acelp_core_dec_ivas_fx( st->nelp_mode_dec = 1; move16(); } + test(); test(); /* long burst frame erasures */ @@ -1280,6 +1399,7 @@ ivas_error acelp_core_dec_ivas_fx( st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) ); move16(); } + /* Update circular buffer, keep last energy difference unchanged */ FOR( i = 1; i < MAX_LT; i++ ) { @@ -1302,6 +1422,7 @@ ivas_error acelp_core_dec_ivas_fx( Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx ); + test(); IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { @@ -1325,6 +1446,7 @@ ivas_error acelp_core_dec_ivas_fx( * FEC - Smooth the speech energy evolution when recovering after a BAD frame * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ + test(); IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { @@ -1332,7 +1454,11 @@ ivas_error acelp_core_dec_ivas_fx( FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, +#ifdef REMOVE_EVS_DUPLICATES + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); +#else exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ @@ -1362,10 +1488,12 @@ ivas_error acelp_core_dec_ivas_fx( /*--------------------------------------------------------* * Apply NB postfilter in case of 8kHz output *--------------------------------------------------------*/ + test(); IF( st->last_bwidth == NB && st->hPFstat != NULL ) { Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 + IF( st->bwidth == NB ) { st->hPFstat->on = 1; @@ -1413,9 +1541,7 @@ ivas_error acelp_core_dec_ivas_fx( { st->hPFstat->on = 1; move16(); - /*----ftf conversions---*/ Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); - set16_fx( st->hPFstat->mem_zero, 0, M ); formant_post_filt_ivas_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); @@ -1440,6 +1566,7 @@ ivas_error acelp_core_dec_ivas_fx( /*----------------------------------------------------------------* * Comfort noise addition *----------------------------------------------------------------*/ + test(); test(); IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -1480,13 +1607,12 @@ ivas_error acelp_core_dec_ivas_fx( st->lp_noise = st->hFdCngDec->lp_noise; move32(); } + test(); IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag ) { - /*Noise estimate*/ - /*==========================================================*/ + /* Noise estimate */ ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - /*==========================================================*/ } IF( !st->cna_dirac_flag ) @@ -1526,19 +1652,27 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { - IF( st->idchan == 0 ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - IF( NE_16( st->element_mode, last_element_mode ) ) + generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 ); + } + ELSE +#endif + { + IF( st->idchan == 0 ) { - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); + IF( NE_16( st->element_mode, last_element_mode ) ) + { + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); + } + Word32 psyn_32_fx[L_FRAME16k]; + Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 + Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 + generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); + Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn + Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } - Word32 psyn_32_fx[L_FRAME16k]; - Word16 exp; - Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 - Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 - generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn - Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } } } @@ -1596,10 +1730,26 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { - FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); - move16(); + // VE: TBV - is it correct in EVS? in FLP, it is: + // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); + // v_add( temp_buf, syn, syn, st->L_frame / 2 ); + FOR( i = 0; i < st->L_frame / 2; i++ ) + { + psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) ); + move16(); + } + } + ELSE +#endif + { + FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) + { + psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); + move16(); + } } } @@ -1625,36 +1775,27 @@ ivas_error acelp_core_dec_ivas_fx( * Bass post-filter *----------------------------------------------------------------*/ - /* check if the CLDFB works on the right sample rate */ - IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) { - resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + CLDFB_SCALE_FACTOR scaleFactor; + Word32 workBuffer[128 * 3]; - IF( st->ini_frame > 0 ) + /* check if the CLDFB works on the right sample rate */ + IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame ) { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); - } - } + /* resample to ACELP internal sampling rate */ + Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); + resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); - /* analyze pitch coherence for bass post-filter */ - - Word32 pitch_buf_fx_q20[12]; - - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) - Word16 lim = shr( st->L_frame, 6 ); - FOR( Word16 lp = 0; lp < lim; lp++ ) - { - pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); - move32(); - } - bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx + IF( st->ini_frame > 0 ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + } - test(); - IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) - { test(); IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) { @@ -1670,72 +1811,25 @@ ivas_error acelp_core_dec_ivas_fx( bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); - } - Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; - set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); - syn_32_fx = syn_tmp_32_fx + L_SUBFR; - test(); - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) - { /* analysis of the synthesis at internal sampling rate */ - Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - pRealSave_fx[i] = realBufferSave_fx[i]; - pImagSave_fx[i] = imagBufferSave_fx[i]; - } - IF( st->p_bpf_noise_buf_32 ) - { - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 - } + cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); - FOR( i = 0; i < st->L_frame; i++ ) - { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 - move32(); - } - - Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 - st->cldfbAna->Q_cldfb_state = Q12; - move16(); - cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 - st->cldfbAna->Q_cldfb_state = Q11; + scaleFactor.hb_scale = scaleFactor.lb_scale; move16(); - /* analysis and add the BPF error signal */ - Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; - Word16 q_bpf_error_signal; - Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); - q_bpf_error_signal = Q6; - move16(); - Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) - st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - move16(); - tmp = -1; + /* analysis and add the BPF error signal */ + i = 0; move16(); - if ( st->bpf_off ) + if ( st->bpf_off == 0 ) { - tmp = 0; + i = CLDFB_NO_COL_MAX; move16(); } - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 - st->cldfbBPF->Q_cldfb_state = Q10; - move16(); + addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ), + i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor ); + /* set output mask for upsampling */ IF( EQ_16( st->bwidth, NB ) ) { @@ -1749,142 +1843,387 @@ ivas_error acelp_core_dec_ivas_fx( st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); move16(); } + + /*WB/SWB-FD_CNG*/ + scaleFactor.hb_scale = scaleFactor.lb_scale; + move16(); + + test(); test(); - IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + test(); + IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) { - test(); - test(); - test(); - /*WB/SWB-FD_CNG*/ - IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) + generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st ); + + st->cldfbSyn->bandsToZero = 0; + move16(); + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) { - Word16 tmpBufferScale = 0; + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); move16(); - generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); + } + st->cldfbSyn->lsb = st->cldfbAna->no_channels; + move16(); + } - FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) - { - Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 - Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 - } + /* synthesis of the combined signal */ + st->Q_syn2 = st->Q_syn; + move16(); + cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); - IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) + /* Bring CLDFB output to Q0 */ + Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) ); + st->Q_syn2 = 0; + move16(); + + /* save synthesis - needed in case of core switching */ + Copy( synth_fx16, st->previoussynth_fx, output_frame ); + } + ELSE +#endif + { + /* check if the CLDFB works on the right sample rate */ + IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) + { + resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + + IF( st->ini_frame > 0 ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + } + + /* analyze pitch coherence for bass post-filter */ + + Word32 pitch_buf_fx_q20[12]; + + Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) + Word16 lim = shr( st->L_frame, 6 ); + FOR( Word16 lp = 0; lp < lim; lp++ ) + { + pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); + move32(); + } + bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); + Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx + + test(); + IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) + { + test(); + IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) + { + IF( EQ_16( st->L_frame, L_FRAME ) ) { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); - move16(); + retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); } - ELSE + ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - st->cldfbSyn->bandsToZero = 0; - move16(); + retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx ); } } + + bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, + st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); } - IF( save_hb_synth_fx16 != NULL ) + Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; + set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); + syn_32_fx = syn_tmp_32_fx + L_SUBFR; + test(); + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) { - /* save and then zero-out lowband */ - Word16 Q_real = 0, Q_imag = 0; - Word32 max_real = 0, max_imag = 0; + /* analysis of the synthesis at internal sampling rate */ + Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + pRealSave_fx[i] = realBufferSave_fx[i]; + pImagSave_fx[i] = imagBufferSave_fx[i]; + } + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + } + + FOR( i = 0; i < st->L_frame; i++ ) + { + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 + move32(); + } + + Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 + st->cldfbAna->Q_cldfb_state = Q12; move16(); + cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 + st->cldfbAna->Q_cldfb_state = Q11; move16(); - move32(); - move32(); + /* analysis and add the BPF error signal */ + Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; + Word16 q_bpf_error_signal; + Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + + q_bpf_error_signal = Q6; + move16(); + Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 } - Word32 max_val = L_max( max_real, max_imag ); - Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; - Q_real = Q_imag; + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) + st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; move16(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + tmp = -1; + move16(); + if ( st->bpf_off ) { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag ); // Q_imag + tmp = 0; + move16(); } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) -#endif /* OPT_STEREO_32KBPS_V1 */ - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 + st->cldfbBPF->Q_cldfb_state = Q10; move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + /* set output mask for upsampling */ + IF( EQ_16( st->bwidth, NB ) ) + { + /* set NB mask for upsampling */ + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); + move16(); + } + ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) + { + /* in case of BW switching, re-init to default */ + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + test(); + IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + test(); + test(); + test(); + /*WB/SWB-FD_CNG*/ + IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) + { + Word16 tmpBufferScale = 0; + move16(); + generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) + { + Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + } + + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); + move16(); + } + ELSE + { + st->cldfbSyn->bandsToZero = 0; + move16(); + } + } + } + + IF( save_hb_synth_fx16 != NULL ) { + /* save and then zero-out lowband */ + max_real = 0; + max_imag = 0; + move32(); + move32(); FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - realBufferSave_fx[i][j] = realBuffer_fx[i][j]; - imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; - move32(); - move32(); - IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) ) + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { - realBuffer_fx[i][j] = 0; - imagBuffer_fx[i][j] = 0; + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } + } + max_val = L_max( max_real, max_imag ); + Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + } +#ifndef OPT_AVOID_STATE_BUF_RESCALE +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) +#endif /* OPT_STEREO_32KBPS_V1 */ + st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + realBufferSave_fx[i][j] = realBuffer_fx[i][j]; + imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; move32(); move32(); + IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) ) + { + realBuffer_fx[i][j] = 0; + imagBuffer_fx[i][j] = 0; + move32(); + move32(); + } } } - } #ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); #else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); #endif /* OPT_AVOID_STATE_BUF_RESCALE */ #ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); + Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); #endif /* OPT_AVOID_STATE_BUF_RESCALE */ - /* restore lowband */ - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + /* restore lowband */ + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { - realBuffer_fx[i][j] = realBufferSave_fx[i][j]; - imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; - move32(); - move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + realBuffer_fx[i][j] = realBufferSave_fx[i][j]; + imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; + move32(); + move32(); + } } - } #ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 + st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + move16(); #endif /* OPT_AVOID_STATE_BUF_RESCALE */ #ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); + cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); #else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); - Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); + cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); + Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); #endif /* OPT_AVOID_STATE_BUF_RESCALE */ + } + ELSE + { + /* synthesis of the combined signal */ + max_real = 0; + max_imag = 0; + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } + } + max_val = L_max( max_real, max_imag ); + Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + } +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ + st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); + move16(); + +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSyn->Q_cldfb_state = Q10; + move16(); + } + + /* save synthesis - needed in case of core switching */ + Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 } ELSE { - /* synthesis of the combined signal */ - Word16 Q_real, Q_imag; - Word32 max_real, max_imag; - Q_real = 0; - Q_imag = 0; - max_real = 0; - max_imag = 0; + Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + + /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ + FOR( i = 0; i < st->L_frame; i++ ) + { + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); + move32(); + } + + Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 + st->cldfbAna->Q_cldfb_state = Q12; move16(); + cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); + + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 + st->cldfbAna->Q_cldfb_state = Q11; + move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ + Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; + Word16 q_bpf_error_signal; + Word16 cldfb_state_offset; + cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + + // Get Q-factor + q_bpf_error_signal = Q6; move16(); + Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + } + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) + st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; + move16(); + tmp = 0; + move16(); + if ( !st->bpf_off ) + { + tmp = nSamples; + move16(); + } + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + + + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 + st->cldfbBPF->Q_cldfb_state = Q10; + move16(); + /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ + max_real = 0; + max_imag = 0; move32(); move32(); FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) @@ -1895,158 +2234,59 @@ ivas_error acelp_core_dec_ivas_fx( max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); } } - Word32 max_val = L_max( max_real, max_imag ); - Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; - Q_real = Q_imag; - move16(); + max_val = L_max( max_real, max_imag ); + Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } +#ifndef OPT_AVOID_STATE_BUF_RESCALE #ifdef OPT_STEREO_32KBPS_V1 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) #else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) #endif /* OPT_STEREO_32KBPS_V1 */ - st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); - move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ #ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifndef OPT_AVOID_STATE_BUF_RESCALE + Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; move16(); - } +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - /* save synthesis - needed in case of core switching */ - Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 - } - ELSE - { - Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + } - /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ - FOR( i = 0; i < st->L_frame; i++ ) - { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); - move32(); + set32_fx( synth_fx, 0, output_frame ); } - Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 - st->cldfbAna->Q_cldfb_state = Q12; - move16(); - cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); - - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 - st->cldfbAna->Q_cldfb_state = Q11; - move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ - Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; - Word16 q_bpf_error_signal; - Word16 cldfb_state_offset; - cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); - - // Get Q-factor - q_bpf_error_signal = Q6; - move16(); - Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + /* Copy output signal */ + Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 + IF( st->element_mode > EVS_MONO ) { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) - st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - move16(); - tmp = 0; - move16(); - if ( !st->bpf_off ) - { - tmp = nSamples; - move16(); - } - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 - st->cldfbBPF->Q_cldfb_state = Q10; + st->Q_syn2 = 0; move16(); - /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ - Word16 Q_real, Q_imag; - Word32 max_real, max_imag; - Q_real = 0; - Q_imag = 0; - max_real = 0; - max_imag = 0; - move16(); - move16(); - move32(); - move32(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } - } - Word32 max_val = L_max( max_real, max_imag ); - Q_imag = sub( norm_l( max_val ), 3 ) /* Guard bits */; - Q_real = Q_imag; - move16(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSyn->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - IF( st->p_bpf_noise_buf_32 ) - { - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 - } - - set32_fx( synth_fx, 0, output_frame ); - } - - /* Copy output signal */ - Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 - IF( st->element_mode > EVS_MONO ) - { - Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ } - st->Q_syn2 = 0; - move16(); /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ + IF( st->hBWE_zero != NULL ) { test(); @@ -2059,14 +2299,28 @@ ivas_error acelp_core_dec_ivas_fx( IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { - Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 - hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); - Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); + } + ELSE +#endif + { + Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); + Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); + } } ELSE { hf_synth_reset_fx( st->hBWE_zero ); - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment +#endif + { + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); + } } } @@ -2094,6 +2348,7 @@ ivas_error acelp_core_dec_ivas_fx( move32(); set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); } + test(); test(); test(); @@ -2101,10 +2356,20 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) { - Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + } + ELSE +#endif + { + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + } } + test(); if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { @@ -2112,20 +2377,31 @@ ivas_error acelp_core_dec_ivas_fx( move32(); } } + /*----------------------------------------------------------------------* * Updates *----------------------------------------------------------------------*/ updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx ); + test(); test(); IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ - cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, - st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, - st->hFdCngDec->hFdCngCom->CngBandwidth ); - +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); + } + ELSE +#endif + { + cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, + st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, + st->hFdCngDec->hFdCngCom->CngBandwidth ); + } /* Set 16k LSP flag for CNG buffer */ st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; @@ -2137,6 +2413,9 @@ ivas_error acelp_core_dec_ivas_fx( } } +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_16( st->element_mode, EVS_MONO ) ) +#endif { IF( save_hb_synth_fx16 ) { @@ -2148,9 +2427,3 @@ ivas_error acelp_core_dec_ivas_fx( pop_wmops(); return error; } - - -static void rescale_fdCngDec( HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff ) -{ - Scale_sig32( hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, Exp_diff ); -} diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 7657491885adbc296ef9f41cfad150842b149f7e..6d3d0b381d267a6ab7cf897abbe95b921fb96043 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -128,7 +128,11 @@ ivas_error acelp_core_switch_dec_fx( * Excitation decoding *----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); +#else config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); +#endif decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc ); @@ -916,7 +920,11 @@ static void decod_gen_voic_core_switch_fx( * Decode pitch lag *----------------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/ +#else pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ +#endif /*--------------------------------------------------------------* * Find the adaptive codebook vector. diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index db4ad2bb021122533aba2ec98cb77b9455a90804..c1c1e61436e16b7b28b144a282dde7a61259fe19 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -373,7 +373,11 @@ ivas_error amr_wb_dec_fx( IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) { /* decode CNG parameters */ +#ifdef REMOVE_EVS_DUPLICATES + CNG_dec_ivas_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); +#else CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); +#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, @@ -626,9 +630,15 @@ ivas_error amr_wb_dec_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, + &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); +#else FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); +#endif frame_ener_fx( L_FRAME, st_fx->clas_dec, syn_fx, pitch_buf_tmp[3], &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); } @@ -707,10 +717,17 @@ ivas_error amr_wb_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, + MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, + st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, + st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 ); +#else FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, 0, 0 ); +#endif /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ frame_ener_fx( L_FRAME, st_fx->last_good, syn_fx, shr( FEC_pitch_fx, 6 ), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); @@ -768,7 +785,11 @@ ivas_error amr_wb_dec_fx( st_fx->hPFstat->on = 1; move16(); test(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 ); +#else formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 ); +#endif } /*----------------------------------------------------------------* @@ -795,8 +816,12 @@ ivas_error amr_wb_dec_fx( #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT PMT( "Fixed point not done here " ) ApplyFdCng_fx( syn, NULL, NULL, NULL, st, 0, 0 ); +#else +#ifdef REMOVE_EVS_DUPLICATES + ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 ); #else ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 ); +#endif #endif st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type; move16(); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 945f0ca758ed89671ff73a19fe0ba7ff25ab0357..ce6ad65683a6cbb3e6a2ab5844fcfb94678c0f20 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -25,6 +25,7 @@ static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, * Decode residual signal energy *-----------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 last_element_mode, /* i : last element mode Q0 */ @@ -695,7 +696,7 @@ void CNG_dec_fx( return; } - +#endif void CNG_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 last_element_mode, /* i : last element mode Q0 */ diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index d5294eb7a0a9eed009f3475c4f24be9270a76377..f53234deda56be19c4a99d212ca765afbd27981e 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -555,7 +555,12 @@ void decoder_LPD_fx( st->relax_prev_lsf_interp = 2; move16(); } + +#ifdef REMOVE_EVS_DUPLICATES + int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); +#else int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); +#endif } ELSE { diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index e327d4cfb958cacf783da1add249812e3336ceab..16f7491561541fdad810d6b6faa0fb735419a0c4 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -532,6 +532,10 @@ void decoder_acelp_fx( move16(); IF( st->igf != 0 ) { +#ifdef REMOVE_EVS_DUPLICATES + prep_tbe_exc_ivas_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, + gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 ); +#else prep_tbe_exc_fx( st->L_frame, #ifdef ADD_IVAS_TBE_CODE L_SUBFR, @@ -543,6 +547,7 @@ void decoder_acelp_fx( st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 #endif ); +#endif } /*---------------------------------------------------------* @@ -681,9 +686,15 @@ void decoder_acelp_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES + FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, + st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn ); +#else FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, force_scale_syn ); +#endif } /* update ACELP synthesis memory */ Copy( mem_syn, st->mem_syn2_fx, M ); diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index 415b4584e53c884068ce8f194e63305bc2ed8dd9..b03b6d69ce178133505548a585ae5cdb7f18cd9c 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -71,7 +71,11 @@ void decod_amr_wb_fx( * Decode pitch lag *----------------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); +#else *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); +#endif /*--------------------------------------------------------------* * Find the adaptive codebook vector diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 325beb9f3b347fc5183cd875e42b633dd0075449..7411d59f208638edf6ce07eaec052efb33052555 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -36,6 +36,7 @@ /* _ None */ /*======================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES ivas_error decod_gen_voic_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ @@ -503,7 +504,7 @@ ivas_error decod_gen_voic_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================*/ - +#endif ivas_error decod_gen_voic_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 L_frame, /* i : length of the frame */ @@ -699,7 +700,16 @@ ivas_error decod_gen_voic_ivas_fx( } /* update LP filtered gains for the case of frame erasures */ - 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 ); +#ifdef REMOVE_EVS_DUPLICATES + 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 ); + } + ELSE +#endif + { + 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 ); + } /*----------------------------------------------------------------------* * Find the total excitation @@ -809,8 +819,18 @@ ivas_error decod_gen_voic_ivas_fx( } ELSE { - enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } + ELSE +#endif + { + enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } } p_Aq_fx += ( M + 1 ); diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 746b668198d4c2d0a3ff030739b0d40d82b23952..fe7d2daafc2174eaadae31ab929f3b1e57b176fa 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -29,6 +29,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void dec_pit_exc_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ @@ -436,6 +438,7 @@ void dec_pit_exc_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ +#endif void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index a4f618a3fd751dec1eeea852d8e26230a86f39c8..281281ed6ae0cf151cb9e18a59eb45fcd86aff86 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -33,8 +33,9 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); +#ifndef REMOVE_EVS_DUPLICATES static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); - +#endif static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); @@ -255,6 +256,8 @@ static void Dec_postfilt_fx( * * Main routine to perform formant post filtering *--------------------------------------------------------------------------*/ + +#ifndef REMOVE_EVS_DUPLICATES void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -379,7 +382,7 @@ void formant_post_filt_fx( p_Aq += ( M + 1 ); } } - +#endif void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ @@ -519,6 +522,7 @@ void formant_post_filt_ivas_fx( * k1 = 1st parcor calculated on {hi} * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0 *----------------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ @@ -597,7 +601,7 @@ static void Dec_formant_postfilt_fx( return; } - +#endif static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index e886fd33770a60b034c992b92348e9fdc33bb9e6..c5b06724aff2a85b1596a4b8fd8b60c3086039db 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -253,9 +253,17 @@ void decod_tran_fx( { tmp_idx_2 = idiv1616( i_subfr, L_SUBFR ); } + +#ifdef REMOVE_EVS_DUPLICATES + prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, + st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); +#endif /*----------------------------------------------------------------* * Excitation enhancements (update of total excitation signal) diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 42f3250fb4595c517537e9e69c54924266a89711..fcc2600a3eefe302fc6cfb62c79dc5ca481d75eb 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -25,6 +25,7 @@ static void gain_dec_gacelp_uv_fx( * Decode unvoiced (UC) frames *-------------------------------------------------------------------*/ +#ifndef REMOVE_EVS_DUPLICATES void decod_unvoiced_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ @@ -112,7 +113,7 @@ void decod_unvoiced_fx( * * Decode unvoiced (UC) frames *-------------------------------------------------------------------*/ - +#endif void decod_unvoiced_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ @@ -207,7 +208,16 @@ void decod_unvoiced_ivas_fx( move16(); /* update LP filtered gains for the case of frame erasures */ - 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 ); +#ifdef REMOVE_EVS_DUPLICATES + 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 ); + } + ELSE +#endif + { + 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 ); + } /*-------------------------------------------------------* * - Find the total excitation. * @@ -247,10 +257,18 @@ void decod_unvoiced_ivas_fx( * Excitation enhancements (update of total excitation signal) *----------------------------------------------------------------*/ - /*enhancer_fx(st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &(st_fx->dm_fx), st_fx->Q_exc);*/ - enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } + ELSE +#endif + { + enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, + norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); + } Word16 tmp_idx; tmp_idx = 0; @@ -258,9 +276,16 @@ void decod_unvoiced_ivas_fx( IF( i_subfr_fx != 0 ) { tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); + } +#endif } voice_factors_fx[tmp_idx] = 0; move16(); + interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR ); p_Aq_fx += ( M + 1 ); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 74340b530f6fe9cc1c2733664b854cc317f057cf..090409b4ce1d02f39a17eeeb03adf95d331b96c8 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -332,7 +332,11 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ +#ifdef REMOVE_EVS_DUPLICATES + IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) +#else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -955,8 +959,12 @@ ivas_error evs_dec_fx( move32(); #ifdef IVAS_CODE_CNG_FIX185_PLC_FADEOUT ApplyFdCng_fx( output, NULL, realBuffer, imagBuffer, st, concealWholeFrame, 0 ); +#else +#ifdef REMOVE_EVS_DUPLICATES + ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); #else ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); +#endif #endif /* Generate additional comfort noise to mask potential coding artefacts */ test(); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 55c491efe96a59e8777a0be986110bd16d2b9b18..d0fd178f25285c995245065cf5ff362ee43912a3 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -554,6 +554,8 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) Returns: error */ + +#ifndef REMOVE_EVS_DUPLICATES Word16 ApplyFdCng_fx( Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ Word16 Q, @@ -1029,7 +1031,6 @@ Word16 ApplyFdCng_fx( { scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); - *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } @@ -1117,7 +1118,7 @@ Word16 ApplyFdCng_fx( return 0; } - +#endif Word16 ApplyFdCng_ivas_fx( Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ Word16 Q, @@ -1220,10 +1221,26 @@ Word16 ApplyFdCng_ivas_fx( ( !st->BER_detect ) ) { /* Perform noise estimation at the decoder */ - perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); + } + ELSE +#endif + { + perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); + } /* Update the shaping parameters */ test(); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); + } + ELSE +#endif IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); @@ -1460,7 +1477,16 @@ Word16 ApplyFdCng_ivas_fx( IF( hFdCngCom->active_frame_counter > 0 ) { /* Perform noise estimation in active frames in the decoder for downward updates */ - perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); + } + ELSE +#endif + { + perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); + } } } @@ -1518,11 +1544,27 @@ Word16 ApplyFdCng_ivas_fx( IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) ) { /* Perform noise estimation on inactive phase at the decoder */ - perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); + } + ELSE +#endif + { + perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); + } /* Update the shaping parameters */ test(); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); + } + ELSE +#endif IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); @@ -1532,15 +1574,25 @@ Word16 ApplyFdCng_ivas_fx( /* This sets the new CNG levels until a SID update overwrites it */ Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ /*Q31 - hFdCngDec->bandNoiseShape_exp*/ - Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); - Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) ); - Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; + move16(); + } + ELSE +#endif + { + Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); + Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) ); + Word16 shift = s_max( sub( hFdCngDec->bandNoiseShape_exp, shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); - scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( hFdCngDec->bandNoiseShape_exp, shift ) ); - scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( *cngNoiseLevel_exp, shift ) ); + scale_sig32( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( hFdCngDec->bandNoiseShape_exp, shift ) ); + scale_sig32( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ), sub( *cngNoiseLevel_exp, shift ) ); - *cngNoiseLevel_exp = shift; - move16(); + *cngNoiseLevel_exp = shift; + move16(); + } /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/ tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); @@ -1610,8 +1662,16 @@ Word16 ApplyFdCng_ivas_fx( IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ - scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); + } + ELSE +#endif + { + scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); + } *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } @@ -1624,8 +1684,16 @@ Word16 ApplyFdCng_ivas_fx( /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { - scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); + } + ELSE +#endif + { + scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); + } *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); @@ -1689,15 +1757,35 @@ Word16 ApplyFdCng_ivas_fx( } } - Word16 shift1 = L_norm_arr( cngNoiseLevel, j ); - Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) ); - Word16 shift = s_max( sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + /* adapt scaling for rest of the buffer */ + s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); + FOR( ; k < hFdCngCom->npart; k++ ) + { + FOR( ; j <= hFdCngCom->part[k]; j++ ) + { + cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ + move32(); + } + } + *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 ); + move16(); + } + ELSE +#endif + { + Word16 shift1 = L_norm_arr( cngNoiseLevel, j ); + Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) ); + Word16 shift = s_max( sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift1 ), sub( *cngNoiseLevel_exp, shift2 ) ); - scale_sig32( cngNoiseLevel, j, sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift ) ); - scale_sig32( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ), sub( *cngNoiseLevel_exp, shift ) ); + scale_sig32( cngNoiseLevel, j, sub( add( hFdCngDec->bandNoiseShape_exp, s2 ), shift ) ); + scale_sig32( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ), sub( *cngNoiseLevel_exp, shift ) ); - *cngNoiseLevel_exp = shift; - move16(); + *cngNoiseLevel_exp = shift; + move16(); + } } } ELSE IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) @@ -1775,7 +1863,16 @@ Word16 ApplyFdCng_ivas_fx( IF( EQ_16( st->codec_mode, MODE2 ) ) { /* Generate comfort noise during SID or zero frames */ - generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); + } + ELSE +#endif + { + generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); + } } BREAK; diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 5e17122311bc97e7495aa9840fa7036d069b3c24..00eca187d71f2ca2891b1ee44c4af13bf099355c 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -601,6 +601,8 @@ void gain_dec_mless_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*==================================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void gain_dec_lbr_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -969,7 +971,7 @@ void gain_dec_lbr_fx( return; } - +#endif void gain_dec_lbr_ivas_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 8f29eb9d13ce53f72ad042cec7c6fe757ca09f7d..cf0fabc7647160864d050f62946949c15a7cd602 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -30,6 +30,8 @@ /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ @@ -92,7 +94,11 @@ void decod_audio_fx( } /* set bit-allocation */ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#else config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif /*---------------------------------------------------------------* * Decode energy dynamics @@ -445,6 +451,7 @@ void decod_audio_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*==========================================================================*/ +#endif void decod_audio_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ @@ -884,9 +891,11 @@ void decod_audio_ivas_fx( } } + Word16 Q_exc_old = st_fx->Q_exc; move16(); gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); + IF( NE_16( Q_exc_old, st_fx->Q_exc ) ) { Q_exc_old = sub( Q_exc_old, st_fx->Q_exc ); @@ -966,6 +975,8 @@ void decod_audio_ivas_fx( /* RETURN ARGUMENTS : */ /* _None */ /*==========================================================================*/ + +#ifndef REMOVE_EVS_DUPLICATES 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*/ @@ -1197,6 +1208,7 @@ void gsc_dec_fx( /* RETURN ARGUMENTS : */ /* _None */ /*==========================================================================*/ +#endif void gsc_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ @@ -1297,7 +1309,17 @@ void gsc_dec_ivas_fx( { i--; } - mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ + +#ifdef REMOVE_EVS_DUPLICATES + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ + } + ELSE +#endif + { + mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ + } st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index b588fdce1bd047a957cc644092befc7ee5368519..11c108380ec274e2d901fddf50bf2890f9a5fef8 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -448,7 +448,6 @@ ivas_error init_decoder_fx( } /* TCX core */ - // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { IF( ( st_fx->hTcxDec = (TCX_DEC_HANDLE) malloc( sizeof( TCX_DEC_DATA ) ) ) == NULL ) diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 21e8705f3aa64d7b7efcb4a8b7b929fbfe49a626..9b7f77c79845d42f4fcd81d0220c0cebeb68854a 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -99,6 +99,7 @@ static void dqlsf_CNG_fx( /* _ None */ /*===========================================================================*/ +#ifndef REMOVE_EVS_DUPLICATES void lsf_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 tc_subfr, /* i : TC subframe index Q0*/ @@ -351,7 +352,7 @@ void lsf_dec_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*===========================================================================*/ - +#endif void lsf_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ const Word16 tc_subfr, /* i : TC subframe index Q0*/ diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index 1d3e9649793cb0578063ec2b5235a452812ffe1d..e8cebedbdd98861e9398f70087cbbd5f11f8214d 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -319,7 +319,7 @@ void Mode2_delta_pit_dec( /* _ (Word16 ) pitch : close loop integer pitch Q6 */ /*=======================================================================*/ - +#ifndef REMOVE_EVS_DUPLICATES Word16 pit_decode_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -543,7 +543,7 @@ Word16 pit_decode_fx( /* o : floating pitch value /* _ (Word16 ) pitch : close loop integer pitch Q6 */ /*=======================================================================*/ - +#endif Word16 pit_decode_ivas_fx( /* o : floating pitch value */ Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index d581f810a7dd724424e19f9651b0a5c4a11e930c..b5d56d8fb9359db6b4daf5012bd70cc2349ac2bf 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -139,13 +139,21 @@ void post_decoder( { st->hPFstat->on = 1; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#endif } ELSE { st->hPFstat->on = 0; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#endif } } @@ -302,13 +310,21 @@ void post_decoder_ivas_fx( { st->hPFstat->on = 1; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); +#endif } ELSE { st->hPFstat->on = 0; move16(); +#ifdef REMOVE_EVS_DUPLICATES + formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); +#endif } } diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 795f03403e1355a49da0ffba61995e412aa6ad98..4c3f7152cbde53f21bea6b4713f6a276a04b3236 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -394,10 +394,14 @@ ivas_error acelp_core_enc_fx( test(); IF( !nelp_mode && !ppp_mode ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, - st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, - tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, - tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif + st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, + tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, + tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } /*-----------------------------------------------------------------* @@ -460,9 +464,13 @@ ivas_error acelp_core_enc_fx( { tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx ); +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, - -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, - tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif + -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, + tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } /*---------------------------------------------------------------* @@ -513,9 +521,13 @@ ivas_error acelp_core_enc_fx( lsp_mid_bck_fx, mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen_fx ); /* Configure ACELP bit allocation */ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, - -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, - st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); +#endif + -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, + st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8226748f745c1e5aa4ad7ce41b2a5e027a55b106..854f0ff678858fa13aa087920b43aa5b48ada1ba 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -151,8 +151,12 @@ void acelp_core_switch_enc_fx( * Excitation encoding *----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, +#else config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, - GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); +#endif + GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index c2f9d0585d356c513226ee2059d219e835976724..78a02eeecf117fbc823f78c8b250a13ccd8b3b14 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -24,19 +24,22 @@ * - update LSPs for the next frame *-------------------------------------------------------------------*/ void analy_lp_ivas_fx( - const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ - const Word16 L_frame, /* i :(q0) length of the frame */ - const Word16 L_look, /* i :(q0) look-ahead */ - Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ - Word16 A[], /* o :(q14) A(z) filter coefficients */ - Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 lsp_new[], /* o :(q15) current frame LSPs */ - Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ - Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ - const Word16 Top[2], /* i :(q0) open loop pitch lag */ - const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ - const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ +#ifdef REMOVE_EVS_DUPLICATES + const Word16 element_mode, /* i : element mode */ +#endif const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ Word16 Q_new, /*i: stores Q for speech*/ Word16 *Q_r /*stores q for ener*/ ) @@ -74,19 +77,24 @@ void analy_lp_ivas_fx( /* Autocorrelations */ autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 ); - /*if ( r[0] < 100.0f && no_thr == 0 )*/ - /*r[0] = 100.0f*/ - IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) ) +#ifdef REMOVE_EVS_DUPLICATES + IF( NE_16( element_mode, EVS_MONO ) ) +#endif { - /*Q_min stores min of 24 and the actual Q for r*/ - Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/ - L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/ - FOR( i = 1; i < 17; i++ ) + /*if ( r[0] < 100.0f && no_thr == 0 )*/ + /*r[0] = 100.0f*/ + IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( L_Comp( r_h[0], r_l[0] ) /* Q_r[1 - i_subfr]*/, sub( 31, add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ) ), 100 /*q0*/, 31 ), -1 ) ) { - L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/ + /*Q_min stores min of 24 and the actual Q for r*/ + Word16 Q_min = s_min( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), 24 ); /* comparing q with 24 because exponent of 100 is 7 so max q should be 24*/ + L_Extract( L_shl( 100, Q_min ), &r_h[0], &r_l[0] ); /*extracting high and low components of r[0]*/ + FOR( i = 1; i < 17; i++ ) + { + L_Extract( L_shr( L_Comp( r_h[i], r_l[i] ), sub( add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ), Q_min ) ), &r_h[i], &r_l[i] ); /*scaling all the values to q24*/ + } + Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/ + move16(); } - Q_r[1 - i_subfr] = sub( Q_min, shl( Q_new, 1 ) ); /*updating the q (subtracting shl( Q_new, 1 ) as in later part it is being added-> to maintain q24 )*/ - move16(); } /* Lag windowing */ @@ -124,6 +132,7 @@ void analy_lp_ivas_fx( return; } +#ifndef REMOVE_EVS_DUPLICATES void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame Q_new*/ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -195,12 +204,20 @@ void analy_lp_fx( IF( EQ_16( sec_chan_low_rate, 1 ) ) { /* LSP interpolation */ +#ifdef REMOVE_EVS_DUPLICATES + int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); +#else int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); +#endif } ELSE { /* LSP interpolation */ +#ifdef REMOVE_EVS_DUPLICATES + int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); +#else int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); +#endif } Copy( lsp_new, lsp_old, M ); /* Q15 */ *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */ @@ -208,7 +225,7 @@ void analy_lp_fx( return; } - +#endif /*-------------------------------------------------------------------* * analy_lp_AMR_WB() diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index d3725dcba73c1b1a10380ea33ca42f9abc403a74..b5c18d44b7cbbba2fbaeb1cb78cdee15c7d0ac39 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -366,8 +366,14 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { +#ifdef REMOVE_EVS_DUPLICATES + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate, + st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate ); +#endif } /*---------------------------------------------------------* diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index e694b60c23b57ff6780c49020375890592655164..a60828a949891a4767b02d2859bb7a11373e08b5 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -367,9 +367,16 @@ void encod_gen_voic_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, + T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); +#endif /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 8e4f13116e030f44bea24b521666c95538462796..394b22c3099bdde32fdaadc97f5e26bfa97f35fa 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -308,8 +308,13 @@ Word16 encod_tran_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ +#ifdef REMOVE_EVS_DUPLICATES + prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); +#else prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); +#endif /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 60e6019aa7cc5ca22c20f3567bcf051342851a11..e200d0f00834bdf4510275df56155aaeb6ba3cf1 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -749,7 +749,6 @@ ivas_error init_encoder_fx( * TCX core *-----------------------------------------------------------------*/ - // VE: reduction possible for MCT_CHAN_MODE_LFE channel - see I1-172 test(); IF( idchan == 0 || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) { diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index bac22a5b75a43268369388b453ed7adf4ef76602..67c4f256f76d7c55ed7d32debc921fb60d159495 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1150,8 +1150,12 @@ ivas_error pre_proc_front_ivas_fx( move16(); } +#ifdef REMOVE_EVS_DUPLICATES + analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r ); +#else analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, i, *Q_new, Q_r ); +#endif FOR( Word16 idx = 0; idx < M + 1; idx++ ) { diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index b2ec139831a8911c4f711699c01bcba5ce664b29..6fe6b6720d17c1fd68c743c3fecdf2d309c8bc0f 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1134,11 +1134,20 @@ ivas_error ivas_compute_core_buffers_fx( IF( Q_new ) { +#ifdef REMOVE_EVS_DUPLICATES + analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r ); +#else analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, sub( *Q_new, 1 ), Q_r ); +#endif } ELSE { +#ifdef REMOVE_EVS_DUPLICATES + analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); + +#else analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, -1, Q_r ); +#endif } /*--------------------------------------------------------------* diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index b21a669528e03c94edff804b63e61db3c529f835..f3cf05e6368c20355fff4b0b2cd27f5fbe27d3fc 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -637,7 +637,12 @@ ivas_error front_vad_spar_fx( hFrontVad->q_buffer_12k8 = Q_inp_12k8; move16(); +#ifdef REMOVE_EVS_DUPLICATES + analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r ); +#else analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r ); +#endif + FOR( Word16 i = 0; i <= M; i++ ) { epsP_fx[i] = L_Comp( epsP_h[i], epsP_l[i] ); // Q_r[0] diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index cbb2cf421564b73d0e51c62baef7b4988667fe3e..e8d4a072251e13f9a3cc95c6c33dc51dda43d0cf 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -414,7 +414,11 @@ void pre_proc_fx( alw_voicing[1] = st->voicing_fx[2]; move16(); +#ifdef REMOVE_EVS_DUPLICATES + analy_lp_ivas_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r ); +#else analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); +#endif lsp2lsf_fx( lsp_new, lsf_new, M, INT_FS_12k8 ); stab_fac = lsf_stab_fx( lsf_new, st->lsf_old1_fx, 0, L_FRAME ); @@ -1127,7 +1131,11 @@ void pre_proc_fx( Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); } +#ifdef REMOVE_EVS_DUPLICATES + analy_lp_ivas_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r ); +#else analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); +#endif /*--------------------------------------------------------------* * Compute Weighted Input diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c83f30ba7895f1f9f25781b4525d954f9e37efee..d9389eb9c6a476898a4b238cfbc84aa70c4f673a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -69,23 +69,27 @@ ivas_error acelp_core_enc_fx( ); void analy_lp_ivas_fx( - const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ - const Word16 L_frame, /* i :(q0) length of the frame */ - const Word16 L_look, /* i :(q0) look-ahead */ - Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ - Word16 A[], /* o :(q14) A(z) filter coefficients */ - Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 lsp_new[], /* o :(q15) current frame LSPs */ - Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ - Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ - const Word16 Top[2], /* i :(q0) open loop pitch lag */ - const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ - const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ +#ifdef REMOVE_EVS_DUPLICATES + const Word16 element_mode, /* i : element mode */ +#endif const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ Word16 Q_new, /*i: stores Q for speech*/ Word16 *Q_r /*stores q for ener*/ ); +#ifndef REMOVE_EVS_DUPLICATES void analy_lp_fx( const Word16 speech[], /* i : pointer to the speech frame Q_new*/ const Word16 L_frame, /* i : length of the frame Q0*/ @@ -103,6 +107,7 @@ void analy_lp_fx( const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/ Word16 Q_new, Word16 *Q_r ); +#endif void AVQ_cod_fx( /* o: comfort noise gain factor */ const Word16 xri[], /* i: vector to quantize */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 9f630da6613efe31400cd71440e9f12823a9f672..5e50cac15b457c299b6af0828b4ac56c07497197 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -212,11 +212,15 @@ void transition_enc_fx( IF( EQ_16( *tc_subfr, TC_0_0 ) ) { /* this is called only to compute unused bits */ +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, - L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, - st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ - ); +#endif + L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } + *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); move16(); updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR ); @@ -324,10 +328,15 @@ void transition_enc_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, - st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, - unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif + st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } + /*-----------------------------------------------------------------* * get number of bits for pitch encoding *-----------------------------------------------------------------*/ @@ -1033,11 +1042,17 @@ void transition_enc_ivas_fx( IF( EQ_16( *tc_subfr, TC_0_0 ) ) { /* this is called only to compute unused bits */ + +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, - L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, - st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ +#endif + L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } + *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); move16(); updt_tar_fx( xn_fx, xn2_fx, y1_fx, *gain_pit_fx, L_SUBFR ); @@ -1145,10 +1160,15 @@ void transition_enc_ivas_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { +#ifdef REMOVE_EVS_DUPLICATES + config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, +#else config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, - st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, - unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); +#endif + st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } + /*-----------------------------------------------------------------* * get number of bits for pitch encoding *-----------------------------------------------------------------*/