Commit 74fefa3a authored by vaillancour's avatar vaillancour
Browse files

fix sat/overflow in case of JMB

parent ac580f71
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -42,8 +42,11 @@ static Word32 calc_gain_code(Word16 g_code, Word16 gcode0, Word16 exp_gcode0)

    L_tmp = L_mult(g_code, gcode0);            /* Q11*Q15 -> Q27 */
    exp_gcode0 = add(exp_gcode0,-11);
#ifdef BASOP_NOGLOB 
    L_tmp = L_shl_sat(L_tmp, exp_gcode0);       /*   Q27 -> Q16 */
#else
    L_tmp = L_shl(L_tmp, exp_gcode0);       /*   Q27 -> Q16 */

#endif

    return L_tmp;
}
@@ -79,8 +82,11 @@ static void Mode2_gain_dec_mless(
    /**gain_inov = 1.0f / (float)sqrt( ( dot_product( code, code, lcode ) + 0.01f ) / lcode);*/
    L_tmp = calc_gain_inov(code, lcode, &L_tmp1, &exp_L_tmp1);
    move16();
#ifdef BASOP_NOGLOB 
    *gain_inov = round_fx_sat(L_shl_sat(L_tmp, 15-3));  /* gain_inov in Q12 */
#else
    *gain_inov = round_fx(L_shl(L_tmp, 15-3));  /* gain_inov in Q12 */

#endif
    /*-----------------------------------------------------------------*
     * Select the gains quantization table
     *-----------------------------------------------------------------*/
+9 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ static void calcGainc2(Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32* lp_gai
    Word16 i, cnt, tmp16 , tmp_e, tmp2_e;
    Word32 L_c, L_acc, L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;      /* TBV !!!!! */
    Flag Overflow = 0;      
    Flag Carry = 0;
#endif

@@ -96,9 +96,17 @@ static void calcGainc2(Word16 *exc, Word16 Q_exc, Word16 L_subfr, Word32* lp_gai
    FOR (i=0; i < cnt; i++)
    {
        /* *gainc += ( exc[i-2*L_subfr] ) * ( exc[i-2*L_subfr]); */
#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */
        L_acc = L_macNs_co(L_acc, exc[i-2*L_subfr] /*Q1*/, exc[i-2*L_subfr] /*Q1*/, &Carry, &Overflow); /*Q3*/
#else
        L_acc = L_macNs(L_acc, exc[i-2*L_subfr] /*Q1*/, exc[i-2*L_subfr] /*Q1*/); /*Q3*/
#endif
        Overflow = 0;
#ifdef BASOP_NOGLOB /* Critical Carry/Overflow */
        L_c = L_macNs_co(L_c,0,0, &Carry, &Overflow); /* Accumulate Carrys */
#else
        L_c = L_macNs(L_c,0,0); /* Accumulate Carrys */
#endif
        Carry = 0;
    }