From 493fe4fa53af2bb9c8f0138e6ede394d1b36aa88 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 30 Aug 2024 11:59:11 -0400 Subject: [PATCH 1/2] possible fix for 869 --- lib_com/options.h | 4 ++++ lib_dec/gain_dec_fx.c | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6601c0d5e..2c69ef155 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -175,6 +175,10 @@ #define FIX_860_FER_CRASH /* VA: fix crash issues caused by saturation within shl */ #define FIX_961_CRASH_DIV_L /* VA: fix to potential crash in div_l when index is <= 0 */ + +#define FIX_869_WRONG_UVGAIN_STEP /* VA: Fix wrong decoding of uv gain quantizer for td-stereo*/ + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 0142a6179..42212ed22 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -1658,11 +1658,15 @@ Word32 gain_dec_gaus_fx( /* o : quantized codebook { Word16 stepSize, gain, expg, frac, expi, tmp_igi; Word32 L_tmp, L_enr_q, L_gain; - +#ifdef FIX_869_WRONG_UVGAIN_STEP + Word16 stepSize_Exp; + stepSize_Exp = 14; + move16(); +#endif /*------------------------------------------------------------------------------------------* * Quantize linearly the log E *------------------------------------------------------------------------------------------*/ - +#ifndef FIX_869_WRONG_UVGAIN_STEP stepSize = shl( sub( topBound, lowBound ), sub( 14, bits ) ); /* Q14 */ /*------------------------------------------------------------------------------------------* @@ -1673,7 +1677,22 @@ Word32 gain_dec_gaus_fx( /* o : quantized codebook L_enr_q = L_mult( index, stepSize ); /* Q0 * Q14 -> Q15 */ L_enr_q = L_shl( L_enr_q, 9 ); /* Q15 -> Q24 */ L_enr_q = L_add( L_enr_q, L_shl( L_deposit_h( lowBound ), 8 ) ); /* Q24 */ +#else + if ( EQ_16( bits, 6 ) ) + { + stepSize_Exp = sub( stepSize_Exp, 1 ); + } + stepSize = shl( sub( topBound, lowBound ), sub( stepSize_Exp, bits )); /* QstepSize_Exp */ + /*------------------------------------------------------------------------------------------* + * Gaussian codebook gain + *------------------------------------------------------------------------------------------*/ + + /* enr_q = (float)index*stepSize ,lowBound); */ + L_enr_q = L_mult( index, stepSize ); /* Q0 * QstepSize_Exp -> QstepSize_Exp+1 */ + L_enr_q = L_shl( L_enr_q, sub( 24 - 1, stepSize_Exp ) ); /* QstepSize_Exp+1 -> Q24 */ + L_enr_q = L_add( L_enr_q, L_shl( L_deposit_h( lowBound ), 8 ) ); /* Q24 */ +#endif /*------------------------------------------------------------* * gain = pow(10.0, enr/20) * = pow(2, 3.321928*enr/20) -- GitLab From f957bb571259d5e94ae3baf4a3c2221a05a26b4c Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 30 Aug 2024 12:03:55 -0400 Subject: [PATCH 2/2] fix clang --- lib_dec/gain_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 42212ed22..61ef5f11a 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -1682,7 +1682,7 @@ Word32 gain_dec_gaus_fx( /* o : quantized codebook { stepSize_Exp = sub( stepSize_Exp, 1 ); } - stepSize = shl( sub( topBound, lowBound ), sub( stepSize_Exp, bits )); /* QstepSize_Exp */ + stepSize = shl( sub( topBound, lowBound ), sub( stepSize_Exp, bits ) ); /* QstepSize_Exp */ /*------------------------------------------------------------------------------------------* * Gaussian codebook gain @@ -1710,7 +1710,7 @@ Word32 gain_dec_gaus_fx( /* o : quantized codebook #ifdef BASOP_NOGLOB L_gain = L_shl_sat( L_gain, expg ); /* In Q16*/ #else - L_gain = L_shl( L_gain, expg ); /* In Q16*/ + L_gain = L_shl( L_gain, expg ); /* In Q16*/ #endif /* *norm_gain_code = gain / *inv_gain_inov;*/ expi = norm_s( inv_gain_inov ); -- GitLab