From 7c9904843169b660684ef9b2ef5dbf1d1ce8c4ee Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 18 Jul 2024 11:15:41 -0400 Subject: [PATCH 1/2] Proposed fix for 810 --- lib_com/options.h | 1 + lib_dec/dec_tran_fx.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d4311a564..0c7d4b051 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */ #define FIX_802_1137_1137_GSC_IVAS_FXFLT_DECODING /* VA: ISSUES 802 and 1137 Made sure that float and fixed point GCS bit allocation is the same during IVAS modes */ +#define FIX_810_PREVENT_UNECESSARY_SAT_IN_TC /* VA : Prevent an unnecessary saturation that can happen in TC, have a minimal impact on most cases. Significant improvement for the last segment of LTV when TC is triggered */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 9d2e808a7..1c79bb0fe 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -6,6 +6,14 @@ #include "cnst.h" /* Common constants */ #include "prot_fx.h" /* Function prototypes */ #ifdef IVAS_FLOAT_FIXED + +#ifdef FIX_810_PREVENT_UNECESSARY_SAT_IN_TC +#define Q3_4 ( 4 << Q3 ) +#define Q3_17 ( 17 << Q3 ) +#define Q16_8 ( 8 << Q16 ) +#define Q16_30 ( 30 << Q16 ) +#endif + /*======================================================================*/ /* FUNCTION : decod_tran_fx() */ /*----------------------------------------------------------------------*/ @@ -177,10 +185,29 @@ void decod_tran_fx( /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ - +#ifdef FIX_810_PREVENT_UNECESSARY_SAT_IN_TC + test(); + test(); + test(); + IF ( GT_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( add( i_subfr, L_SUBFR ), tc_subfr_fx ) && LT_16( i_subfr, tc_subfr_fx ) && GT_16( st_fx->Q_subfr[0], 4 ) ) ) + { + test(); + test(); + test(); + IF( GE_16( st_fx->Q_subfr[0], 7 ) && LE_32( st_fx->lp_gainc_fx, Q3_4 ) && LE_32( norm_gain_code_fx, Q16_8 ) ) + { + st_fx->Q_subfr[0] = s_min( st_fx->Q_subfr[0], 4 ); + move16(); + } + ELSE IF( LE_32( st_fx->lp_gainc_fx, Q3_17 ) && LE_32( L_sub( gain_code_fx, norm_gain_code_fx ), Q16_30 ) ) + { + st_fx->Q_subfr[0] = s_min( 4, sub( st_fx->Q_subfr[0], 2 ) ); + move16(); + } + } +#endif IF( EQ_16( L_frame_fx, L_FRAME ) ) /* Rescaling for 12.8k core */ { - Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr], &bwe_exc_fx[shr( imult1616( i_subfr, 2 * HIBND_ACB_L_FAC ), 1 )], hGSCDec->last_exc_dct_in_fx, L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr, st_fx->coder_type ); } -- GitLab From 43223550e361131711e84def1641a32861cf01bc Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 18 Jul 2024 11:35:39 -0400 Subject: [PATCH 2/2] fix formating --- lib_dec/dec_tran_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index 1c79bb0fe..4d8767e47 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -8,10 +8,10 @@ #ifdef IVAS_FLOAT_FIXED #ifdef FIX_810_PREVENT_UNECESSARY_SAT_IN_TC -#define Q3_4 ( 4 << Q3 ) +#define Q3_4 ( 4 << Q3 ) #define Q3_17 ( 17 << Q3 ) -#define Q16_8 ( 8 << Q16 ) -#define Q16_30 ( 30 << Q16 ) +#define Q16_8 ( 8 << Q16 ) +#define Q16_30 ( 30 << Q16 ) #endif /*======================================================================*/ @@ -189,7 +189,7 @@ void decod_tran_fx( test(); test(); test(); - IF ( GT_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( add( i_subfr, L_SUBFR ), tc_subfr_fx ) && LT_16( i_subfr, tc_subfr_fx ) && GT_16( st_fx->Q_subfr[0], 4 ) ) ) + IF( GT_16( st_fx->element_mode, EVS_MONO ) && ( GE_16( add( i_subfr, L_SUBFR ), tc_subfr_fx ) && LT_16( i_subfr, tc_subfr_fx ) && GT_16( st_fx->Q_subfr[0], 4 ) ) ) { test(); test(); -- GitLab