Commit ac40e16f authored by vaillancour's avatar vaillancour
Browse files

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

parent c729ff03
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -245,11 +245,24 @@ Word32 Energy_scale( /* (o) : Q31: normalized result (1 <
        FOR (i = 1; i < lg; i++)
        {
            tmp = mult_r(x[i], sft);
#ifdef BASOP_NOGLOB
            L_sum = L_mac_o(L_sum, tmp, tmp, &Overflow);
#else
            L_sum = L_mac(L_sum, tmp, tmp);
#endif
        }
    }
    IF (expi > 0)
    {
#ifdef BASOP_NOGLOB
        tmp = shl_o(x[0], expi, &Overflow);
        L_sum = L_mac_o(1, tmp, tmp, &Overflow);
        FOR (i = 1; i < lg; i++)
        {
            tmp = shl_o(x[i], expi, &Overflow);
            L_sum = L_mac_o(L_sum, tmp, tmp, &Overflow);
        }
#else
        tmp = shl(x[0], expi);
        L_sum = L_mac(1, tmp, tmp);
        FOR (i = 1; i < lg; i++)
@@ -257,6 +270,7 @@ Word32 Energy_scale( /* (o) : Q31: normalized result (1 <
            tmp = shl(x[i], expi);
            L_sum = L_mac(L_sum, tmp, tmp);
        }
#endif
    }

    /* Normalize acc in Q31 */
+15 −1
Original line number Diff line number Diff line
@@ -28,10 +28,14 @@ void Residu3_lc_fx(
    Word16 i, j;
    Word32 s;
    Word16 q;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    q = add( norm_s(a[0]), 1 );
    if (shift > 0)
    {
        q = add(q, shift);
    }
    *y++ = shl(x[0], shift);
    move16();

@@ -44,8 +48,13 @@ void Residu3_lc_fx(
            s = L_mac(s, x[i-j], a[j]);
        }

#ifdef BASOP_NOGLOB
        s = L_shl_o(s, q, &Overflow);
        *y++ = round_fx_o(s, &Overflow);
#else
        s = L_shl(s, q);
        *y++ = round_fx(s);
#endif
    }

    FOR (; i < lg; i++)
@@ -56,8 +65,13 @@ void Residu3_lc_fx(
            s = L_mac(s, x[i-j], a[j]);
        }

#ifdef BASOP_NOGLOB
        s = L_shl_o(s, q, &Overflow);
        *y++ = round_fx_o(s, &Overflow);
#else
        s = L_shl(s, q);
        *y++ = round_fx(s);
#endif
    }
}

