Commit 7152f85c authored by vaillancour's avatar vaillancour
Browse files

Fix more overflows with that command line : 7200 16 stv16c.INP

parent 8f8da449
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include "stl.h"
#include "math_op.h"
#include "basop32.h"

/*****************************************************************************
 *                                                                           *
@@ -122,11 +123,17 @@ Word32 L_Comp (Word16 hi, Word16 lo)
Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
{
    Word32 L_32;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;

    L_32 = L_mult (hi1, hi2);
    L_32 = L_mac_o (L_32, mult (hi1, lo2), 1, &Overflow);
    L_32 = L_mac_o (L_32, mult (lo1, hi2), 1, &Overflow);
#else
    L_32 = L_mult (hi1, hi2);
    L_32 = L_mac (L_32, mult (hi1, lo2), 1);
    L_32 = L_mac (L_32, mult (lo1, hi2), 1);

#endif
    return (L_32);
}

@@ -154,11 +161,16 @@ Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
Word32 Mac_32 (Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
{
    Word32 L_32;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
    L_32 = L_mac_o (L_num, hi1, hi2, &Overflow);
    L_32 = L_mac_o(L_32, mult (hi1, lo2), 1, &Overflow);
    L_32 = L_mac_o(L_32, mult (lo1, hi2), 1, &Overflow);
#else
    L_32 = L_mac (L_num, hi1, hi2);
    L_32 = L_mac (L_32, mult (hi1, lo2), 1);
    L_32 = L_mac (L_32, mult (lo1, hi2), 1);

#endif
    return (L_32);
}

@@ -185,9 +197,14 @@ Word32 Mac_32 (Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
Word32 Sqr_32 (Word16 hi, Word16 lo)
{
    Word32 L_32;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
    L_32 = L_mult_o (hi, hi, &Overflow);
    L_32 = L_mac_o (L_32, mult (hi, lo), 2, &Overflow);
#else 
    L_32 = L_mult(hi, hi);
    L_32 = L_mac(L_32, mult(hi, lo), 2);
#endif

    return (L_32);
}
+4 −0
Original line number Diff line number Diff line
@@ -413,7 +413,11 @@ Word16 E_LPC_lev_dur_stab(const Word16 Rh[], const Word16 Rl[], Word16 A[],
    FOR (i = 1; i <= order; i++)
    {
        t0 = L_Comp(Ah[i], Al[i]);
#ifdef BASOP_NOGLOB
        A[i] = round_fx_o(L_shl_o(t0, k, &Overflow), &Overflow);
#else
        A[i] = round_fx(L_shl(t0, k));
#endif
    }

    BASOP_SATURATE_WARNING_ON
+4 −0
Original line number Diff line number Diff line
@@ -577,7 +577,11 @@ static void spectautocorr_fx(

        /*r[1] = L_mac(r[1], x[i-1], gn);*/
        Mpy_32_16_ss(gn, x[i-1], &mh, &ml);
#ifdef BASOP_NOGLOB
        r[1] = L_add_o(r[1], mh, &Overflow);
#else
        r[1] = L_add(r[1], mh);
#endif
        move32();
        c[1] = x[i-1];
        move16();
+2 −1
Original line number Diff line number Diff line
@@ -3868,10 +3868,11 @@ void prep_tbe_exc_fx(
            L_tmp = L_mac( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] ); /*Q15+Q_exc */
#ifdef BASOP_NOGLOB
            L_tmp = L_shl_o( L_tmp, 1 , &Overflow); /*16+Q_exc */ /* saturation can occur here */
            bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o(L_tmp, &Overflow);  /*Q_exc */
#else /* BASOP_NOGLOB */
            L_tmp = L_shl( L_tmp, 1 ); /*16+Q_exc */ /* saturation can occur here */
#endif /* BASOP_NOGLOB */
            bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx(L_tmp);  /*Q_exc */
#endif /* BASOP_NOGLOB */
        }
    }
    ELSE
+15 −2
Original line number Diff line number Diff line
@@ -233,7 +233,9 @@ void gain_enc_mless_fx(
    Word16 exp1, exp2;
    Word16 exp_num, exp_den, exp_div, frac_den;
    Word32 L_frac_num, L_frac_den, L_div;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    /*-----------------------------------------------------------------*
     * calculate the rest of the correlation coefficients
     * c2 = <y2,y2>, c3 = -2<xn,y2>, c4 = 2<y1,y2>
@@ -379,8 +381,11 @@ void gain_enc_mless_fx(
        L_div = Mult_32_16(L_frac_num,tmp); /*Q(30-exp)*/
        exp_div = sub(exp_num,exp_den);

#ifdef BASOP_NOGLOB
        *gain_pit = round_fx_o(L_shl_o(L_div,add(exp,exp_div), &Overflow), &Overflow); /*Q14*/
#else
        *gain_pit = round_fx(L_shl(L_div,add(exp,exp_div))); /*Q14*/

#endif
        L_tmp1 = L_shr(L_mult(coeff[1],coeff[4]),2); /*Q31*/
        exp1 = add(exp_coeff[1], exp_coeff[4]);

@@ -402,7 +407,11 @@ void gain_enc_mless_fx(
        L_div = Mult_32_16(L_frac_num,tmp); /*Q(30-exp)*/
        exp_div = sub(exp_num,exp_den);

#ifdef BASOP_NOGLOB
        *gain_code = L_shl_o(L_div,sub(add(exp,exp_div),14), &Overflow);
#else
        *gain_code = L_shl(L_div,sub(add(exp,exp_div),14));
#endif
        move32();/*Q16*/

        *gain_pit = s_max(G_PITCH_MIN_TC192_Q14,s_min(*gain_pit,G_PITCH_MAX_TC192_Q14));
@@ -430,7 +439,11 @@ void gain_enc_mless_fx(
        index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg );
        push_indice_fx( hBstr, IND_GAIN_CODE, index, nBits2 );
        L_tmp = L_mult(gain_code16,gcode0); /*Q0*Q0 -> Q1*/
#ifdef BASOP_NOGLOB
        *gain_code = L_shl_o(L_tmp,add(add(expg,exp_gcode0),15), &Overflow); /*Q16*/
#else
        *gain_code = L_shl(L_tmp,add(add(expg,exp_gcode0),15)); /*Q16*/
#endif
    }
    ELSE
    {