From ec0c63e38581bdabe7bfe0ce361556768ed19e8d Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 14 Apr 2026 16:41:27 +0200 Subject: [PATCH 1/9] Preserve precision by removing one-bit headroom from Q_min and allowing saturation during buffer scaling. --- lib_com/options.h | 1 + lib_enc/ivas_core_pre_proc_front_fx.c | 14 +++++++++++++- lib_enc/ivas_core_pre_proc_fx.c | 10 +++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 031b3b41c..ffd01f4ed 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -114,6 +114,7 @@ #define FIX_BASOP_2520_PARAMBIN_THRESHOLD_FIX /* Nokia: BASOP issue 2520: Fix wrong threshold in ParamBin */ #define FIX_BASOP_2510_UNNECESSARY_ASSERT /* Nokia: BASOP issue 2510: Fix by removing assert */ #define FIX_2515_TDREND_PORT_ERROR_SCALING /* Nokia: BASOP issue 2515: Fix port error by changing to correct scaling */ +//#define FIX_BASOP_2517_CLICK_IN_OMASA_LTV /* FhG: BASOP #2517: preserve precision by removing one-bit headroom from Q_min and allowing saturation during buffer scaling */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 80116aa5b..6c3679782 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -356,7 +356,11 @@ void pre_proc_front_ivas_fx( /* Take into account resampling memory for Q_min, and 1 bit headroom for resampling overshoot. */ IF( NE_32( input_Fs, INT_FS_12k8 ) ) { +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Q_min = s_min( Q_min, add( st->mem_q, norm_arr( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX ) ) ); +#else Q_min = sub( s_min( Q_min, add( st->mem_q, norm_arr( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX ) ) ), Q1 ); +#endif } #endif /* Limit Q_min to avoid rescale larger than 15 against Q-1 */ @@ -479,7 +483,11 @@ void pre_proc_front_ivas_fx( *----------------------------------------------------------------*/ #ifdef NONBE_FIX_ISSUE_2206 +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */ +#else scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */ +#endif st->mem_q = st->q_inp; move16(); #else @@ -491,7 +499,11 @@ void pre_proc_front_ivas_fx( { new_inp_out_size = modify_Fs_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx_q_inp, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */ #ifdef NONBE_FIX_ISSUE_2206 +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ +#else scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ +#endif #else Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ st->mem_q = st->q_inp; @@ -505,7 +517,7 @@ void pre_proc_front_ivas_fx( #endif set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); new_inp_out_size = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ -#ifdef NONBE_FIX_ISSUE_2206 +#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ #else Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 019ccca6e..1a67e9d90 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -917,11 +917,11 @@ void ivas_compute_core_buffers_fx( } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { -#ifdef NONBE_FIX_ISSUE_2206 +#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */ #endif size_modified = modify_Fs_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ -#ifdef NONBE_FIX_ISSUE_2206 +#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ #else Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ @@ -931,7 +931,11 @@ void ivas_compute_core_buffers_fx( set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); size_modified = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ #ifdef NONBE_FIX_ISSUE_2206 +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#else scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ +#endif // Scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ Q_tmp = norm_arr( st->mem_decim16k_fx, mem_decim16k_size ); @@ -968,7 +972,7 @@ void ivas_compute_core_buffers_fx( } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { -#ifdef NONBE_FIX_ISSUE_2206 +#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */ #endif /* reconstruct past segment of input signal when switching from MDCT stereo */ -- GitLab From b248cdd8750cb5c4b3890706ec3f2b216fdbfb7e Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 14 Apr 2026 16:53:03 +0200 Subject: [PATCH 2/9] Correct preprocessor condition --- lib_com/options.h | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ffd01f4ed..ce0f0a7cf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -114,7 +114,7 @@ #define FIX_BASOP_2520_PARAMBIN_THRESHOLD_FIX /* Nokia: BASOP issue 2520: Fix wrong threshold in ParamBin */ #define FIX_BASOP_2510_UNNECESSARY_ASSERT /* Nokia: BASOP issue 2510: Fix by removing assert */ #define FIX_2515_TDREND_PORT_ERROR_SCALING /* Nokia: BASOP issue 2515: Fix port error by changing to correct scaling */ -//#define FIX_BASOP_2517_CLICK_IN_OMASA_LTV /* FhG: BASOP #2517: preserve precision by removing one-bit headroom from Q_min and allowing saturation during buffer scaling */ +#define FIX_BASOP_2517_CLICK_IN_OMASA_LTV /* FhG: BASOP #2517: preserve precision by removing one-bit headroom from Q_min and allowing saturation during buffer scaling */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 6c3679782..ecf72399e 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -517,7 +517,7 @@ void pre_proc_front_ivas_fx( #endif set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); new_inp_out_size = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ -#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ #else Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 1a67e9d90..059d68300 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -917,11 +917,11 @@ void ivas_compute_core_buffers_fx( } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { -#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */ #endif size_modified = modify_Fs_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ -#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ #else Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ @@ -972,7 +972,7 @@ void ivas_compute_core_buffers_fx( } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { -#if defined( NONBE_FIX_ISSUE_2206 ) && not defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */ #endif /* reconstruct past segment of input signal when switching from MDCT stereo */ -- GitLab From 2ab72551a3421d736df275a31a0de367fac0c3bc Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 15 Apr 2026 14:35:52 +0200 Subject: [PATCH 3/9] Replace Scale_sig() with scale_sig(). --- lib_enc/ivas_core_pre_proc_front_fx.c | 6 +----- lib_enc/ivas_core_pre_proc_fx.c | 11 +++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index ecf72399e..5b80778fb 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -483,11 +483,7 @@ void pre_proc_front_ivas_fx( *----------------------------------------------------------------*/ #ifdef NONBE_FIX_ISSUE_2206 -#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */ -#else scale_sig( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX, sub( st->q_inp, st->mem_q ) ); /* st->q_inp */ -#endif st->mem_q = st->q_inp; move16(); #else @@ -517,7 +513,7 @@ void pre_proc_front_ivas_fx( #endif set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); new_inp_out_size = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_12k8_fx + L_FRAME, INT_FS_12k8, mem_decim_dummy_fx, 0, &Q_new_inp, &mem_decim_size ); /* st->q_inp */ -#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#ifdef NONBE_FIX_ISSUE_2206 scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ #else Scale_sig( new_inp_12k8_fx + L_FRAME, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 059d68300..3033c0418 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -917,11 +917,11 @@ void ivas_compute_core_buffers_fx( } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { -#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#ifdef NONBE_FIX_ISSUE_2206 scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */ #endif size_modified = modify_Fs_fx( signal_in_fx, input_frame, input_Fs, new_inp_16k_fx, sr_core, st->mem_decim16k_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ -#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#ifdef NONBE_FIX_ISSUE_2206 scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ #else Scale_sig( new_inp_16k_fx, size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ @@ -931,12 +931,7 @@ void ivas_compute_core_buffers_fx( set16_fx( temp1F_icatdmResampBuf_fx, 0, L_FILT_MAX ); size_modified = modify_Fs_fx( temp1F_icatdmResampBuf_fx, NS2SA_FX2( input_Fs, DELAY_FIR_RESAMPL_NS ), input_Fs, new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), sr_core, mem_decim16k_dummy_fx, 0, &Q_tmp, &mem_decim16k_size ); /* Q0 */ #ifdef NONBE_FIX_ISSUE_2206 -#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#else scale_sig( new_inp_16k_fx + NS2SA_FX2( sr_core, FRAME_SIZE_NS ), size_modified, negate( Q_tmp ) ); /* scaling back to Q_old_inp_16k */ -#endif - // Scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( -1, Q_old_inp_16k ) ); /* Q(-1) */ Q_tmp = norm_arr( st->mem_decim16k_fx, mem_decim16k_size ); scale_sig( st->mem_decim16k_fx, mem_decim16k_size, Q_tmp ); @@ -972,7 +967,7 @@ void ivas_compute_core_buffers_fx( } ELSE IF( EQ_32( input_Fs, 32000 ) || EQ_32( input_Fs, 48000 ) ) { -#if defined( NONBE_FIX_ISSUE_2206 ) && !defined( FIX_BASOP_2517_CLICK_IN_OMASA_LTV ) +#ifdef NONBE_FIX_ISSUE_2206 scale_sig( st->mem_decim16k_fx, 2 * L_FILT_MAX, sub( Q_old_inp_16k, st->q_mem_decim16k_fx ) ); /* Q_old_inp_16k */ #endif /* reconstruct past segment of input signal when switching from MDCT stereo */ -- GitLab From d021ed311995b052c66cfc9713f4950d82af225a Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 15 Apr 2026 16:37:26 +0200 Subject: [PATCH 4/9] Improve locally signal precision for LP analysis to preserve LSP accuracy in low-Q SCE path --- lib_enc/ivas_core_pre_proc_front_fx.c | 37 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 5b80778fb..8e092d8f4 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -356,11 +356,7 @@ void pre_proc_front_ivas_fx( /* Take into account resampling memory for Q_min, and 1 bit headroom for resampling overshoot. */ IF( NE_32( input_Fs, INT_FS_12k8 ) ) { -#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Q_min = s_min( Q_min, add( st->mem_q, norm_arr( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX ) ) ); -#else Q_min = sub( s_min( Q_min, add( st->mem_q, norm_arr( st->mem_decim_fx_q_inp, 2 * L_FILT_MAX ) ) ), Q1 ); -#endif } #endif /* Limit Q_min to avoid rescale larger than 15 against Q-1 */ @@ -495,11 +491,7 @@ void pre_proc_front_ivas_fx( { new_inp_out_size = modify_Fs_fx( signal_in_fx, input_frame, input_Fs, new_inp_12k8_fx, INT_FS_12k8, st->mem_decim_fx_q_inp, ( st->max_bwidth == NB ), &Q_new_inp, &mem_decim_size ); /* st->q_inp */ #ifdef NONBE_FIX_ISSUE_2206 -#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ -#else scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ -#endif #else Scale_sig( new_inp_12k8_fx, new_inp_out_size, negate( Q_new_inp ) ); /* scaling back to st->q_inp*/ st->mem_q = st->q_inp; @@ -1161,7 +1153,36 @@ void pre_proc_front_ivas_fx( move16(); } +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Word16 inp_local[L_INP_12k8]; + Word16 offset = (Word16) ( inp_12k8_fx - old_inp_12k8_fx ); + Word16 norm_inp = norm_arr( old_inp_12k8_fx, L_INP_12k8 ); + Word16 Q_local; + + IF( GT_16( norm_inp, 0 ) ) + { + Copy_Scale_sig( old_inp_12k8_fx, inp_local, L_INP_12k8, norm_inp ); + Q_local = add( *Q_new, norm_inp ); + analy_lp_fx( inp_local + offset, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, Q_local, Q_r ); + IF( ener_fx != NULL ) + { + Word16 ener_shift = shl( norm_inp, 1 ); + IF( ener_shift > 0 ) + { + ener_fx[0] = L_shr_sat( ener_fx[0], ener_shift ); + move32(); + } + } + Q_r[0] = sub( Q_r[0], shl( norm_inp, 1 ) ); + move16(); + } + ELSE + { + analy_lp_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r ); + } +#else analy_lp_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r ); +#endif FOR( Word16 idx = 0; idx < M + 1; idx++ ) { -- GitLab From 6467c04ce75e5382a49b5170d16413546d8284de Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 15 Apr 2026 18:27:27 +0200 Subject: [PATCH 5/9] Remove ener_fx rescaling after analy_lp_fx() --- lib_enc/ivas_core_pre_proc_front_fx.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 8e092d8f4..54cc3f443 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1155,26 +1155,15 @@ void pre_proc_front_ivas_fx( #ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV Word16 inp_local[L_INP_12k8]; + Word16 Q_local; Word16 offset = (Word16) ( inp_12k8_fx - old_inp_12k8_fx ); Word16 norm_inp = norm_arr( old_inp_12k8_fx, L_INP_12k8 ); - Word16 Q_local; IF( GT_16( norm_inp, 0 ) ) { Copy_Scale_sig( old_inp_12k8_fx, inp_local, L_INP_12k8, norm_inp ); Q_local = add( *Q_new, norm_inp ); analy_lp_fx( inp_local + offset, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, Q_local, Q_r ); - IF( ener_fx != NULL ) - { - Word16 ener_shift = shl( norm_inp, 1 ); - IF( ener_shift > 0 ) - { - ener_fx[0] = L_shr_sat( ener_fx[0], ener_shift ); - move32(); - } - } - Q_r[0] = sub( Q_r[0], shl( norm_inp, 1 ) ); - move16(); } ELSE { -- GitLab From 5ed0ee6822085bf74bd35b31cfb4e54f0d031b30 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 15 Apr 2026 20:32:10 +0200 Subject: [PATCH 6/9] Normalize find_targets_ivas_fx() inputs locally to improve precision --- lib_enc/enc_gen_voic_fx.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 1ca20c9a6..c1b947d1e 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -247,8 +247,39 @@ void encod_gen_voic_fx( } ELSE { +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Word16 min_scf = norm_arr( (Word16 *) ( speech_fx + i_subfr_fx - M ), M ); + min_scf = s_min( min_scf, norm_arr( hLPDmem->mem_syn, M ) ); + min_scf = s_min( min_scf, norm_arr( (Word16 *) ( res_fx + i_subfr_fx ), L_SUBFR ) ); + IF( hLPDmem->mem_w0 != 0 ) + { + min_scf = s_min( min_scf, norm_s( hLPDmem->mem_w0 ) ); + } + + IF( GT_16( min_scf, 0 ) ) + { + Word16 speech_local[L_FRAME16k]; + Word16 mem_syn_local[M]; + Word16 res_local[L_FRAME16k]; + Word16 mem_w0_local = shl( hLPDmem->mem_w0, min_scf ); + Copy_Scale_sig( speech_fx, speech_local, L_frame, min_scf ); + Copy_Scale_sig( hLPDmem->mem_syn, mem_syn_local, M, min_scf ); + Copy_Scale_sig( res_fx, res_local, L_frame, min_scf ); + find_targets_ivas_fx( speech_local, mem_syn_local, i_subfr_fx, &mem_w0_local, p_Aq_fx, + res_local, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + scale_sig( xn_fx, L_SUBFR, negate( min_scf ) ); + scale_sig( cn_fx, L_SUBFR, negate( min_scf ) ); + hLPDmem->mem_w0 = shr( mem_w0_local, min_scf ); + } + ELSE + { + find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, + res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); + } +#else find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); +#endif q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ -- GitLab From 022113be106ff7b438e11374f50b837eb9d32304 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 15 Apr 2026 20:36:58 +0200 Subject: [PATCH 7/9] Remove (Word16 *) cast from norm_arr inputs --- lib_enc/enc_gen_voic_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index c1b947d1e..7c17f8a47 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -248,9 +248,9 @@ void encod_gen_voic_fx( ELSE { #ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Word16 min_scf = norm_arr( (Word16 *) ( speech_fx + i_subfr_fx - M ), M ); + Word16 min_scf = norm_arr( speech_fx + i_subfr_fx - M, M ); min_scf = s_min( min_scf, norm_arr( hLPDmem->mem_syn, M ) ); - min_scf = s_min( min_scf, norm_arr( (Word16 *) ( res_fx + i_subfr_fx ), L_SUBFR ) ); + min_scf = s_min( min_scf, norm_arr( res_fx + i_subfr_fx, L_SUBFR ) ); IF( hLPDmem->mem_w0 != 0 ) { min_scf = s_min( min_scf, norm_s( hLPDmem->mem_w0 ) ); -- GitLab From 03f2b39428e8d2ec53852f3d03007cea1a126ef6 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 16 Apr 2026 09:29:31 +0200 Subject: [PATCH 8/9] Normalize inputs of calc_residu_fx() and revert normalization of inputs in find_targets_ivas_fx(). --- lib_enc/acelp_core_enc_fx.c | 15 +++++++++++++++ lib_enc/enc_gen_voic_fx.c | 31 ------------------------------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 964f90f78..26ae97c11 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -666,7 +666,22 @@ ivas_error acelp_core_enc_fx( * Calculation of LP residual (filtering through A[z] filter) *---------------------------------------------------------------*/ +#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV + Word16 scf = norm_arr( inp - M, add( st->L_frame, M ) ); + IF( GT_16( scf, 0 ) ) + { + Word16 inp_local_acelp[L_FRAME16k + M]; + Copy_Scale_sig( inp - M, inp_local_acelp, add( st->L_frame, M ), scf ); + calc_residu_fx( st, inp_local_acelp + M, res_fx, Aq ); + scale_sig( res_fx, st->L_frame, negate( scf ) ); + } + ELSE + { + calc_residu_fx( st, inp, res_fx, Aq ); + } +#else calc_residu_fx( st, inp, res_fx, Aq ); +#endif calculate_hangover_attenuation_gain_fx( st, &att_fx, vad_hover_flag ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 7c17f8a47..1ca20c9a6 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -247,39 +247,8 @@ void encod_gen_voic_fx( } ELSE { -#ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Word16 min_scf = norm_arr( speech_fx + i_subfr_fx - M, M ); - min_scf = s_min( min_scf, norm_arr( hLPDmem->mem_syn, M ) ); - min_scf = s_min( min_scf, norm_arr( res_fx + i_subfr_fx, L_SUBFR ) ); - IF( hLPDmem->mem_w0 != 0 ) - { - min_scf = s_min( min_scf, norm_s( hLPDmem->mem_w0 ) ); - } - - IF( GT_16( min_scf, 0 ) ) - { - Word16 speech_local[L_FRAME16k]; - Word16 mem_syn_local[M]; - Word16 res_local[L_FRAME16k]; - Word16 mem_w0_local = shl( hLPDmem->mem_w0, min_scf ); - Copy_Scale_sig( speech_fx, speech_local, L_frame, min_scf ); - Copy_Scale_sig( hLPDmem->mem_syn, mem_syn_local, M, min_scf ); - Copy_Scale_sig( res_fx, res_local, L_frame, min_scf ); - find_targets_ivas_fx( speech_local, mem_syn_local, i_subfr_fx, &mem_w0_local, p_Aq_fx, - res_local, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - scale_sig( xn_fx, L_SUBFR, negate( min_scf ) ); - scale_sig( cn_fx, L_SUBFR, negate( min_scf ) ); - hLPDmem->mem_w0 = shr( mem_w0_local, min_scf ); - } - ELSE - { - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, - res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); - } -#else find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx, res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx ); -#endif q_h1 = sub( 14, norm_s( h1_fx[0] ) ); Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ -- GitLab From af68aa783ed4139783b6657d996cc3446b3a8a5b Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 17 Apr 2026 17:44:20 +0200 Subject: [PATCH 9/9] Add two-bit headroom to the normalization of inputs in calc_residu_fx(). --- lib_enc/acelp_core_enc_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 26ae97c11..9869b1c69 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -667,8 +667,9 @@ ivas_error acelp_core_enc_fx( *---------------------------------------------------------------*/ #ifdef FIX_BASOP_2517_CLICK_IN_OMASA_LTV - Word16 scf = norm_arr( inp - M, add( st->L_frame, M ) ); - IF( GT_16( scf, 0 ) ) + Word16 scf = sub( norm_arr( inp - M, add( st->L_frame, M ) ), 2 ); + test(); + IF( NE_16( st->element_mode, EVS_MONO ) && GT_16( scf, 0 ) ) { Word16 inp_local_acelp[L_FRAME16k + M]; Copy_Scale_sig( inp - M, inp_local_acelp, add( st->L_frame, M ), scf ); -- GitLab