Commit e7dbca87 authored by vaillancour's avatar vaillancour
Browse files

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

parent 11d11a1d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -318,7 +318,11 @@ void tcx_arith_scale_envelope(
                L_tmp = L_add(L_tmp, L_shl(Mpy_32_16_1(env[k], mult_r(1147/*0.035f Q15*/, iscale)), iscale_e));

                tmp = norm_l(L_tmp);
#ifdef BASOP_NOGLOB
                statesi = mult_r(statesi, round_fx_o(L_shl_o(L_tmp, tmp, &Overflow), &Overflow));
#else
                statesi = mult_r(statesi, round_fx(L_shl(L_tmp, tmp)));
#endif
                bits = add(bits, sub(15, tmp));

                tmp = norm_s(statesi);
+39 −1
Original line number Diff line number Diff line
@@ -632,6 +632,9 @@ void Decimate_allpass_steep_fx(
    Word32 Lacc, Lacc1;
    Word16 temp1, temp2;
    Word16 sum = 0;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    move16();

    /*upper allpass filter chain  */
@@ -641,7 +644,11 @@ void Decimate_allpass_steep_fx(
    {

        Lacc  = L_deposit_h( mem[0] );                     /* Q(16+x)   */
#ifdef BASOP_NOGLOB
        Lacc = L_mac_o(Lacc, AP1_STEEP_FX[0], in_fx[2 * k], &Overflow);     /* Q(16+x)   */
#else
        Lacc  = L_mac( Lacc, AP1_STEEP_FX[0], in_fx[2*k] );     /* Q(16+x)   */
#endif
        Lacc1 = L_deposit_h( in_fx[2*k] );                      /* Q16+Qx    */
        temp1 = extract_h( Lacc );                              /* Qx        */
        Lacc1 = L_msu( Lacc1, AP1_STEEP_FX[0], temp1 );         /* Q16+Qx    */
@@ -651,8 +658,11 @@ void Decimate_allpass_steep_fx(
        move16();

        Lacc1 = L_deposit_h( mem[1] );                     /* Q16+Qx    */
#ifdef BASOP_NOGLOB
        Lacc1 = ( L_mac_o( Lacc1, AP1_STEEP_FX[1], temp1, &Overflow ));      /* Q16+Qx    */
#else
        Lacc1 = ( L_mac( Lacc1, AP1_STEEP_FX[1], temp1 ));      /* Q16+Qx    */

#endif
        temp2 = extract_h( Lacc1 );                             /* Qx        */
        Lacc = L_msu( Lacc, AP1_STEEP_FX[1], temp2 );           /* Q16+Qx    */
        mem[1] = extract_h(Lacc);                          /* Qx        */
@@ -661,7 +671,11 @@ void Decimate_allpass_steep_fx(


        Lacc = L_deposit_h( mem[ ALLPASSSECTIONS_STEEP-1 ] );                                              /* Q(16+x)              */
#ifdef BASOP_NOGLOB
        out_fx[ k ] = extract_h( L_mac_o( Lacc, AP1_STEEP_FX[ ALLPASSSECTIONS_STEEP-1 ], temp2, &Overflow ));                /* Qx format            */
#else
        out_fx[ k ] = extract_h( L_mac( Lacc, AP1_STEEP_FX[ ALLPASSSECTIONS_STEEP-1 ], temp2 ));                /* Qx format            */
#endif
        mem[ ALLPASSSECTIONS_STEEP-1 ] = extract_h( L_msu ( Lacc1, AP1_STEEP_FX[ ALLPASSSECTIONS_STEEP-1 ], out_fx[k] )); /* Qx    */

    }
@@ -669,7 +683,11 @@ void Decimate_allpass_steep_fx(
    /* lower allpass filter chain  */

    Lacc  = L_deposit_h( mem[ ALLPASSSECTIONS_STEEP ] );               /*  Q(16+x)     */
#ifdef BASOP_NOGLOB
    Lacc  = L_mac_o( Lacc, AP2_STEEP_FX[0], mem[2*ALLPASSSECTIONS_STEEP], &Overflow );  /*Q(16+x)   */
#else
    Lacc  = L_mac( Lacc, AP2_STEEP_FX[0], mem[2*ALLPASSSECTIONS_STEEP] );  /*Q(16+x)   */
#endif
    Lacc1 = L_deposit_h( mem[2*ALLPASSSECTIONS_STEEP] );               /*  Q(16+x)     */
    temp1 = extract_h( Lacc );                                              /*  Qx          */
    Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 );                         /*  Q(16+x)     */
@@ -679,7 +697,11 @@ void Decimate_allpass_steep_fx(
    move16();

    Lacc1 = L_deposit_h( mem[ ALLPASSSECTIONS_STEEP+1 ] );            /*   Q(16+x) */
#ifdef BASOP_NOGLOB
    Lacc1 = L_mac_o( Lacc1, AP2_STEEP_FX[1], temp1, &Overflow);                         /*  Q(16+x) */
#else
    Lacc1 = L_mac( Lacc1, AP2_STEEP_FX[1], temp1 );                         /*  Q(16+x) */
#endif
    temp2 = extract_h( Lacc1 );                                             /*  Qx      */
    temp[1] = temp2;
    move16();
@@ -688,7 +710,11 @@ void Decimate_allpass_steep_fx(


    Lacc = L_deposit_h( mem[2*ALLPASSSECTIONS_STEEP-1] );               /* Q(16+x)  */
#ifdef BASOP_NOGLOB
    Lacc = L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp2, &Overflow);      /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#else
    Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp2 );      /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#endif
    temp[2] = extract_h( Lacc );                                             /* temp[2] in Qx  */
    Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2] );    /*   Q(16+x) */
    mem[ 2*ALLPASSSECTIONS_STEEP-1 ] = extract_h( Lacc1 );                  /*   Qx      */
@@ -702,7 +728,11 @@ void Decimate_allpass_steep_fx(


        Lacc  = L_deposit_h( mem[ ALLPASSSECTIONS_STEEP ] );               /* Q(16+x)           */
#ifdef BASOP_NOGLOB
        Lacc  = L_mac_o(Lacc, AP2_STEEP_FX[0], in_fx[2*k-1], &Overflow);                    /* Q(16+x):temp[0]   */
#else
        Lacc  = L_mac(Lacc, AP2_STEEP_FX[0], in_fx[2*k-1] );                    /* Q(16+x):temp[0]   */
#endif
        Lacc1 = L_deposit_h( in_fx[ 2*k-1 ] );                                  /* Q(16+x)           */
        temp1 = extract_h( Lacc );                                              /* Qx                */
        Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 );                         /* Q(16+x)           */
@@ -713,7 +743,11 @@ void Decimate_allpass_steep_fx(


        Lacc1 = L_deposit_h( mem[ ALLPASSSECTIONS_STEEP+1 ] );             /* Q(16+x)  */
#ifdef BASOP_NOGLOB
        Lacc1 = L_mac_o(Lacc1,AP2_STEEP_FX[1],temp1, &Overflow);                             /* Q(16+x)  */
#else
        Lacc1 = L_mac(Lacc1,AP2_STEEP_FX[1],temp1);                             /* Q(16+x)  */
#endif
        temp2 = extract_h( Lacc1 );                                             /* Qx       */
        temp[1] = temp2;
        move16();
@@ -722,7 +756,11 @@ void Decimate_allpass_steep_fx(


        Lacc  = L_deposit_h( mem[2*ALLPASSSECTIONS_STEEP-1] );                 /* Q(16+x) */
#ifdef BASOP_NOGLOB
        Lacc = L_mac_o( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[1], &Overflow);       /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#else
        Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[1] );       /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
#endif
        temp[2] = extract_h( Lacc );    /*temp[2] in Qx  */
        Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2] );     /* Q(16+x) */
        mem[2*ALLPASSSECTIONS_STEEP-1] = extract_h( Lacc1 );                   /* Qx  */
+7 −1
Original line number Diff line number Diff line
@@ -949,7 +949,9 @@ void GenShapedWBExcitation_fx(
    Word32 LepsP[LPC_WHTN_ORDER_WB+1];
    Word16 tmp_vfac;
    Word16 avg_voice_fac;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    /*0.25f*sum_f(voice_factors, NB_SUBFR)*/
    L_tmp = L_mult(voice_factors[0], 8192);
    FOR (i=1; i<NB_SUBFR; i++)
@@ -1115,9 +1117,13 @@ void GenShapedWBExcitation_fx(
                {
                    /*tmp_vfac = 2*voice_factors[i];
                      tmp_vfac = min(1, tmp_vfac);*/
#ifdef BASOP_NOGLOB
                    tmp_vfac = shl_o(voice_factors[i], 1, &Overflow);
#else
                    BASOP_SATURATE_WARNING_OFF
                    tmp_vfac = shl(voice_factors[i], 1);
                    BASOP_SATURATE_WARNING_ON
#endif
                }
                ELSE
                {
+7 −1
Original line number Diff line number Diff line
@@ -212,7 +212,9 @@ Word16 SearchPeriodicityIndex(
    Word32 Lag;
    Word16 s, tmp, tmp2, tmp3;
    Word32 tmp32;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    /* Debug init (not instrumented) */
    C = -3000;

@@ -426,9 +428,13 @@ Word16 SearchPeriodicityIndex(
        tmp = sub(norm_l(tmp32), 1);
        tmp2 = norm_l(AbsTotal);
        tmp3 = div_s( round_fx(L_shl(tmp32, tmp)), round_fx(L_shl(AbsTotal, tmp2)) );
#ifdef BASOP_NOGLOB
        * RelativeScore = shr_o(tmp3, add(sub(tmp, tmp2), 2), &Overflow); /* -> 2Q13 */           move16();
#else
        BASOP_SATURATE_WARNING_OFF
        *RelativeScore = shr(tmp3, add(sub(tmp, tmp2), 2)); /* -> 2Q13 */           move16();
        BASOP_SATURATE_WARNING_ON
#endif
    }
    ELSE
    {
+16 −1
Original line number Diff line number Diff line
@@ -366,7 +366,9 @@ static Word16 tcx_arith_rateloop(
    Word32 L_tmp;
    Word16 tmp, tmp3;
    Word32 tmp2;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif


    scale = tcx_arith_estimate_scale(abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, &tmp);
@@ -375,9 +377,13 @@ static Word16 tcx_arith_rateloop(

    scale_max = tcx_arith_find_max_scale(abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, exps, deadzone, scale_e);

#ifdef BASOP_NOGLOB
    scale = shl_o(scale, sub(tmp, *scale_e), &Overflow);
#else
    BASOP_SATURATE_WARNING_OFF;
    scale = shl(scale, sub(tmp, *scale_e));
    BASOP_SATURATE_WARNING_ON;
#endif
    scale = s_min(scale, scale_max);

    scale_best     = scale;
@@ -437,9 +443,13 @@ static Word16 tcx_arith_rateloop(
            {
                /* Update estimator temporal compensation factor */
                tmp = BASOP_Util_Divide3232_Scale(L_mult0(target_bits, 1<<9), bits, &s);
#ifdef BASOP_NOGLOB
                tmp = shl_o(mult_r(*target_bits_fac, tmp), s, &Overflow);
#else
                BASOP_SATURATE_WARNING_OFF;
                tmp = shl(mult_r(*target_bits_fac, tmp), s);
                BASOP_SATURATE_WARNING_ON;
#endif
                tmp = s_min(tmp, 20480/*1.25f Q14*/);
                tmp = s_max(tmp, 12288/*0.75f Q14*/);
                *target_bits_fac = tmp;
@@ -469,10 +479,15 @@ static Word16 tcx_arith_rateloop(
            {
                /* adjust = 1.25f * target_bits / (float)bits; */
                tmp = BASOP_Util_Divide3232_Scale(L_mult0(target_bits, 0x280), bits, &s);
#ifdef BASOP_NOGLOB
                adjust = shl_o(tmp, sub(s, 1), &Overflow); /* Q14 */
                scale = shl_o(mult_r(scale, adjust), 1, &Overflow);
#else
                BASOP_SATURATE_WARNING_OFF; /* adjust limited to <= 2.0, scale to <= scale_max */
                adjust = shl(tmp, sub(s, 1)); /* Q14 */
                scale = shl(mult_r(scale, adjust), 1);
                BASOP_SATURATE_WARNING_ON;
#endif
                scale = s_min(scale, scale_max);
            }
        }
Loading