From 79f3351a1eadf6c0a051cfca49b686199cd1ddae Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 10:22:00 -0500 Subject: [PATCH 01/11] remove IVAS version of comp_and_apply --- lib_com/gs_gains_fx.c | 3 ++- lib_com/gs_noisefill_fx.c | 8 +++++--- lib_com/options.h | 2 +- lib_com/prot_fx.h | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 55ced4ea0..c8c6a1f2f 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -136,6 +136,7 @@ void Comp_and_apply_gain_fx( return; } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ @@ -234,7 +235,7 @@ void Comp_and_apply_gain_ivas_fx( return; } - +#endif /*========================================================================*/ /* FUNCTION : Ener_per_band_comp_fx() */ diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index c9c9a89ca..33ca81ebe 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1352,9 +1352,10 @@ void highband_exc_dct_in_ivas_fx( move16(); } } - +#ifndef FIX_2338_HARM_GSC_GAIN_COMP IF( EQ_16( element_mode, EVS_MONO ) ) { +#endif 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 ) @@ -1362,6 +1363,7 @@ void highband_exc_dct_in_ivas_fx( 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 ); } +#ifndef FIX_2338_HARM_GSC_GAIN_COMP } ELSE { @@ -1369,7 +1371,7 @@ void highband_exc_dct_in_ivas_fx( 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 ); + Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); FIX_2338_HARM_GSC_GAIN_COMP IF( exc_wo_nf != NULL ) { @@ -1392,7 +1394,7 @@ void highband_exc_dct_in_ivas_fx( Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } } - +#endif /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, * and add the quantized pulses or the noise for the higher part of the spectrum diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..cc6e63ec6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,7 +145,7 @@ #define FIX_2315_AGC_MEMORY_RESET /* VA: basop issue 2315: fix reset of the AGC memory */ #define FIX_2312_CONDITION_MISSING_GSC_DEC_LR /* VA: basop issue 2297: addition of condition missing in the GSC gain decoder at low-rate */ #define FIX_2313_HF_RESET_16KHZ /* VA: basop issue 2313: Call hf_synth_reset_fx() also for 16 kHz output_Fs */ - +#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 588617196..4ca9e13f6 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1764,7 +1764,7 @@ void Comp_and_apply_gain_fx( const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 Q_exc ); - +#ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ @@ -1773,7 +1773,7 @@ void Comp_and_apply_gain_ivas_fx( const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 *Q_exc ); - +#endif void pre_echo_att_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ -- GitLab From e0b0a2f79795ec4fc91e164a18a22debeecdc173 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 12:44:31 -0500 Subject: [PATCH 02/11] fix clang-format issue --- lib_com/gs_noisefill_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 33ca81ebe..ddb7980b7 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1371,7 +1371,8 @@ void highband_exc_dct_in_ivas_fx( 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 ); FIX_2338_HARM_GSC_GAIN_COMP + Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc ); + FIX_2338_HARM_GSC_GAIN_COMP IF( exc_wo_nf != NULL ) { -- GitLab From 7f57cc0f445362c5329d56a1e5db570cac4d2065 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 13:59:44 -0500 Subject: [PATCH 03/11] fix --- lib_com/gs_noisefill_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index ddb7980b7..f7de75348 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1372,7 +1372,6 @@ void highband_exc_dct_in_ivas_fx( 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 ); - FIX_2338_HARM_GSC_GAIN_COMP IF( exc_wo_nf != NULL ) { -- GitLab From a7a6d7902699a44738ae13ff6c4b7b82244733e1 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 13:59:55 -0500 Subject: [PATCH 04/11] fix --- 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 2c470dc81..b7d351596 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ -#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +/*#define FIX_2338_HARM_GSC_GAIN_COMP*/ /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ -- GitLab From ce81a6d36a9fece60b775eb29d1c1b89ac67be4b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 15 Jan 2026 15:00:09 -0500 Subject: [PATCH 05/11] fix --- 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 b7d351596..2c470dc81 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,7 +116,7 @@ #define OPT_NBE_2311_HARM_GSC_GAIN /* VA: issue 2311: non-BE part of the GSC gain harmonization */ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ -/*#define FIX_2338_HARM_GSC_GAIN_COMP*/ /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ -- GitLab From 21ddb8fa389093a16ba272d47451ea8e0e8fc4af Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 08:16:57 -0500 Subject: [PATCH 06/11] Reducing probability of single frame post filter mode change during audio frames --- lib_com/options.h | 1 + lib_com/prot_fx.h | 5 ++++- lib_dec/LD_music_post_filter_fx.c | 17 ++++++++++++++++- lib_dec/acelp_core_dec_fx.c | 5 ++++- lib_dec/amr_wb_dec_fx.c | 5 ++++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2c470dc81..e0d91123b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -117,6 +117,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2338_HARM_GSC_GAIN_COMP_PART2 /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS, reducing MLD regressions */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 4fea02ccf..0bcae103a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7944,7 +7944,10 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + const Word16 element_mode, /* i : IVAS element mode Q0 */ +#endif + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index fe6433768..01a5a1bd2 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -48,6 +48,9 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + const Word16 element_mode, /* i : IVAS element mode Q0 */ +#endif const Word16 Qdct /* i : input scaling Q0 */ ) { @@ -69,6 +72,9 @@ void LD_music_post_filter_fx( Word16 mant, exp1, s_ave, tmp16, old_tmp16; Word16 diff_sc; Word16 old_tmp16_1; +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + Word16 previous_flag; +#endif move16(); move16(); move16(); @@ -93,8 +99,17 @@ void LD_music_post_filter_fx( /*------------------------------------------------------------------------* * Find signal classification *------------------------------------------------------------------------*/ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + previous_flag = hMusicPF->LDm_last_music_flag; +#endif music_flag2 = stab_est_fx( LG_etot, hMusicPF->LDm_lt_diff_etot_fx, &hMusicPF->LDm_mem_etot_fx, &hMusicPF->LDm_nb_thr_3, &hMusicPF->LDm_nb_thr_1, hMusicPF->LDm_thres_fx, &hMusicPF->LDm_last_music_flag, 1 ); - +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + /* delay going back to 0 by one frame, prevent single frame switching during audio segment */ + if ( EQ_16( Last_coder_type, AUDIO ) && EQ_16( coder_type, AUDIO ) && EQ_16( previous_flag, 1 ) && music_flag2 == 0 && element_mode > EVS_MONO ) + { + music_flag2 = previous_flag; + } +#endif test(); if ( LT_32( core_brate, ACELP_6k60 ) || NE_16( Last_coder_type, AUDIO ) ) { diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index c5d367699..1832662e6 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1213,8 +1213,11 @@ ivas_error acelp_core_dec_fx( } /* LD music post-filter */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, st->element_mode, last_coder_type, qdct ); +#else 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 ); - +#endif /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS { diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index db508ec27..7926ea137 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -586,8 +586,11 @@ ivas_error amr_wb_dec_fx( Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx, hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &Qdct ); /* LD music post-filter */ +#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 + LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, EVS_MONO, Qdct ); +#else LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, Qdct ); - +#endif /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ Post_music_postP_fx( dct_buffer_fx, exc2_fx, mem_tmp_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 1, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, -- GitLab From 8785d158544d237164d2380e9b0adc4a746be64f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 08:21:31 -0500 Subject: [PATCH 07/11] fix clang-format --- lib_com/prot_fx.h | 2 +- lib_dec/LD_music_post_filter_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a5fc7489e..ddf300830 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7947,7 +7947,7 @@ void LD_music_post_filter_fx( #ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 const Word16 element_mode, /* i : IVAS element mode Q0 */ #endif - const Word16 Qdct /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 01a5a1bd2..47c1fb06a 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -49,9 +49,9 @@ void LD_music_post_filter_fx( const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ #ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - const Word16 element_mode, /* i : IVAS element mode Q0 */ + const Word16 element_mode, /* i : IVAS element mode Q0 */ #endif - const Word16 Qdct /* i : input scaling Q0 */ + const Word16 Qdct /* i : input scaling Q0 */ ) { Word32 fr_bands[MBANDS_GN_LD]; /*2*Qdct+10*/ -- GitLab From 71937120271b134855ec92260203678b5cb4dbd0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 09:11:55 -0500 Subject: [PATCH 08/11] fix wrong parameter in LD_music_post_filter_fx call --- lib_dec/acelp_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index f3d49dd41..f133ced32 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1214,7 +1214,7 @@ ivas_error acelp_core_dec_fx( /* LD music post-filter */ #ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, st->element_mode, last_coder_type, qdct ); + 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, st->element_mode, qdct ); #else 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 ); #endif -- GitLab From 4d29115f7f5769b99e112e604a465321ed235f86 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 19 Jan 2026 10:26:26 -0500 Subject: [PATCH 09/11] CodeFileLineColumn --- lib_com/options.h | 1 - lib_com/prot_fx.h | 3 --- lib_dec/LD_music_post_filter_fx.c | 17 +---------------- lib_dec/acelp_core_dec_fx.c | 5 +---- lib_dec/amr_wb_dec_fx.c | 5 +---- 5 files changed, 3 insertions(+), 28 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6b0f753a6..0b6411001 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,6 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ -#define FIX_2338_HARM_GSC_GAIN_COMP_PART2 /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS, reducing MLD regressions */ /* ##################### End NON-BE switches ########################### */ /* #################### Start BASOP optimization switches ############################ */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ddf300830..249f67250 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7944,9 +7944,6 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : i scaling Q0 */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - const Word16 element_mode, /* i : IVAS element mode Q0 */ -#endif const Word16 Qdct /* i : i scaling Q0 */ ); diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 47c1fb06a..4dc9ee37b 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -48,9 +48,6 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - const Word16 element_mode, /* i : IVAS element mode Q0 */ -#endif const Word16 Qdct /* i : input scaling Q0 */ ) { @@ -72,9 +69,6 @@ void LD_music_post_filter_fx( Word16 mant, exp1, s_ave, tmp16, old_tmp16; Word16 diff_sc; Word16 old_tmp16_1; -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - Word16 previous_flag; -#endif move16(); move16(); move16(); @@ -99,17 +93,8 @@ void LD_music_post_filter_fx( /*------------------------------------------------------------------------* * Find signal classification *------------------------------------------------------------------------*/ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - previous_flag = hMusicPF->LDm_last_music_flag; -#endif music_flag2 = stab_est_fx( LG_etot, hMusicPF->LDm_lt_diff_etot_fx, &hMusicPF->LDm_mem_etot_fx, &hMusicPF->LDm_nb_thr_3, &hMusicPF->LDm_nb_thr_1, hMusicPF->LDm_thres_fx, &hMusicPF->LDm_last_music_flag, 1 ); -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - /* delay going back to 0 by one frame, prevent single frame switching during audio segment */ - if ( EQ_16( Last_coder_type, AUDIO ) && EQ_16( coder_type, AUDIO ) && EQ_16( previous_flag, 1 ) && music_flag2 == 0 && element_mode > EVS_MONO ) - { - music_flag2 = previous_flag; - } -#endif + test(); if ( LT_32( core_brate, ACELP_6k60 ) || NE_16( Last_coder_type, AUDIO ) ) { diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index f133ced32..71d8729aa 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1213,11 +1213,8 @@ ivas_error acelp_core_dec_fx( } /* LD music post-filter */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - 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, st->element_mode, qdct ); -#else 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 ); -#endif + /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS { diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 7926ea137..db508ec27 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -586,11 +586,8 @@ ivas_error amr_wb_dec_fx( Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx, hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &Qdct ); /* LD music post-filter */ -#ifdef FIX_2338_HARM_GSC_GAIN_COMP_PART2 - LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, EVS_MONO, Qdct ); -#else LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, &hMusicPF->Old_ener_Q, -1, tmp_coder_type, Qdct ); -#endif + /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ Post_music_postP_fx( dct_buffer_fx, exc2_fx, mem_tmp_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 1, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, -- GitLab From 22a38d5a9e56a32ef3f11d7da2e919a9c8a0c93d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 20 Jan 2026 12:09:33 -0500 Subject: [PATCH 10/11] fix clang-format --- lib_com/prot_fx.h | 2 +- lib_dec/LD_music_post_filter_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 22f5a89b8..05458b52d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7953,7 +7953,7 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 4dc9ee37b..fe6433768 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -48,7 +48,7 @@ void LD_music_post_filter_fx( Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ const Word16 Last_coder_type, /* i : input scaling Q0 */ - const Word16 Qdct /* i : input scaling Q0 */ + const Word16 Qdct /* i : input scaling Q0 */ ) { Word32 fr_bands[MBANDS_GN_LD]; /*2*Qdct+10*/ -- GitLab From c4104ed4e64015355f42c5b205ff037e8932224a Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 22 Jan 2026 21:53:47 +0100 Subject: [PATCH 11/11] formatting --- lib_com/gs_gains_fx.c | 29 ++++++++++++++++++----------- lib_com/options.h | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 99d44a4ba..769af2692 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -73,7 +73,7 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const void Comp_and_apply_gain_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ - Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ + Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, @@ -241,6 +241,7 @@ void Comp_and_apply_gain_ivas_fx( } #endif + /*========================================================================*/ /* FUNCTION : Ener_per_band_comp_fx() */ /*------------------------------------------------------------------------*/ @@ -259,7 +260,6 @@ void Comp_and_apply_gain_ivas_fx( /* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */ /* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */ /*------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ @@ -267,10 +267,10 @@ void Comp_and_apply_gain_ivas_fx( /* o : Band gain Q12 */ static Word16 Comp_band_log_ener( - const Word16 *pt_fx, /* i : Dct input Q_sc */ - const Word16 Len, /* i : Lenght en energy accumulation */ - const Word16 Q_sc, /* i : scaling of input */ - const Word16 E_sc /* i : Additional scaling factor for energy */ + const Word16 *pt_fx, /* i : Dct input Q_sc */ + const Word16 Len, /* i : Lenght en energy accumulation */ + const Word16 Q_sc, /* i : scaling of input */ + const Word16 E_sc /* i : Additional scaling factor for energy */ ) { Word32 L_tmp; @@ -286,6 +286,7 @@ static Word16 Comp_band_log_ener( return tmp16; } + void Ener_per_band_comp_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ @@ -404,6 +405,7 @@ static void GSC_gain_adj( /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */ Word16 Gain_off, i; Word16 Fac_div; + Fac_div = 102; move16(); @@ -541,6 +543,7 @@ Word16 gsc_gaindec_fx( idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 ); VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 ); } + test(); IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) ) { @@ -577,7 +580,9 @@ Word16 gsc_gaindec_fx( *--------------------------------------------------------------------------------------*/ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); + VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 ); + IF( !( coder_type == INACTIVE && st_fx->tdm_LRTD_flag == 0 && EQ_16( st_fx->idchan, 1 ) ) || GT_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) { idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 ); @@ -601,7 +606,9 @@ Word16 gsc_gaindec_fx( move16(); y_gainQ_fx[11] = 0; move16(); + ifft_rel_fx( y_gainQ_fx + 8, 8, 3 ); + FOR( i = 8; i < 16; i++ ) { y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */ @@ -950,11 +957,11 @@ Word16 gsc_gainQ_fx( *-------------------------------------------------------------------*/ static Word16 VDQ_vec_fx( - Word16 *Qvec_out_fx, /* o: Quanitzed vector */ - const Word16 *mean_dic_fx, /* i: average codebook */ - const Word16 *dic_fx, /* i: codebook */ - const Word16 index_fx, /* i: index of codebook*/ - const Word16 vec_en_fx /* i: vector length */ + Word16 *Qvec_out_fx, /* o : Quanitzed vector */ + const Word16 *mean_dic_fx, /* i : average codebook */ + const Word16 *dic_fx, /* i : codebook */ + const Word16 index_fx, /* i : index of codebook */ + const Word16 vec_en_fx /* i : vector length */ ) { Word16 i, j; diff --git a/lib_com/options.h b/lib_com/options.h index a918edd65..c7cd38dd8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,8 +118,8 @@ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ - #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ + /* ##################### End NON-BE switches ########################### */ -- GitLab