+5 −3
Original line number Diff line number Diff line
@@ -3884,12 +3884,13 @@ void prep_tbe_exc_fx(
                Ltemp1 = Mult_32_16(gain_code_fx, code_fx[i]);    /* Q16 + Q9 + 1 - 16 = Q10 */
                Ltemp2 = L_mult(gain_preQ_fx, code_preQ_fx[i]);   /*Q2 * Q10 -> Q12  */

                Ltemp1 = L_shl( Ltemp1, Q_exc+6 /*Q_exc+16-19*/) ; /*Q_exc+16 */
#ifdef BASOP_NOGLOB
                Ltemp1 = L_shl_o(Ltemp1, Q_exc + 6 /*Q_exc+16-19*/, &Overflow); /*Q_exc+16 */
                Ltemp2 = L_shl_o( Ltemp2, Q_exc+4 /*Q_exc+16-13*/, &Overflow) ; /*Q_exc+16 */

                tmp_code_preInt_fx[i] = round_fx(L_add_o(Ltemp1, Ltemp2, &Overflow)); /* Q_exc  */
                tmp_code_preInt_fx[i] = round_fx_o(L_add_o(Ltemp1, Ltemp2, &Overflow), &Overflow); /* Q_exc  */
#else /* BASOP_NOGLOB */
                Ltemp1 = L_shl(Ltemp1, Q_exc + 6 /*Q_exc+16-19*/); /*Q_exc+16 */
                Ltemp2 = L_shl( Ltemp2, Q_exc+4 /*Q_exc+16-13*/  ) ; /*Q_exc+16 */

                tmp_code_preInt_fx[i] = round_fx(L_add(Ltemp1, Ltemp2)); /* Q_exc  */
@@ -3911,10 +3912,11 @@ void prep_tbe_exc_fx(
        FOR ( i = 0; i < L_subfr * 2; i++ )
        {
            L_tmp = L_mult(gain_pit_fx, bwe_exc_fx[i + i_subfr_fx*2]); /*Q14+Q_exc+1 */
            tmp = round_fx(L_shl(L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/ ));  /* tmp in Q_exc */
#ifdef BASOP_NOGLOB
            tmp = round_fx_o(L_shl_o(L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow), &Overflow);  /* tmp in Q_exc */
            bwe_exc_fx[i + i_subfr_fx * 2] = add_o(tmp, tmp_code_fx[i], &Overflow);  /*Q_exc */  move16();
#else /* BASOP_NOGLOB */
            tmp = round_fx(L_shl(L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/));  /* tmp in Q_exc */
            bwe_exc_fx[i + i_subfr_fx * 2] = add(tmp, tmp_code_fx[i]);  /*Q_exc */  move16();
#endif /* BASOP_NOGLOB */
        }
+15 −3
Original line number Diff line number Diff line
@@ -287,9 +287,13 @@ void encod_gen_voic_fx(
        }
        gp_clip_test_gain_pit_fx(st_fx->element_mode, st_fx->core_brate_fx, gain_pit_fx, st_fx->clip_var_fx );

#ifdef BASOP_NOGLOB
        Lgcode = L_shl_o(gain_code_fx, Q_new, &Overflow);      /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_o(Lgcode, &Overflow);
#else
        Lgcode = L_shl(gain_code_fx, Q_new);      /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx(Lgcode);

#endif
        hLPDmem->tilt_code = Est_tilt2(&exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift);

        /*-----------------------------------------------------------------*
@@ -327,16 +331,24 @@ void encod_gen_voic_fx(
                Ltmp1 = L_shl(Ltmp1,tmp1_fx);                     /* Q16 + Q_exc */

                /* Compute exc2 */
#ifdef BASOP_NOGLOB
                Ltmp = L_shl_o(L_mult(gain_pit_fx,exc_fx[i+i_subfr_fx]),1, &Overflow);
                exc2_fx[i+i_subfr_fx] = round_fx_o(L_add_o(Ltmp, Ltmp1, &Overflow), &Overflow);
#else
                Ltmp = L_shl(L_mult(gain_pit_fx,exc_fx[i+i_subfr_fx]),1);
                exc2_fx[i+i_subfr_fx] = round_fx(L_add(Ltmp, Ltmp1));

#endif
                /* code in Q9, gain_pit in Q14 */
                Ltmp = L_mult(gcode16, code_fx[i]);
                Ltmp = L_shl(Ltmp, 5);
                Ltmp = L_mac(Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx);
#ifdef BASOP_NOGLOB
                Ltmp = L_shl_o(Ltmp, 1, &Overflow); /* saturation can occur here */
                exc_fx[i + i_subfr_fx] = round_fx_o(L_add_o(Ltmp, Ltmp1, &Overflow), &Overflow);
#else
                Ltmp = L_shl(Ltmp, 1); /* saturation can occur here */

                exc_fx[i+i_subfr_fx] = round_fx(L_add(Ltmp, Ltmp1));
#endif
            }

        }
+15 −1
Original line number Diff line number Diff line
@@ -51,7 +51,9 @@ void transf_cdbk_enc_fx(
    Word16 Qdct;
    Word16 avq_bit_sFlag;
    Word16 trgtSvPos;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    avq_bit_sFlag = 0;
    move16();
    if (GT_16(st_fx->element_mode, EVS_MONO))
@@ -79,7 +81,11 @@ void transf_cdbk_enc_fx(
     *--------------------------------------------------------------*/
    IF (EQ_16(st_fx->coder_type,INACTIVE))
    {
#ifdef BASOP_NOGLOB
        gcode16 = round_fx_o(L_shl_o(gain_code, Q_new, &Overflow), &Overflow);
#else
        gcode16 = round_fx(L_shl(gain_code, Q_new));
#endif
        FOR( i=0; i<L_SUBFR; i++ )
        {
            /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/
@@ -173,7 +179,11 @@ void transf_cdbk_enc_fx(
            m_corr = div_s(16384, m_den);
            e_corr = sub(14+4, e_den);
            Ltmp = L_shr(Mult_32_16(Ltmp, m_corr), e_corr);  /*Q12*/
#ifdef BASOP_NOGLOB
            stmp = round_fx_o(L_shl_o(Ltmp,16, &Overflow), &Overflow);
#else
            stmp = round_fx(L_shl(Ltmp,16));
#endif
        }
        ELSE
        {
@@ -276,7 +286,11 @@ void transf_cdbk_enc_fx(

    FOR( i=0; i<Nsv*WIDTH_BAND; i++ )
    {
#ifdef BASOP_NOGLOB
        x_tran[i] = shl_o(x_norm[i],Q_AVQ_OUT_DEC, &Overflow);
#else                                                   
        x_tran[i] = shl(x_norm[i],Q_AVQ_OUT_DEC);
#endif
        move16();
    }
    set16_fx( x_tran+Nsv*WIDTH_BAND, 0, sub(L_SUBFR,i_mult2(WIDTH_BAND,Nsv)) );
Loading