Commit 493fe4fa authored by vaillancour's avatar vaillancour
Browse files

possible fix for 869

parent b96b632d
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 */
+21 −2
Original line number Diff line number Diff line
@@ -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)