Commit 151ed246 authored by Manuel Jander's avatar Manuel Jander
Browse files

Fix shl() saturation crash in threshold decision by saturating with shl_sat()....

Fix shl() saturation crash in threshold decision by saturating with shl_sat(). Crash condition: st->hTdCngEnc->last_idx_ener = 1.
parent 6713d9ed
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1564,7 +1564,11 @@ static void shb_CNG_encod_fx(
                Word16 tmp, tmp1, tmp2, scale, exp1, exp2, ener_mid_dec_thr_e;
                tmp = BASOP_Util_Divide1616_Scale( st->hTdCngEnc->last_idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0
                scale = add( scale, ( 15 - 0 ) );
#ifdef NONBE_FIX_ISSUE_2206
                tmp = sub( tmp, shl_sat( 6, sub( Q15, scale ) ) ); /* Saturate, because the computation goes into a threshold decision. */
#else
                tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) );
#endif
                tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp1 );
                exp1 = add( exp1, ( scale - 0 ) );

@@ -1572,7 +1576,11 @@ static void shb_CNG_encod_fx(

                tmp = BASOP_Util_Divide1616_Scale( idx_ener, 22938, &scale ); // 0.7 in Q15 ->exp 0
                scale = add( scale, ( 15 - 0 ) );
#ifdef NONBE_FIX_ISSUE_2206
                tmp = sub( tmp, shl_sat( 6, sub( Q15, scale ) ) ); /* Saturate, because the computation goes into a threshold decision. */
#else
                tmp = sub( tmp, shl( 6, sub( Q15, scale ) ) );
#endif
                tmp1 = BASOP_Util_Divide1616_Scale( tmp, 3277, &exp2 );
                exp2 = add( exp2, ( scale - 0 ) );