diff --git a/lib_com/options.h b/lib_com/options.h index 6601c0d5ec5dea34b95ab2f6c65c20ea8bb1114e..2c69ef155a9b17d6608ff0687d69e2ab1921e3cd 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 0142a617945bf62e7b063ec3ee3deb7de60da41d..61ef5f11adf59ecd52b000895a7730b5372c41d8 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) @@ -1691,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 );