Commit b298e61d authored by sagnowski's avatar sagnowski
Browse files

Fix encoder overflows with args: -dtx ./switchPaths/sw_amrwb_evs.bin 16

parent 14577925
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -146,6 +146,9 @@ void E_UTIL_synthesis(const Word16 shift, const Word16 a[], const Word16 x[], Wo
    Word32 L_tmp;
    Word16 q;
    Word32 (*syn_kern)(Word32 L_tmp, const Word16 a[], const Word16 y[]) = NULL;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */

    if (EQ_16(m, 6))
    {
@@ -205,8 +208,13 @@ void E_UTIL_synthesis(const Word16 shift, const Word16 a[], const Word16 x[], Wo
    FOR (; i < lg; i++)
    {
        L_tmp = syn_kern(L_mult(a0, *x++), a, y);
#ifdef BASOP_NOGLOB
        L_tmp = L_shl_o(L_tmp, q, &Overflow);
        *y++ = round_fx_o(L_tmp, &Overflow);
#else /* BASOP_NOGLOB */
        L_tmp = L_shl(L_tmp, q);
        *y++ = round_fx(L_tmp);
#endif /* BASOP_NOGLOB */
    }

    /*-----------------------------------------------------------------------*
+7 −0
Original line number Diff line number Diff line
@@ -1143,6 +1143,9 @@ void PsychAdaptLowFreqDeemph(
    Word16 i;
    Word16 max_val, max_e, fac, min, min_e, tmp, tmp_e;
    Word32 L_tmp;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */



@@ -1190,7 +1193,11 @@ void PsychAdaptLowFreqDeemph(
        L_tmp = BASOP_Util_Log2(L_tmp); /* Q25 */
        L_tmp = L_shr(L_tmp, 7); /* 0.0078125f = 1.f/(1<<7) */
        L_tmp = BASOP_Util_InvLog2(L_tmp); /* Q31 */
#ifdef BASOP_NOGLOB
        tmp = round_fx_o(L_tmp, &Overflow); /* Q15 */
#else /* BASOP_NOGLOB */
        tmp = round_fx(L_tmp); /* Q15 */
#endif /* BASOP_NOGLOB */
        fac = tmp; /* Q15 */                                                        move16();

        /* gradual lowering of lowest 32 bins; DC is lowered by (max_val/tmp)^1/4 */
+4 −0
Original line number Diff line number Diff line
@@ -137,7 +137,11 @@ PMT("should we used extended basop here for when the L_subfr > L_SUBFR, to preve
            {
                Ltmp = L_msu(Ltmp, Aqs[j], h1[i-j]);
            }
#ifdef BASOP_NOGLOB
            h1[i] = round_fx(L_shl_o(Ltmp, s, &Overflow));
#else /* BASOP_NOGLOB */
            h1[i] = round_fx(L_shl(Ltmp, s));
#endif /* BASOP_NOGLOB */
        }
        Ltmp = L_mult(Ap[i], s2);
        FOR (j = 1; j <= M; j++)
+13 −0
Original line number Diff line number Diff line
@@ -100,8 +100,13 @@ void find_tilt_fx(
    /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/
    Ltmp = L_mult(voicing[1], 16384);
    Ltmp = L_mac(Ltmp, voicing[2], 16384);
#ifdef BASOP_NOGLOB
    Ltmp = L_mac_o(Ltmp,corr_shift, 32767, &Overflow);
    mean_voi = round_fx_o(Ltmp, &Overflow);
#else /* BASOP_NOGLOB */
    Ltmp = L_mac(Ltmp,corr_shift, 32767);
    mean_voi = round_fx(Ltmp);
#endif /* BASOP_NOGLOB */

    /*f0 = INT_FS_FX / pitch[2];*/
    e_tmp = norm_s(pitch[2]);
@@ -147,7 +152,11 @@ void find_tilt_fx(
                    tmp = sub(freq, f2);
                    IF(L_mac0(-(Word32)TH_D_FX*TH_D_FX, tmp, tmp) < 0)
                    {
#ifdef BASOP_NOGLOB
                        lp_E = L_add_o(*pt_E, lp_E, &Overflow);
#else /* BASOP_NOGLOB */
                        lp_E = L_add(*pt_E, lp_E);
#endif /* BASOP_NOGLOB */
                        m_cnt = add(m_cnt, 1);
                    }
                    pt_E++;
@@ -201,7 +210,11 @@ void find_tilt_fx(
            m_tmp = div_s(m_tmp, m_hpE);
            e_tmp = sub(e_tmp, e_hpE);

#ifdef BASOP_NOGLOB
            ee[i] = L_shr_o(m_tmp, add(e_tmp, 15-6), &Overflow);    /* ee in Q6 */
#else /* BASOP_NOGLOB */
            ee[i] = L_shr(m_tmp, add(e_tmp, 15-6));    /* ee in Q6 */
#endif /* BASOP_NOGLOB */
        }
        ELSE IF (lp_E == 0)
        {
+14 −0
Original line number Diff line number Diff line
@@ -227,7 +227,11 @@ Word16 find_uv_fx( /* o : coding type
     *-----------------------------------------------------------------*/

    /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */   /* coefficients take into account the position of the window */
#ifdef BASOP_NOGLOB
    mean_ee = L_add_o(L_add_o(st_fx->ee_old_fx, ee[0], &Overflow), ee[1], &Overflow);
#else /* BASOP_NOGLOB */
    mean_ee = L_add(L_add(st_fx->ee_old_fx, ee[0]), ee[1]);
#endif /* BASOP_NOGLOB */
    mean_ee = Mult_32_16(mean_ee, 10923);        /*Q6*/

    /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/
@@ -327,9 +331,15 @@ Word16 find_uv_fx( /* o : coding type
    test();
    test();
    test();
#ifdef BASOP_NOGLOB
    if( ( EQ_16(st_fx->last_coder_type_raw_fx,UNVOICED))||             /* previous frame was unvoiced  */
            ( ( LT_32(ee[0],ee0_th)  ) && ( GT_32(hp_E[0],L_shl(E_MIN_FX,Q_new))  ) &&         /* energy is concentrated in high frequencies provided that some energy is present in HF */
              ( LT_16(add_o(st_fx->voicing_fx[0],corr_shift, &Overflow),voi_th))))             /* normalized correlation is low */
#else /* BASOP_NOGLOB */
    if( ( EQ_16(st_fx->last_coder_type_raw_fx,UNVOICED))||             /* previous frame was unvoiced  */
            ( ( LT_32(ee[0],ee0_th)  ) && ( GT_32(hp_E[0],L_shl(E_MIN_FX,Q_new))  ) &&         /* energy is concentrated in high frequencies provided that some energy is present in HF */
              ( LT_16(add(st_fx->voicing_fx[0],corr_shift),voi_th))))             /* normalized correlation is low */
#endif /* BASOP_NOGLOB */
    {
        tmp_offset_flag = 0;
        move16();
@@ -431,7 +441,11 @@ Word16 find_uv_fx( /* o : coding type
        test();
        test();
        test();
#ifdef BASOP_NOGLOB
        if( ( ( LT_16(add_o(mean_voi3, corr_shift, &Overflow), add(22774,mean_voi3_offset)))&&         /* normalized correlation low  */
#else /* BASOP_NOGLOB */
        if( ( ( LT_16(add(mean_voi3, corr_shift),add(22774,mean_voi3_offset)))&&         /* normalized correlation low  */
#endif /* BASOP_NOGLOB */
        (  LT_16(add(st_fx->voicing_fx[2], corr_shift),25887) ) &&               /* normalized correlation low on look-ahead - onset detection */
        ( LT_32(ee[0], 397) ) && ( GT_32(hp_E[0], E_min_th)  ) &&    /* energy concentrated in high frequencies provided that some energy is present in HF...  */
        ( LT_32(ee[1], 397) ) && ( GT_32(hp_E[1], E_min_th)  ) &&    /* ... biased towards look-ahead to detect onsets  */
Loading