Commit 8f8da449 authored by vaillancour's avatar vaillancour
Browse files

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

parent 5b9eecaf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -223,7 +223,11 @@ void tcx_arith_scale_envelope(

        tmp = norm_l(env[k]);
        tmp2 = sub(15, tmp);
#ifdef BASOP_NOGLOB
        tmp = Inv16(round_fx_o(L_shl_o(env[k], tmp, &Overflow), &Overflow), &tmp2);
#else
        tmp = Inv16(round_fx(L_shl(env[k], tmp)), &tmp2);
#endif
        ienv[k] = L_shl(L_deposit_h(tmp), sub(tmp2, 15)); /* Q16 */                 move32();
        mean = L_add(mean, ienv[k]);
    }
+15 −5
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */
{
    Word32 tcorr, tener, Lgain;
    Word16 exp_c, exp_e, exp, tmp;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif

    tcorr = L_deposit_l(0);
    tener = L_deposit_l(0);
@@ -34,9 +36,13 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */
    tcorr = Dot_product16HQ( 0, x, y,  n, &exp_c );
    tener = Dot_productSq16HQ( 0, y, n, &exp_e );

#ifdef BASOP_NOGLOB
    BASOP_Util_Divide_MantExp(round_fx_o(tcorr, &Overflow), exp_c, s_max(round_fx_o(tener, &Overflow),1), exp_e, &tmp,&exp);
    Lgain = L_shl_o(L_deposit_l(tmp)/*Q15*/, add(1, exp), &Overflow)/*Q16*/;
#else
    BASOP_Util_Divide_MantExp(round_fx(tcorr), exp_c, s_max(round_fx(tener),1), exp_e, &tmp,&exp);
    Lgain = L_shl(L_deposit_l(tmp)/*Q15*/,add(1,exp))/*Q16*/;

#endif
    return Lgain;
}

@@ -48,7 +54,9 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */
{
    Word32 tcorr, tener, Lgain;
    Word16 m_corr, m_ener, negative, Q_corr, Q_ener;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    negative = 0;
    move16();

@@ -68,7 +76,6 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */
    BASOP_SATURATE_WARNING_OFF /*tcorr max be negative maxvall -  not critical*/
    tcorr = L_abs(tcorr);
    BASOP_SATURATE_WARNING_ON

    m_corr = extract_h(tcorr);

    m_ener = extract_h(tener);
@@ -90,8 +97,11 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */

    Q_corr = sub(Q_corr,Q_ener);

#ifdef BASOP_NOGLOB
    Lgain = L_shl_o(L_deposit_l(m_corr), add(Q_corr, 1), &Overflow); /* Lgain in Q16 */
#else
    Lgain = L_shl(L_deposit_l(m_corr), add(Q_corr, 1)); /* Lgain in Q16 */

#endif
    if (negative != 0)
    {
        Lgain = L_negate(Lgain);           /* Lgain in Q16 */
+7 −1
Original line number Diff line number Diff line
@@ -3311,7 +3311,9 @@ Word16 root_search_fx( Word16 low,
    Word32 v_high, vh;
    Word32 Ltemp, L_tmp1, L_tmp, Ltmp;
    Word16 exp1, tmp;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    v_high = polynomial_eval_fx( high, coef, order ); /*  v_high has the value at high index */

    IF ( v_high != 0 )
@@ -3379,7 +3381,11 @@ Word16 root_search_fx( Word16 low,
            exp1 = sub(30 - 25, exp1);
            tmp = div_s( 16384, tmp );              /* 15+exp1 */
            Ltmp = Mult_32_16( *v_low, tmp );       /* 15+exp1+25-15 */
#ifdef BASOP_NOGLOB
            Ltemp = L_shl_o( Ltmp, ( 6 - exp1 ), &Overflow );    /* Q31 */
#else
            Ltemp = L_shl( Ltmp, ( 6 - exp1 ) );    /* Q31 */
#endif
            if ( LT_32( *v_low, vh ))
            {
                Ltemp = L_negate( Ltemp );