From 647937cb88fbe9d01c75de7d2c839565605c22e5 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 16 Dec 2025 14:49:05 -0500 Subject: [PATCH 01/26] Removal of unnecessary scaling --- lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 ++++ lib_dec/acelp_core_dec_fx.c | 19 ++++++++++++++++++- lib_dec/ivas_core_dec_fx.c | 13 ++++++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 640bd4a74..f6f59e9e8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,7 +100,7 @@ #define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ #define FIX_2287_MCT_MDCT_STEREO_DATA_MALLOC_SIZE /* FhG: correct allocation size for STEREO_MDCT_DEC_DATA struct */ - +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bba113ec0..29fce3f6e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10321,7 +10321,11 @@ ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs */ Word16 synth_fx16[], /* o : synthesis */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else Word16 save_hb_synth_fx16[], /* o : HB synthesis */ +#endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ Word16 *voice_factors_fx, /* o : voicing factors */ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index e163662c8..f3b421367 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -55,7 +55,11 @@ ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ Word16 synth_fx16[], /* o : synthesis Q_syn2*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ +#endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/ @@ -74,7 +78,11 @@ ivas_error acelp_core_dec_fx( const Word16 read_sid_info /* i : read SID info flag */ ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 synth_fx[960]; +#else Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; +#endif 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. */ @@ -2008,7 +2016,11 @@ ivas_error acelp_core_dec_fx( } } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + IF( save_hb_synth_fx32 != NULL ) +#else IF( save_hb_synth_fx16 != NULL ) +#endif { /* save and then zero-out lowband */ max_real = 0; @@ -2049,8 +2061,11 @@ ivas_error acelp_core_dec_fx( } } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx32, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); +#else cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); - +#endif /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2333,6 +2348,7 @@ ivas_error acelp_core_dec_fx( IF( NE_16( st->element_mode, EVS_MONO ) ) { +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING #ifdef FIX_2252_SCALING_SAVE_HB_SYNTH IF( save_hb_synth_fx16 != NULL ) #else @@ -2345,6 +2361,7 @@ ivas_error acelp_core_dec_fx( Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0 #endif } +#endif Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 690797e20..3377d8321 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -479,6 +479,7 @@ ivas_error ivas_core_dec_fx( { /* ACELP core decoder */ Word16 old_syn_12k8_16k_fx_16[L_FRAME16k]; +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 save_hb_synth_fx_arr[L_FRAME48k], *save_hb_synth_16_fx; IF( save_hb_synth_32_fx ) @@ -489,7 +490,7 @@ ivas_error ivas_core_dec_fx( { save_hb_synth_16_fx = NULL; } - +#endif IF( st->cldfbAna ) { scale_sig32( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, Q11 - Q10 ); // Q11 @@ -529,7 +530,11 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = 0; move16(); +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -555,14 +560,16 @@ ivas_error ivas_core_dec_fx( move16(); } move16(); - IF( save_hb_synth_32_fx ) { +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_16_32_DEPREC( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); // Q11 +#else + Scale_sig32( save_hb_synth_32_fx, output_frame, Q11 ); // Q0 -> Q11 +#endif hSCE->q_save_hb_synth_fx = Q11; move16(); } - Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n], L_FRAME16k, Q11 - ( -Q1 ) ); // Q(11 - (-1)) } -- GitLab From d36fbf2011e4546fc6cd4925156d31359a764d98 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 16:15:48 +0100 Subject: [PATCH 02/26] updt --- lib_com/ivas_prot_fx.h | 8 +++++++ lib_com/prot_fx.h | 14 ++++++++----- lib_dec/acelp_core_dec_fx.c | 22 +++++++++++++++----- lib_dec/hq_core_dec_fx.c | 38 ++++++++++++++++++++++++++++++++-- lib_dec/ivas_core_dec_fx.c | 16 ++++++++++++-- lib_dec/ivas_tcx_core_dec_fx.c | 20 +++++++++++++++--- 6 files changed, 101 insertions(+), 17 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 31dfb1ea2..9f2eb0d4a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1588,8 +1588,12 @@ void ivas_hq_core_dec_fx( const Word16 output_frame, /* i : output frame length */ const Word16 hq_core_type, /* i : HQ core type */ const Word16 core_switching_flag, /* i : ACELP->HQ switching frame flag */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_32_fx /* o : synthesis @internal_Fs, Q11 */ +#else Word16 output[], Word16 *Q_output +#endif ); void ivas_HQ_FEC_Mem_update_fx( @@ -2068,7 +2072,11 @@ void ivas_buffer_deinterleaved_to_interleaved_fx( void stereo_tcx_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ const FRAME_MODE frameMode, /* i : Decoder frame mode */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *signal_out_32_fx, /* o : synthesis @internal_Fs, Q11 */ +#else Word16 *signal_out, /* o : synthesis @internal_Fs, Q0 */ +#endif Word16 *signal_outFB, /* o : synthesis @output_Fs, Q0 */ Word16 pitch_buf[], /* o : floating pitch for each subframe, Q6 */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9e56f4868..66349adcc 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10199,13 +10199,17 @@ Word16 swb_bwe_dec_fx32( ); ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs */ - Word16 synth_fx16[], /* o : synthesis */ + Decoder_State *st, /* i/o: decoder state structure */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ #else - Word16 save_hb_synth_fx16[], /* o : HB synthesis */ + Word16 output_fx[], /* o : synthesis @internal Fs */ +#endif + Word16 synth_fx16[], /* o : synthesis */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else + Word16 save_hb_synth_fx16[], /* o : HB synthesis */ #endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */ Word16 *voice_factors_fx, /* o : voicing factors */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 7d6ac254d..366480956 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -52,13 +52,17 @@ *-------------------------------------------------------------------*/ ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ - Word16 synth_fx16[], /* o : synthesis Q_syn2*/ + Decoder_State *st, /* i/o: decoder state structure */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ #else - Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ + Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ +#endif + Word16 synth_fx16[], /* o : synthesis Q_syn2*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 save_hb_synth_fx32[], /* o : HB synthesis Q0*/ +#else + Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ #endif Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/ Word16 *voice_factors_fx, /* o : voicing factors Q15*/ @@ -214,7 +218,11 @@ ivas_error acelp_core_dec_fx( Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/ } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + set32_fx( output_fx32, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ +#else set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ +#endif set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ /* CN generation done in DFT domain */ @@ -2209,7 +2217,11 @@ ivas_error acelp_core_dec_fx( Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 IF( st->element_mode > EVS_MONO ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig_16_32_no_sat( psyn_fx, output_fx32, L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 +#else Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ +#endif } st->Q_syn2 = 0; diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index e34527da0..f9dac288e 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -468,8 +468,13 @@ void ivas_hq_core_dec_fx( const Word16 output_frame, /* i : output frame length Q0*/ const Word16 hq_core_type, /* i : HQ core type Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching frame flag Q0*/ - Word16 output[], /* Q_ouput */ - Word16 *Q_output ) +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_32_fx /* o : synthesis @internal_Fs, Q11 */ +#else + Word16 output[], /* Q_ouput */ + Word16 *Q_output +#endif +) { Word16 num_bits, is_transient, hqswb_clas, inner_frame; Word16 i, j, flag_uv, num_Sb, nb_sfm; @@ -504,7 +509,19 @@ void ivas_hq_core_dec_fx( Word16 mdctWindowLength; Word16 mdctWindowLengthFB; Word16 tmp_e; +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 tmp_out[L_FRAME48k]; +#else + Word16 output[L_FRAME48k]; + Word16 Q_output; + + Q_output = 0; + move16(); + *Q_synth = 0; + move16(); + st_fx->Q_syn_factor = 0; + move16(); +#endif /*-------------------------------------------------------------------------- * Initializations @@ -886,7 +903,11 @@ void ivas_hq_core_dec_fx( move16(); Inverse_Transform( t_audio_q, &Q_audio, wtda_audio_LB, is_transient, st_fx->L_frame, inner_frame, st_fx->element_mode ); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Q_output = Q_audio; +#else *Q_output = Q_audio; +#endif move16(); } @@ -912,7 +933,11 @@ void ivas_hq_core_dec_fx( IF( st_fx->element_mode > EVS_MONO ) { /* LB synthesis for potential switch to ACELP */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + window_ola_fx( wtda_audio_LB, output, &Q_output, hHQ_core->old_out_LB_fx, &hHQ_core->Q_old_wtda_LB, L_FRAME16k, st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx ); +#else window_ola_fx( wtda_audio_LB, output, Q_output, hHQ_core->old_out_LB_fx, &hHQ_core->Q_old_wtda_LB, L_FRAME16k, st_fx->hTcxCfg->tcx_last_overlap_mode, st_fx->hTcxCfg->tcx_curr_overlap_mode, st_fx->prev_bfi && !hHQ_core->ph_ecu_active, hHQ_core->oldHqVoicing, hHQ_core->oldgapsynth_fx ); +#endif } test(); test(); @@ -974,12 +999,21 @@ void ivas_hq_core_dec_fx( Copy( &st_fx->mem_pitch_gain[2], &st_fx->mem_pitch_gain[nbsubfr + 2], nbsubfr ); /* Q14 */ set16_fx( &st_fx->mem_pitch_gain[2], 0, nbsubfr ); } + /* Move LB excitation to old_exc memory in case of switch HQ->ACELP */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig( output, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame, negate( Q_output ) ); /* Q0 */ + + Copy_Scale_sig_16_32_DEPREC( output, output_32_fx, L_FRAME48k, sub( Q11, Q_output ) ); // Q11 + st_fx->Q_syn_factor = s_min( 0, s_min( *Q_synth, Q_output ) ); +#else IF( st_fx->element_mode > EVS_MONO ) { Copy_Scale_sig( output, tmp_out, st_fx->L_frame, negate( *Q_output ) ); /* Q0 */ Copy( tmp_out, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame ); /* Q0 */ } +#endif + return; } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index b1cb8a071..37d9520cd 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -524,7 +524,7 @@ ivas_error ivas_core_dec_fx( move16(); #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = acelp_core_dec_fx( st, output_32_fx[n], synth_16_fx[n], save_hb_synth_32_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx[n], sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) #endif @@ -532,8 +532,10 @@ ivas_error ivas_core_dec_fx( return error; } +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 Scale_sig( output_16_fx[n], L_FRAME48k, negate( st->Q_syn2 ) ); // Q0 +#endif IF( st->cldfbAna ) { scale_sig32( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_size, Q10 - Q11 ); /* 9 * (Word16)(st->L_frame * FRAMES_PER_SEC * INV_CLDFB_BANDWIDTH + 0.5f) , Q10 */ @@ -603,9 +605,13 @@ ivas_error ivas_core_dec_fx( move32(); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + stereo_tcx_core_dec_fx( st, frameMode[n], output_32_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); +#else stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, sub( Q11, st->Q_syn_factor ) ); // Q11 +#endif IF( st->hTcxDec ) { @@ -623,6 +629,11 @@ ivas_error ivas_core_dec_fx( IF( EQ_16( st->core, HQ_CORE ) ) { /* HQ core decoder */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_32_fx[n] ); + + Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor +#else Word16 Q_output; Q_output = 0; @@ -638,6 +649,7 @@ ivas_error ivas_core_dec_fx( st->Q_syn_factor = s_min( 0, s_min( Q_synth, Q_output ) ); Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor Scale_sig( output_16_fx[n], L_FRAME48k, sub( st->Q_syn_factor, Q_output ) ); // st->Q_syn_factor +#endif } /*---------------------------------------------------------------------* @@ -1153,7 +1165,7 @@ ivas_error ivas_core_dec_fx( #ifdef HARM_NON_LINEARITY Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 45588e7cc..3c917978c 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -188,9 +188,13 @@ void stereo_tcx_init_dec_fx( *-------------------------------------------------------------------*/ void stereo_tcx_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const FRAME_MODE frameMode, /* i : Decoder frame mode */ - Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const FRAME_MODE frameMode, /* i : Decoder frame mode */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *signal_out_32_fx, /* o : synthesis @internal_Fs, Q11*/ +#else + Word16 *signal_out_fx, /* o : synthesis @internal_Fs, Q0*/ +#endif Word16 *signal_outFB_fx, /* o : synthesis @output_Fs, Q0*/ Word16 pitch_buf_fx[], /* o : Word16 pitch for each subframe, Q6*/ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC Q0*/ @@ -232,6 +236,9 @@ void stereo_tcx_core_dec_fx( Word32 psd_fx[L_FRAME16k]; Word32 psd_part_fx[NPART_SHAPING]; Word16 psd_part_e; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 signal_out_fx[L_FRAME48k]; +#endif TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; @@ -877,7 +884,9 @@ void stereo_tcx_core_dec_fx( } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word32 signal_out_32_fx[L_FRAME48k]; +#endif Word16 exp; Copy_Scale_sig_16_32_no_sat( signal_out_fx, signal_out_32_fx, st->hFdCngDec->hFdCngCom->frameSize, Q6 ); generate_masking_noise_ivas_fx( signal_out_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); @@ -893,6 +902,11 @@ void stereo_tcx_core_dec_fx( } } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 output_frame = extract_l( Mpy_32_16_1( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + Copy_Scale_sig_16_32_DEPREC( signal_out_fx, signal_out_32_fx, output_frame, sub( Q11, st->Q_syn_factor ) ); +#endif + pop_wmops(); return; } -- GitLab From 2f5af4899fa03e66ac47fdf1c50959d6d70bd4d8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 16:33:24 +0100 Subject: [PATCH 03/26] remove buffer output_16_fx[][] --- lib_com/ivas_prot_fx.h | 4 ++++ lib_com/options.h | 1 + lib_dec/ivas_core_dec_fx.c | 19 +++++++++++++++---- lib_dec/swb_bwe_dec_fx.c | 30 +++++++++++++++++++++++++++--- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 9f2eb0d4a..281599664 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1892,7 +1892,11 @@ void GenShapedWBExcitation_ivas_fx( /* o : Q_syn_hb*/ Word16 ivas_wb_bwe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ +#else const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ + #endif Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ diff --git a/lib_com/options.h b/lib_com/options.h index 1852ffa6d..414eaaa40 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,6 +108,7 @@ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ +//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 37d9520cd..c4ecdffcd 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -93,7 +93,9 @@ ivas_error ivas_core_dec_fx( ivas_error error; Word32 L_tmp; Word16 Q_synth; +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Word16 output_16_fx[CPE_CHANNELS][L_FRAME48k]; +#endif Word16 hb_synth_16_fx[CPE_CHANNELS][L_FRAME48k]; Word16 synth_16_fx[CPE_CHANNELS][L_FRAME48k]; Word32 synth_32_fx[CPE_CHANNELS][L_FRAME48k]; @@ -467,8 +469,9 @@ ivas_error ivas_core_dec_fx( * HQ core decoding *---------------------------------------------------------------------*/ +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE set16_fx( output_16_fx[n], 0, L_FRAME48k ); /* this is needed for instances like L_norm_arr( p_output_fx[i], L_FRAME48k ) */ - +#endif IF( st->core == ACELP_CORE ) { /* ACELP core decoder */ @@ -1023,8 +1026,10 @@ ivas_error ivas_core_dec_fx( Q_synth_fx = Q_synth; move16(); +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 +#endif + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 test(); test(); test(); @@ -1043,7 +1048,11 @@ ivas_error ivas_core_dec_fx( ELSE IF( EQ_16( st->extl, WB_BWE ) && st->bws_cnt == 0 ) { /* WB BWE decoder */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_32_fx[n], synth_16_fx[n], hb_synth_16_fx[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); +#else Q_hb_synth_fx = ivas_wb_bwe_dec_fx( st, output_16_fx[n], synth_16_fx[n], hb_synth_16_fx[n], use_cldfb_for_dft, output_frame, voice_factors_fx[n], pitch_buf_fx[n], &Q_synth_fx ); +#endif } /* Memories Re-Scaling */ @@ -1051,7 +1060,9 @@ ivas_error ivas_core_dec_fx( { Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 } - Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE + Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 +#endif Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 IF( hBWE_FD != NULL ) @@ -1165,7 +1176,7 @@ ivas_error ivas_core_dec_fx( #ifdef HARM_NON_LINEARITY Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif Copy_Scale_sig_32_16( synth_32_fx[n], synth_fxl, output_frame, negate( add( Q11, q ) ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 1845b32e4..c1cb1ed5f 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -355,8 +355,12 @@ Word16 WB_BWE_gain_deq_fx( /* o : Q_syn_hb */ Word16 ivas_wb_bwe_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ + Decoder_State *st_fx, /* i/o: decoder state structure */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ +#else + const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ +#endif Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ @@ -370,6 +374,10 @@ Word16 ivas_wb_bwe_dec_fx( Word16 ysynth_fx[L_FRAME48k]; Word16 Q_syn, exp, Q_syn_hb; Word32 L_wtda_synth_fx[2 * L_FRAME48k], ysynth_32[L_FRAME48k], t_audio32_tmp[L_FRAME48k]; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 output[L_FRAME48k]; + Word16 Q_input, sf; +#endif Word16 scl, new_input_fx_exp; Word16 i; FD_BWE_DEC_HANDLE hBWE_FD; @@ -379,8 +387,20 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD = st_fx->hBWE_FD; - /* MDCT of the core synthesis signal */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + sf = getScaleFactor32( output_fx32, L_FRAME48k ); + + Q_input = 0; + move16(); + if ( LT_16( sf, 5 ) ) + { + Q_input = sub( sf, 5 ); + } + + Copy_Scale_sig_32_16( output_fx32, output, L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input +#endif + /* MDCT of the core synthesis signal */ new_input_fx_exp = *Qpost; move16(); test(); @@ -512,6 +532,10 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD->prev_Q_synth = Q_syn; move16(); +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig_16_32_no_sat( output, output_fx32, L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 + +#endif return Q_syn_hb; } -- GitLab From bd3b498ec72b503a18ec1d7e839e34cb05ace6ae Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 16:51:31 +0100 Subject: [PATCH 04/26] clang-format --- lib_com/prot_fx.h | 2 +- lib_dec/acelp_core_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 66349adcc..c956b584d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10201,7 +10201,7 @@ Word16 swb_bwe_dec_fx32( ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ + Word32 output_fx32[], /* o : synthesis @internal Fs Q11*/ #else Word16 output_fx[], /* o : synthesis @internal Fs */ #endif diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 366480956..1dc3fc087 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -221,7 +221,7 @@ ivas_error acelp_core_dec_fx( #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING set32_fx( output_fx32, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #else - set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #endif set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ -- GitLab From 7be3ae7388cff6e63e37a6fc35eec17649a971d0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 17:29:41 +0100 Subject: [PATCH 05/26] fix buffer length --- lib_dec/acelp_core_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 1dc3fc087..f6fd79257 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2215,14 +2215,14 @@ ivas_error acelp_core_dec_fx( /* 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 ) - { #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Copy_Scale_sig_16_32_no_sat( psyn_fx, output_fx32, L_FRAME48k, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 + Copy_Scale_sig_16_32_no_sat( psyn_fx, output_fx32, st->L_frame, sub( Q11, st->Q_syn2 ) ); // Q_syn2->Q11 #else + IF( st->element_mode > EVS_MONO ) + { Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ -#endif } +#endif st->Q_syn2 = 0; move16(); -- GitLab From a46f371a962d0db7886b7c66acd56cc49fd25fb6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 17:37:04 +0100 Subject: [PATCH 06/26] cleaning --- lib_dec/swb_bwe_dec_fx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index c1cb1ed5f..025129585 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -532,10 +532,6 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD->prev_Q_synth = Q_syn; move16(); -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Copy_Scale_sig_16_32_no_sat( output, output_fx32, L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 - -#endif return Q_syn_hb; } -- GitLab From ce6f0d99ec65011a307618ca9dd8b54bae8b6923 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:08:44 +0100 Subject: [PATCH 07/26] optimization --- lib_dec/ivas_core_dec_fx.c | 21 ++++++++++++++++----- lib_dec/swb_bwe_dec_fx.c | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index c4ecdffcd..595d8b062 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -284,6 +284,9 @@ ivas_error ivas_core_dec_fx( } set16_fx( voice_factors_fx[n], 0, NB_SUBFR16k ); +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + set32_fx( output_32_fx[n], 0, L_FRAME48k ); +#endif set32_fx( hb_synth_32_fx[n], 0, L_FRAME48k ); set16_fx( hb_synth_16_fx[n], 0, L_FRAME48k ); bwe_exc_extended_fx[n] = hb_synth_32_fx[n]; /* note: reuse the buffer */ @@ -848,7 +851,11 @@ ivas_error ivas_core_dec_fx( set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } - Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], output_frame, Q4 - Q11 ); // Q4 +#else + Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 +#endif /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ @@ -953,7 +960,11 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( st->delay_buf_out_fx, st->delay_buf_out32_fx, ( HQ_DELTA_MAX * HQ_DELAY_COMP ), sub( Q11, st->hHQ_core->Q_old_postdec ) ); // Q11 } - Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], output_frame, ( Q11 - Q4 ) ); // Q11 +#else + Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 +#endif /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -1029,7 +1040,7 @@ ivas_error ivas_core_dec_fx( #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input #endif - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 test(); test(); test(); @@ -1061,7 +1072,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 } #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE - Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 + Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 #endif Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 @@ -1174,7 +1185,7 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); #ifdef HARM_NON_LINEARITY - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 025129585..61d5b3451 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -375,7 +375,7 @@ Word16 ivas_wb_bwe_dec_fx( Word16 Q_syn, exp, Q_syn_hb; Word32 L_wtda_synth_fx[2 * L_FRAME48k], ysynth_32[L_FRAME48k], t_audio32_tmp[L_FRAME48k]; #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word16 output[L_FRAME48k]; + Word16 output[L_FRAME16k]; Word16 Q_input, sf; #endif Word16 scl, new_input_fx_exp; @@ -387,25 +387,25 @@ Word16 ivas_wb_bwe_dec_fx( hBWE_FD = st_fx->hBWE_FD; -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - sf = getScaleFactor32( output_fx32, L_FRAME48k ); - - Q_input = 0; - move16(); - if ( LT_16( sf, 5 ) ) - { - Q_input = sub( sf, 5 ); - } - - Copy_Scale_sig_32_16( output_fx32, output, L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input -#endif - /* MDCT of the core synthesis signal */ new_input_fx_exp = *Qpost; move16(); test(); IF( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && !use_cldfb_for_dft ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + sf = getScaleFactor32( output_fx32, st_fx->L_frame ); + + Q_input = 0; + move16(); + if ( LT_16( sf, 5 ) ) + { + Q_input = sub( sf, 5 ); + } + + Copy_Scale_sig_32_16( output_fx32, output, st_fx->L_frame, sub( Q_input, Q11 ) ); // Q_input + +#endif /* IVAS_fmToDo: wtda() does not support L_FRAME length; thus temporarily resample the signal */ /* IVAS_fmToDo: delay output[] by 1.25ms ? */ lerp( output, ysynth_fx, L_FRAME16k, st_fx->L_frame ); -- GitLab From f20a898e278157cc2e14f8b18701d241bdeb7ec3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:27:41 +0100 Subject: [PATCH 08/26] updt --- lib_com/prot_fx.h | 10 +++++++--- lib_dec/core_switching_dec_fx.c | 24 ++++++++++++++++++++---- lib_dec/ivas_core_dec_fx.c | 29 ++++++++++++++++++++--------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c956b584d..f48e092a5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7654,9 +7654,13 @@ ivas_error core_switching_pre_dec_fx( Word16 *Q_olapBufferSynth2 ); ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ +#else + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ +#endif Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 3bfcb453d..cd30683fd 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -208,9 +208,13 @@ void bw_switching_pre_proc_fx( ivas_error core_switching_post_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth, /* i/o: output synthesis Qsynth*/ - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth, /* i/o: output synthesis Qsynth*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ +#else + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ +#endif Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ @@ -433,7 +437,11 @@ ivas_error core_switching_post_dec_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { - Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_fx, output_frame, Q10 - Q11 ); /* Q10 */ +#else + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#endif core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -491,7 +499,11 @@ ivas_error core_switching_post_dec_fx( FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ +#else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ +#endif move32(); IF( LT_16( alpha, sub( 32767, tmp ) ) ) { @@ -540,7 +552,11 @@ ivas_error core_switching_post_dec_fx( FOR( i = 0; i < delta; i++ ) { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ +#else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ +#endif move32(); IF( LT_16( alpha, sub( 32767, tmp ) ) ) { diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 595d8b062..4014d3ab2 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -851,12 +851,10 @@ ivas_error ivas_core_dec_fx( set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_32_fx[n], output_frame, Q4 - Q11 ); // Q4 -#else - Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 -#endif +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 +#endif /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ @@ -961,7 +959,10 @@ ivas_error ivas_core_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE + Scale_sig32( output_32_fx[n], output_frame, ( Q4 - Q11 ) ); // Q4 Scale_sig32( output_32_fx[n], output_frame, ( Q11 - Q4 ) ); // Q11 +#endif #else Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 #endif @@ -1005,8 +1006,18 @@ ivas_error ivas_core_dec_fx( * WB BWE decoding *---------------------------------------------------------------------*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE + Word16 Q_hb_synth_fx, Q_synth_fx; + Word16 Q_syn_hb; + + Q_hb_synth_fx = 0; + move16(); + Q_synth_fx = Q_synth; + move16(); +#else Word16 Q_input, Q_hb_synth_fx, Q_synth_fx; Word16 Q_syn_hb, sf; +#endif flaf_swb_tbe = 0; move16(); @@ -1024,6 +1035,7 @@ ivas_error ivas_core_dec_fx( move16(); } +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE sf = getScaleFactor32( output_32_fx[n], L_FRAME48k ); Q_input = 0; @@ -1037,10 +1049,9 @@ ivas_error ivas_core_dec_fx( Q_synth_fx = Q_synth; move16(); -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE Copy_Scale_sig_32_16( output_32_fx[n], output_16_fx[n], L_FRAME48k, sub( Q_input, Q11 ) ); // Q_input #endif - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 test(); test(); test(); @@ -1072,7 +1083,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( hb_synth_16_fx[n], hb_synth_32_fx[n], L_FRAME48k, sub( Q11, Q_hb_synth_fx ) ); // Q11 } #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE - Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 + Copy_Scale_sig_16_32_no_sat( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_input ) ); // Q11 // Q_input can get value <= -5 #endif Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], synth_32_fx[n], output_frame, sub( Q11, Q_synth_fx ) ); // Q11 @@ -1185,7 +1196,7 @@ ivas_error ivas_core_dec_fx( q = 2; move16(); #ifdef HARM_NON_LINEARITY - Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 #else Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, -( Q11 ) ); // Q0 #endif -- GitLab From e792d0e25d832dcda81284b39d4114146ef80ab0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:41:18 +0100 Subject: [PATCH 09/26] FIX_2280_REDUCTION_UNNECESSARY_SCALING2 --- lib_com/options.h | 1 + lib_com/prot_fx.h | 6 +++++- lib_dec/core_switching_dec_fx.c | 19 ++++++++++++++++++- lib_dec/ivas_core_dec_fx.c | 12 +++++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 414eaaa40..3286878a2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,7 @@ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ //#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index f48e092a5..bb9ee20ac 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7661,7 +7661,11 @@ ivas_error core_switching_post_dec_fx( #else Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ #endif - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#else + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#endif const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index cd30683fd..ae7299d5e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -207,6 +207,12 @@ void bw_switching_pre_proc_fx( } +/*---------------------------------------------------------------------* + * core_switching_post_dec() + * + * Postprocessing for ACELP/HQ core switching + *---------------------------------------------------------------------*/ + ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ @@ -215,7 +221,11 @@ ivas_error core_switching_post_dec_fx( #else Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ #endif - Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#else + Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ +#endif const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ const Word16 output_frame, /* i : frame length Q0*/ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag Q0*/ @@ -618,10 +628,17 @@ ivas_error core_switching_post_dec_fx( hHQ_core->Q_old_wtda = Qtmp; move16(); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; + + Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) + Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ +#else IF( output_mem_fx != NULL ) { Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ } +#endif *Qsynth = Qtmp; move16(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 4014d3ab2..db08b8feb 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -835,6 +835,7 @@ ivas_error ivas_core_dec_fx( /*core_switching_post_dec*/ Q_synth = add( sub( 15, e_sig[0] ), st->Q_syn_factor ); +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /*------------------fix-to-fix-end-----------------------*/ Word16 output_mem_16_fx[L_FRAME48k]; @@ -850,14 +851,15 @@ ivas_error ivas_core_dec_fx( p_output_mem_16 = NULL; set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } - +#endif #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 #endif +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ - +#endif IF( st->cldfbSyn != NULL ) { scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q4 - Q11 ); // Q4 @@ -917,7 +919,11 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_fx, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -964,7 +970,7 @@ ivas_error ivas_core_dec_fx( Scale_sig32( output_32_fx[n], output_frame, ( Q11 - Q4 ) ); // Q11 #endif #else - Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 + Scale_sig32( output_32_fx[n], L_FRAME48k, ( Q11 - Q4 ) ); // Q11 #endif /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ -- GitLab From e3555e5ee9a9a33adcd0c9d21dad39eb08e37e25 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 26 Jan 2026 19:54:18 +0100 Subject: [PATCH 10/26] fix --- lib_dec/ivas_mct_dec_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index d44ebdb3f..6deeef90d 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -340,6 +340,7 @@ ivas_error ivas_mct_dec_fx( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { @@ -349,7 +350,7 @@ ivas_error ivas_mct_dec_fx( { set16_fx( output_mem_fx, 0, NS2SA_FX2( sts[n]->output_Fs, 3125000 ) ); } - +#endif Word16 Q_synth = sub( 15, e_sig[n] ); move16(); @@ -364,7 +365,11 @@ ivas_error ivas_mct_dec_fx( dirac_stereo_flag = 0; } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], hCPE->output_mem_fx[1], 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) +#endif { return error; } -- GitLab From 980f808b214f5a51f0fc35524a1371b173c425b8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 08:01:22 +0100 Subject: [PATCH 11/26] fix MSAN errors --- lib_dec/core_switching_dec_fx.c | 8 +++++--- lib_dec/ivas_tcx_core_dec_fx.c | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ae7299d5e..ab0fd31da 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -630,9 +630,11 @@ ivas_error core_switching_post_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; - - Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) - Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + IF( output_mem_fx32 != NULL ) + { + Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) + Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + } #else IF( output_mem_fx != NULL ) { diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 3c917978c..b85150251 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -903,8 +903,7 @@ void stereo_tcx_core_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word16 output_frame = extract_l( Mpy_32_16_1( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - Copy_Scale_sig_16_32_DEPREC( signal_out_fx, signal_out_32_fx, output_frame, sub( Q11, st->Q_syn_factor ) ); + Copy_Scale_sig_16_32_DEPREC( signal_out_fx, signal_out_32_fx, st->L_frame, sub( Q11, st->Q_syn_factor ) ); #endif pop_wmops(); -- GitLab From d7746898df8fe78b9ae50daed37dfbe482030882 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 08:40:00 +0100 Subject: [PATCH 12/26] fix MSAN errors --- lib_dec/hq_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index f9dac288e..8d1f4c966 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1004,7 +1004,7 @@ void ivas_hq_core_dec_fx( #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig( output, st_fx->old_exc_fx + sub( L_EXC_MEM_DEC, st_fx->L_frame ), st_fx->L_frame, negate( Q_output ) ); /* Q0 */ - Copy_Scale_sig_16_32_DEPREC( output, output_32_fx, L_FRAME48k, sub( Q11, Q_output ) ); // Q11 + Copy_Scale_sig_16_32_DEPREC( output, output_32_fx, L_FRAME16k, sub( Q11, Q_output ) ); // Q11 st_fx->Q_syn_factor = s_min( 0, s_min( *Q_synth, Q_output ) ); #else IF( st_fx->element_mode > EVS_MONO ) -- GitLab From 058e89a02dad8c503570ce7c2d7e6940fa486cef Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 09:34:15 +0100 Subject: [PATCH 13/26] disable FIX_2280_REDUCTION_UNNECESSARY_SCALING2 --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3286878a2..e2c7b3a96 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ //#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ -- GitLab From acecaca6246af12d9c307fb578e8f996814a2bd1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 12:31:52 +0100 Subject: [PATCH 14/26] fix --- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 11 ++++++++--- lib_dec/hq_core_dec_fx.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index f6fd79257..f4e2bf5f3 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -219,7 +219,7 @@ ivas_error acelp_core_dec_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - set32_fx( output_fx32, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + set32_fx( output_fx32, 0, st->L_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #else set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ #endif diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ab0fd31da..58e4a606e 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -247,6 +247,10 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; Word16 offset; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word16 q_output_fx = Q11; + move16(); +#endif L_tmp = 0; move32(); @@ -448,7 +452,8 @@ ivas_error core_switching_post_dec_fx( IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_fx, output_frame, Q10 - Q11 ); /* Q10 */ + Scale_sig32( output_fx, st_fx->L_frame, Q10 - Q11 ); /* Q10 */ + q_output_fx = Q4; #else Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif @@ -510,7 +515,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif @@ -563,7 +568,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 8d1f4c966..dcc99bbdc 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -512,7 +512,7 @@ void ivas_hq_core_dec_fx( #ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 tmp_out[L_FRAME48k]; #else - Word16 output[L_FRAME48k]; + Word16 output[L_FRAME16k]; Word16 Q_output; Q_output = 0; -- GitLab From 8ae38f57e11db4463449e7aecf392f383a448993 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 12:37:14 +0100 Subject: [PATCH 15/26] enable FIX_2280_REDUCTION_UNNECESSARY_SCALING2 --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index e2c7b3a96..3286878a2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ //#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE -//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ -- GitLab From eb82bc34fc852ebc2cc9af5e332fc5975d72a9bd Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 18:44:11 +0100 Subject: [PATCH 16/26] fix + activate FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE --- lib_com/options.h | 2 +- lib_dec/core_switching_dec_fx.c | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 108f4c993..6bdf247c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,7 @@ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ #define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE #define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 58e4a606e..c50fabdc2 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -172,7 +172,6 @@ void bw_switching_pre_proc_fx( } } - test(); test(); test(); @@ -835,7 +834,6 @@ ivas_error core_switching_post_dec_fx( test(); test(); test(); - IF( ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) || EQ_16( st_fx->extl, SWB_CNG ) ) && ( NE_16( st_fx->L_frame, st_fx->last_L_frame ) || ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) || EQ_16( st_fx->last_core, HQ_CORE ) ) ) || ( LT_16( st_fx->bwidth, st_fx->last_bwidth ) && NE_16( st_fx->last_extl, SWB_TBE ) ) || st_fx->old_ppp_mode || ( ( EQ_16( st_fx->prev_coder_type, AUDIO ) || EQ_16( st_fx->prev_coder_type, INACTIVE ) ) && st_fx->bws_cnt > 0 ) || ( st_fx->bws_cnt == 0 && EQ_16( st_fx->prev_bws_cnt, N_WS2N_FRAMES ) ) ) @@ -911,6 +909,7 @@ ivas_error core_switching_post_dec_fx( return error; } + /*---------------------------------------------------------------------* * core_switching_hq_prepare_dec() * @@ -994,9 +993,17 @@ void core_switching_hq_prepare_dec_fx( /* reset state of old_out if switching */ set16_fx( st_fx->hHQ_core->old_out_fx, 0, output_frame ); + return; } + +/*---------------------------------------------------------------------* + * core_switch_lb_upsamp() + * + * Resample HQ/TCX-LB to the output sampling rate (8/16/32/48 kHz) + *---------------------------------------------------------------------*/ + static void core_switch_lb_upsamp_fx( Decoder_State *st, /* i/o: Decoder state */ Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ @@ -1072,17 +1079,28 @@ static void core_switch_lb_upsamp_fx( no_col = s_min( no_col, temp ); } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( st->hTcxDec->L_frameTCX, imult1616( no_col, st->cldfbSyn->no_channels ) ), Q4 - Q10 ); /* Q4 */ +#else Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( L_FRAME48k, imult1616( no_col, st->cldfbSyn->no_channels ) ), 4 - 10 ); /* Q4 */ +#endif /* save synthesis - needed in case of core switching */ IF( st->hTcxDec != NULL ) { - Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -4 ); /* Q0 */ + Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -Q4 ); /* Q0 */ } return; } + +/*---------------------------------------------------------------------* + * smoothTransitionDtxToTcx() + * + * apply smoothing to the transition part for inactive to active transitions in DTX + *---------------------------------------------------------------------*/ + #define TRANSITION_SMOOTHING_LEN_16k 15 #define TRANSITION_SMOOTHING_LEN_32k 31 #define TRANSITION_SMOOTHING_LEN_48k 47 -- GitLab From 5da447265f7312c6250253de833e7aa8cc7f1d10 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 18:57:23 +0100 Subject: [PATCH 17/26] simplification --- lib_dec/core_switching_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index c50fabdc2..f352a3f30 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -636,8 +636,7 @@ ivas_error core_switching_post_dec_fx( Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; IF( output_mem_fx32 != NULL ) { - Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), -Q11 ); // Q(q_output_mem_fx-11) - Scale_sig( output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), Qtmp ); /* Qtmp */ + Copy_Scale_sig_32_16( output_mem_fx32, output_mem_fx, NS2SA_FX2( st_fx->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Qtmp, Q11 ) ); // Qtmp } #else IF( output_mem_fx != NULL ) -- GitLab From 526491a6a12bb5cbc0c0149f76edf334f8185b57 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 27 Jan 2026 20:38:56 +0100 Subject: [PATCH 18/26] disable FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE --- lib_com/options.h | 2 +- lib_dec/acelp_core_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6d09f8e0e..9fddaf3a6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,7 +120,7 @@ #define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ #define FIX_2355_IGF_EXP_POWERSPEC /* FhG: basop issue 2355: make sure exp_pPowerSpectrumParameter_fx is initialized in all cases */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE #define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index d8c2cd7bc..6d37d4486 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2073,7 +2073,7 @@ ivas_error acelp_core_dec_fx( #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx32, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); #else - 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, synth_fx /*tmp buffer for save_hb_synth_fx[] */, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); #ifdef FIX_BASOP_2350_HARM_0B_BWE_2 Copy_Scale_sig_32_16( synth_fx, save_hb_synth_fx16, output_frame, 0 ); // Q0 -- GitLab From 526131890e15d723365289984f60bf3ab84e6675 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 Jan 2026 09:41:57 +0100 Subject: [PATCH 19/26] simplification --- lib_dec/core_switching_dec_fx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index f352a3f30..41b42c6b0 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -246,10 +246,6 @@ ivas_error core_switching_post_dec_fx( HQ_DEC_HANDLE hHQ_core; ivas_error error; Word16 offset; -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word16 q_output_fx = Q11; - move16(); -#endif L_tmp = 0; move32(); @@ -452,7 +448,6 @@ ivas_error core_switching_post_dec_fx( { #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Scale_sig32( output_fx, st_fx->L_frame, Q10 - Q11 ); /* Q10 */ - q_output_fx = Q4; #else Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif @@ -514,7 +509,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif @@ -567,7 +562,7 @@ ivas_error core_switching_post_dec_fx( { st_fx->cldfbAna->cldfb_state_fx[offset - delta + i] = #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], sub( Q10, q_output_fx ) ), alpha ); /* Q10 */ + Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q11 ), alpha ); /* Q10 */ #else Mpy_32_16_1( L_shl( output_fx[st_fx->L_frame - delta + i], Q10 - Q4 ), alpha ); /* Q10 */ #endif @@ -1079,7 +1074,7 @@ static void core_switch_lb_upsamp_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( st->hTcxDec->L_frameTCX, imult1616( no_col, st->cldfbSyn->no_channels ) ), Q4 - Q10 ); /* Q4 */ + Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( st->hTcxDec->L_frameTCX, imult1616( no_col, st->cldfbSyn->no_channels ) ), Q11 - Q10 ); /* Q11 */ #else Scale_sig32( output + imult1616( no_col, st->cldfbSyn->no_channels ), sub( L_FRAME48k, imult1616( no_col, st->cldfbSyn->no_channels ) ), 4 - 10 ); /* Q4 */ #endif @@ -1087,7 +1082,11 @@ static void core_switch_lb_upsamp_fx( /* save synthesis - needed in case of core switching */ IF( st->hTcxDec != NULL ) { +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -Q4 ); /* Q0 */ +#else + Copy_Scale_sig_32_16( output, st->previoussynth_fx, st->hTcxDec->L_frameTCX, -Q4 ); /* Q0 */ +#endif } return; -- GitLab From 0f48cf1825f0d8228c4f92f9362139d1f9eb21dc Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 Jan 2026 14:45:26 +0100 Subject: [PATCH 20/26] fix in core_switch_lb_upsamp_fx() --- lib_dec/core_switching_dec_fx.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 41b42c6b0..9cba3af81 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -446,10 +446,8 @@ ivas_error core_switching_post_dec_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_fx, st_fx->L_frame, Q10 - Q11 ); /* Q10 */ -#else - Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -1000,7 +998,11 @@ void core_switching_hq_prepare_dec_fx( static void core_switch_lb_upsamp_fx( Decoder_State *st, /* i/o: Decoder state */ - Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 *output /* i/o: LB synth/upsampled LB synth Q11*/ +#else + Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ +#endif ) { Word16 i, no_col; @@ -1008,6 +1010,13 @@ static void core_switch_lb_upsamp_fx( Word32 realBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Word32 output_tmp[L_FRAME16k]; + + Copy32( output, output_tmp, s_min( st->L_frame, L_FRAME16k ) ); + Scale_sig32( output, st->L_frame, Q10 - Q11 ); /* Q10 */ +#endif + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ FOR( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) { @@ -1089,6 +1098,10 @@ static void core_switch_lb_upsamp_fx( #endif } +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy32( output_tmp, output, imult1616( no_col, st->cldfbSyn->no_channels ) ); /* Q11 */ +#endif + return; } -- GitLab From 00b63e8b790d291a743d6cf4d1ca7e1106ae6fb0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 29 Jan 2026 12:26:06 +0100 Subject: [PATCH 21/26] restore bit-exactness --- lib_dec/core_switching_dec_fx.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 0f89d14b0..4873fe0a2 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -446,8 +446,10 @@ ivas_error core_switching_post_dec_fx( test(); IF( ( ( NE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_core_brate, FRAME_NO_DATA ) ) || ( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) && NE_16( st_fx->element_mode, IVAS_CPE_TD ) ) || EQ_16( nchan_out, 1 ) ) && !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( st_fx->idchan, 1 ) && ( EQ_16( nchan_out, 1 ) || EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) ) { -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q11 ); /* Q10 */ +#else + Scale_sig32( output_fx, L_FRAME48k, Q10 - Q4 ); /* Q10 */ #endif core_switch_lb_upsamp_fx( st_fx, output_fx ); } @@ -998,11 +1000,7 @@ void core_switching_hq_prepare_dec_fx( static void core_switch_lb_upsamp_fx( Decoder_State *st, /* i/o: Decoder state */ -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 *output /* i/o: LB synth/upsampled LB synth Q11*/ -#else - Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ -#endif + Word32 *output /* i/o: LB synth/upsampled LB synth Q10*/ ) { Word16 i, no_col; @@ -1010,15 +1008,6 @@ static void core_switch_lb_upsamp_fx( Word32 realBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; Word32 imagBufferTmp_fx[CLDFB_OVRLP_MIN_SLOTS][CLDFB_NO_CHANNELS_MAX]; -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 output_tmp[L_FRAME16k]; - - /* save the original output "buffer" to ensure that it is not overwritten in this function */ - Copy32( output, output_tmp, s_min( st->L_frame, L_FRAME16k ) ); - - Scale_sig32( output, st->L_frame, Q10 - Q11 ); /* Q10 */ -#endif - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ FOR( i = 0; i < CLDFB_OVRLP_MIN_SLOTS; i++ ) { @@ -1101,7 +1090,7 @@ static void core_switch_lb_upsamp_fx( } #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Copy32( output_tmp, output, imult1616( no_col, st->cldfbSyn->no_channels ) ); /* Q11 */ + Scale_sig32( output, imult1616( no_col, st->cldfbSyn->no_channels ), Q11 - Q4 ); /* Q11 */ #endif return; -- GitLab From 6324cd496c6ce24f83deb92c422133f03dadaf53 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 14:49:19 +0100 Subject: [PATCH 22/26] clang-format --- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/core_switching_dec_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 0b4dd036c..922f7ad1f 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2135,7 +2135,7 @@ ivas_error acelp_core_dec_fx( #ifdef FIX_2379_REMOVE_previoussynth_fx_32 Copy_Scale_sig_32_16( synth_fx, st->previoussynth_fx, output_frame, 0 ); // Q0 #else - Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 + Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 #endif } ELSE diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index c86bd236b..0c94c8c3c 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1663,7 +1663,7 @@ ivas_error core_switching_pre_dec_fx( Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ #else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif st->lp_gainp_fx = 0; move16(); @@ -1752,7 +1752,7 @@ ivas_error core_switching_pre_dec_fx( Copy_Scale_sig_16_32_no_sat( st->previoussynth_fx, previoussynth_fx_32, output_frame, 0 ); fer_energy_fx( output_frame, UNVOICED_CLAS, previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q0*/ #else - fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ + fer_energy_fx( output_frame, UNVOICED_CLAS, st->previoussynth_fx_32, 0, -1, &st->enr_old_fx, 1 ); /*Q-0*/ #endif st->lp_gainp_fx = 0; -- GitLab From 8ef2c953864b79020fbe69bd1be3df022f2a5cce Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 16:58:13 +0100 Subject: [PATCH 23/26] remove buffer synth_fxl[960] --- lib_dec/ivas_core_dec_fx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index cae261c21..99b17712e 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -869,7 +869,6 @@ ivas_error ivas_core_dec_fx( move16(); } - test(); test(); test(); @@ -1206,6 +1205,14 @@ ivas_error ivas_core_dec_fx( IF( ( GE_16( output_frame, L_FRAME32k ) && st->hTdCngDec != NULL ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && GE_16( st->bwidth, SWB ) && st->hTdCngDec != NULL ) ) { /* SHB CNG decoder */ +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 + Copy_Scale_sig_32_16( synth_32_fx[n], synth_16_fx[n], output_frame, -( Q11 + Q2 ) ); // Q0 + Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 + Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 + + swb_CNG_dec_fx( st, synth_16_fx[n], hb_synth_16_fx[n], sid_bw[n], -Q2 ); +#else Word16 synth_fxl[960]; /* Q-2 */ Word16 q; @@ -1217,6 +1224,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 swb_CNG_dec_fx( st, synth_fxl, hb_synth_16_fx[n], sid_bw[n], negate( q ) ); +#endif test(); IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) @@ -1236,7 +1244,7 @@ ivas_error ivas_core_dec_fx( IF( n == 0 && GE_16( st->element_mode, IVAS_CPE_DFT ) ) { Word16 q; - q = 11; + q = Q11; move16(); #ifndef FIX_2367_REMOVE_CODE_ICBWE @@ -1247,6 +1255,7 @@ ivas_error ivas_core_dec_fx( } #endif stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); + test(); test(); test(); -- GitLab From bcb6fa4ff54a2b4e1b1c58089a2374889dc3a37a Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 18:27:08 +0100 Subject: [PATCH 24/26] activate FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8a0467763..2ee68f076 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,7 +110,7 @@ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -//#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE #define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /* #################### End BE switches ################################## */ -- GitLab From 5e7e6b41813e02c287753c17ac91b492e483cde1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Feb 2026 18:28:17 +0100 Subject: [PATCH 25/26] clang-format --- lib_dec/ivas_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 99b17712e..9bdda48a2 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -1207,7 +1207,7 @@ ivas_error ivas_core_dec_fx( /* SHB CNG decoder */ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Copy_Scale_sig_32_16( hb_synth_32_fx[n], hb_synth_16_fx[n], output_frame, -( Q11 ) ); // Q0 - Copy_Scale_sig_32_16( synth_32_fx[n], synth_16_fx[n], output_frame, -( Q11 + Q2 ) ); // Q0 + Copy_Scale_sig_32_16( synth_32_fx[n], synth_16_fx[n], output_frame, -( Q11 + Q2 ) ); // Q0 Scale_sig( hBWE_TD->state_lpc_syn_fx, LPC_SHB_ORDER, sub( Q8, hBWE_TD->prev_Q_bwe_syn ) ); // Q8 Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, ( 2 * ALLPASSSECTIONS_STEEP ), sub( hBWE_TD->prev_Q_bwe_syn2, Q11 ) ); // prev_Q_bew_syn2 @@ -1255,7 +1255,7 @@ ivas_error ivas_core_dec_fx( } #endif stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); - + test(); test(); test(); -- GitLab From b09f8a9906c25771ef653915af6c114495e7c178 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 4 Feb 2026 08:10:25 +0100 Subject: [PATCH 26/26] merge FIX_2280_REDUCTION_UNNECESSARY_SCALING2 into FIX_2280_REDUCTION_UNNECESSARY_SCALING --- lib_com/options.h | 3 +-- lib_com/prot_fx.h | 7 ++----- lib_dec/core_switching_dec_fx.c | 4 ++-- lib_dec/ivas_core_dec_fx.c | 9 +++------ lib_dec/ivas_mct_dec_fx.c | 4 ++-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2ee68f076..62a5c198b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,8 +110,7 @@ #define FIX_2397_COPY_AQ_MDCT_CORE_BFI /* FhG: prevent copying of uninit memory in MDCT stereo core if bfi is set */ #define HARMONIZE_TBE /* VA: harmonize core-coder TBE function duplications */ #define FIX_2280_REDUCTION_UNNECESSARY_SCALING /* VA: reduction of unnecessary scaling */ -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE -#define FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#define FIX_2280_REDUCTION_UNNECESSARY_SCALING_NONBE /* VA: reduction of unnecessary scaling, non-BE part */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index cd4f2cc00..2ad5f157e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7575,13 +7575,10 @@ ivas_error core_switching_post_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *synth, /* i/o: output synthesis Qsynth*/ #ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ -#else - Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ -#endif -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q11*/ Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ #else + Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ #endif const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo Q0*/ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 0c94c8c3c..56cc1bfc3 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -220,7 +220,7 @@ ivas_error core_switching_post_dec_fx( #else Word32 *output_fx, /* i/o: LB synth/upsampled LB synth Q4*/ #endif -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word32 output_mem_fx32[], /* i : OLA memory from last TCX/HQ frame Qx*/ #else Word16 output_mem_fx[], /* i : OLA memory from last TCX/HQ frame Qx*/ @@ -627,7 +627,7 @@ ivas_error core_switching_post_dec_fx( hHQ_core->Q_old_wtda = Qtmp; move16(); } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 output_mem_fx[NS2SA( 48000, STEREO_DFT32MS_OVL_NS )]; IF( output_mem_fx32 != NULL ) { diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 9bdda48a2..2e3abcb5e 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -837,7 +837,7 @@ ivas_error ivas_core_dec_fx( /*core_switching_post_dec*/ Q_synth = add( sub( 15, e_sig[0] ), st->Q_syn_factor ); -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING /*------------------fix-to-fix-end-----------------------*/ Word16 output_mem_16_fx[L_FRAME48k]; @@ -853,12 +853,9 @@ ivas_error ivas_core_dec_fx( p_output_mem_16 = NULL; set16_fx( output_mem_16_fx, 0, NS2SA_FX2( st->output_Fs, 3125000 ) ); } -#endif -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING + Scale_sig32( output_32_fx[n], L_FRAME48k, Q4 - Q11 ); // Q4 -#endif -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ #endif @@ -920,7 +917,7 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( synth_16_fx[n], hSCE->save_synth_fx, output_frame, sub( hSCE->q_save_synth_fx, Q_synth ) ); // q_save_synth_fx } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_fx, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_post_dec_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index cf4894e5e..aed970f20 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -371,7 +371,7 @@ ivas_error ivas_mct_dec_fx( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ -#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifndef FIX_2280_REDUCTION_UNNECESSARY_SCALING Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { @@ -396,7 +396,7 @@ ivas_error ivas_mct_dec_fx( dirac_stereo_flag = 0; } -#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING2 +#ifdef FIX_2280_REDUCTION_UNNECESSARY_SCALING IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], hCPE->output_mem_fx[1], 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = core_switching_post_dec_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) -- GitLab