From 293232a32a8eb38c10ddca7b80ae9704a777970d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 10 Oct 2025 11:40:37 -0400 Subject: [PATCH 1/2] Fix proposal for 2081 --- lib_com/options.h | 3 +++ lib_enc/enc_tran_fx.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c941842df..3f91af032 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,9 @@ #define FIX_2021_BANDWIDTH_EXTENSION_PROBLEM /* FhG: increase cldfb buffer precision*/ #define FIX_2085_FLOATING_POINT_LEFTOVERS /* FhG: convert floating-point leftovers in ivas_dirac_config_fx() */ + +#define FIX_2081_REVISE_H1_SCALING /* VA: accommodate for H1 overshoot that was causing assert in set_impule. Not BE with MASA on LTV with bitrate switching for only 2 instances */ + /* #################### Start BASOP porting switches ############################ */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index c95f07e41..3affc1fcb 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -460,7 +460,11 @@ Word16 encod_tran_ivas_fx( Word16 tc_subfr, /* i/o: TC subframe classification Q0*/ Word16 position, /* i : maximum of residual signal index Q0*/ Word16 *unbits, /* i/o: number of unused bits Q0*/ - const Word16 shift, /* i : Scaling to get 12 bits */ +#ifdef FIX_2081_REVISE_H1_SCALING + const Word16 shift_r, /* i : Scaling to get 12 bits */ +#else + const Word16 shift, /* i : Scaling to get 12 bits */ +#endif const Word16 Q_new /* i : Input scaling */ ) { @@ -494,6 +498,9 @@ Word16 encod_tran_ivas_fx( Word16 shift_wsp; Word32 L_tmp; Word16 q_h1; +#ifdef FIX_2081_REVISE_H1_SCALING + Word16 shift, tmp; +#endif #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; @@ -504,6 +511,11 @@ Word16 encod_tran_ivas_fx( SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; +#ifdef FIX_2081_REVISE_H1_SCALING + shift = shift_r; /* for IVAS, shift_r is always 0 */ + /* will be reusing the EVS shift strategy later on to allow of H1 overshoot */ + move16(); +#endif L_frame_fx = st_fx->L_frame; move16(); @@ -572,9 +584,21 @@ Word16 encod_tran_ivas_fx( res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); +#ifdef FIX_2081_REVISE_H1_SCALING + tmp = sub( 14, norm_arr( h1, L_SUBFR ) ); + shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ + shift_wsp = add( Q_new, shift ); + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } +#endif Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ +#ifdef FIX_2081_REVISE_H1_SCALING + Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) ); +#else Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); - +#endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); -- GitLab From 4dfec78ebe52221c4982eb6285dba4d74796559c Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 10 Oct 2025 11:45:13 -0400 Subject: [PATCH 2/2] Fix clang-format --- lib_enc/enc_tran_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 3affc1fcb..bce044600 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -461,11 +461,11 @@ Word16 encod_tran_ivas_fx( Word16 position, /* i : maximum of residual signal index Q0*/ Word16 *unbits, /* i/o: number of unused bits Q0*/ #ifdef FIX_2081_REVISE_H1_SCALING - const Word16 shift_r, /* i : Scaling to get 12 bits */ + const Word16 shift_r, /* i : Scaling to get 12 bits */ #else - const Word16 shift, /* i : Scaling to get 12 bits */ + const Word16 shift, /* i : Scaling to get 12 bits */ #endif - const Word16 Q_new /* i : Input scaling */ + const Word16 Q_new /* i : Input scaling */ ) { Word16 xn[L_SUBFR]; /* Target vector for pitch search */ @@ -500,7 +500,7 @@ Word16 encod_tran_ivas_fx( Word16 q_h1; #ifdef FIX_2081_REVISE_H1_SCALING Word16 shift, tmp; -#endif +#endif #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; @@ -586,7 +586,7 @@ Word16 encod_tran_ivas_fx( q_h1 = sub( 14, norm_s( h1[0] ) ); #ifdef FIX_2081_REVISE_H1_SCALING tmp = sub( 14, norm_arr( h1, L_SUBFR ) ); - shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ + shift = sub( q_h1, tmp ); /* shift is initialized to shift_r ( to 0) at the beginning of the scope, re-compute shift_wsp in case it has changed */ shift_wsp = add( Q_new, shift ); if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { -- GitLab