diff --git a/lib_com/options.h b/lib_com/options.h index d4311a5640b8a440cf5bae73c7d0556a68cd64b6..0c7d4b051dd1a3f9e8bd1108f85f4436c332c0bf 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 9d2e808a70e3bd37402f5b74ffc002b51cb85998..4d8767e475e737c6a2eb2e4fd98c2667483d9683 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 ); }