Commit 14577925 authored by sagnowski's avatar sagnowski
Browse files

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

parent 53dc4424
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -334,16 +334,27 @@ static Word32 b_inv_sq(
    Word16 m_den, exp_den;
    Word16 div_out;
    Word32 Ltmp;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */

    exp_den = norm_l(in32);
    m_den = extract_h(L_shl(in32, exp_den));
    exp_den = add(sub(30,exp_den),sub(16,exp_in));

    m_den = mult_r(m_den, m_den);
#ifdef BASOP_NOGLOB
    exp_den = shl_o(exp_den,1, &Overflow);
#else /* BASOP_NOGLOB */
    exp_den = shl(exp_den,1);
#endif /* BASOP_NOGLOB */

    div_out = div_s(8192,m_den);
#ifdef BASOP_NOGLOB
    Ltmp = L_shl_o(div_out, add(sub(30-13, exp_den),15), &Overflow);  /*Q15*/
#else /* BASOP_NOGLOB */
    Ltmp = L_shl(div_out, add(sub(30-13, exp_den),15));  /*Q15*/
#endif /* BASOP_NOGLOB */

    return Ltmp;
}
@@ -634,7 +645,11 @@ static void spectautocorr_fx(
        move16();

        Mpy_32_16_ss(gp, c[j], &mh, &ml);
#ifdef BASOP_NOGLOB
        r[j] = L_add_o(r[j], mh, &Overflow);
#else /* BASOP_NOGLOB */
        r[j] = L_add(r[j], mh);
#endif /* BASOP_NOGLOB */
        move32();
    }

@@ -642,7 +657,11 @@ static void spectautocorr_fx(
     * Add the endpoints x = cos(0) = 1 and x = cos(pi) = -1 as
     * well as the lower half of the unit circle.
     *---------------------------------------------------------------------*/
#ifdef BASOP_NOGLOB
    gp = L_shr(L_add_o(G[0], G[N-1], &Overflow), 1);
#else /* BASOP_NOGLOB */
    gp = L_shr(L_add(G[0], G[N-1]), 1);
#endif /* BASOP_NOGLOB */
    gn = L_shr(L_sub(G[0], G[N-1]), 1);

#ifdef BASOP_NOGLOB
+7 −0
Original line number Diff line number Diff line
@@ -1072,6 +1072,9 @@ void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 c
    Word32 s, L_tmp;
    Word16 nb_pulse, nb_pulse_m2;
    Word16 check = 0; /* debug code not instrumented */
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */


    alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */ move16();
@@ -1254,7 +1257,11 @@ void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 c

            L_tmp = L_mult(vec[0], vec[0]);
            FOR (i = 1; i < L_SUBFR; i++)
#ifdef BASOP_NOGLOB
            L_tmp = L_mac_o(L_tmp, vec[i], vec[i], &Overflow);
#else /* BASOP_NOGLOB */
            L_tmp = L_mac(L_tmp, vec[i], vec[i]);
#endif /* BASOP_NOGLOB */

            alp = round_fx(L_shr(L_tmp, 3));

+10 −1
Original line number Diff line number Diff line
@@ -209,7 +209,11 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not)
            IF (EQ_16(i,ind_mins[k]))
            {
                /* include the last peak point (new minimum) to the corr. sum */
#ifdef BASOP_NOGLOB
                Lcory2 = L_mac_o(Lcory2, old_S[i], old_S[i], &Overflow);
#else /* BASOP_NOGLOB */
                Lcory2 = L_mac(Lcory2, old_S[i], old_S[i]);
#endif /* BASOP_NOGLOB */

                /* calculation of the norm. peak correlation */
                test();
@@ -264,10 +268,15 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not)

                k++;
            }

#ifdef BASOP_NOGLOB
            Lcorx2 = L_mac_o(Lcorx2, S[i], S[i], &Overflow);
            Lcory2 = L_mac_o(Lcory2, old_S[i], old_S[i], &Overflow);
            Lcorxy = L_mac_o(Lcorxy, S[i], old_S[i], &Overflow);
#else /* BASOP_NOGLOB */
            Lcorx2 = L_mac(Lcorx2, S[i], S[i]);
            Lcory2 = L_mac(Lcory2, old_S[i], old_S[i]);
            Lcorxy = L_mac(Lcorxy, S[i], old_S[i]);
#endif /* BASOP_NOGLOB */
        }

        Copy( S, old_S, ind_mins[0]);
+16 −0
Original line number Diff line number Diff line
@@ -83,8 +83,15 @@ static Word16 noise_est_ln_q8_fx(
{
    Word16 e_ener, f_ener;
    Word32 L_tmp;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */

#ifdef BASOP_NOGLOB
    L_tmp  = L_add_o(L_enr, L_shl((Word32)1L, q_new_plus_q_scale), &Overflow); /*  +1.0f */
#else /* BASOP_NOGLOB */
    L_tmp  = L_add(L_enr, L_shl((Word32)1L, q_new_plus_q_scale)); /*  +1.0f */
#endif /* BASOP_NOGLOB */
    if( flag_add1p0 == 0 )
    {
        L_tmp = L_add(L_enr, 0);   /* +0 , no offset */
@@ -690,8 +697,13 @@ void noise_est_fx(

    Ltmp = L_deposit_h(corr_shift);
    Ltmp = L_mac(Ltmp, st_fx->voicing_fx[0], 10923);
#ifdef BASOP_NOGLOB
    Ltmp = L_mac_o(Ltmp, st_fx->voicing_fx[1], 10923, &Overflow);
    wtmp = mac_ro(Ltmp, st_fx->voicing_fx[2], 10923, &Overflow);
#else /* BASOP_NOGLOB */
    Ltmp = L_mac(Ltmp, st_fx->voicing_fx[1], 10923);
    wtmp = mac_r(Ltmp, st_fx->voicing_fx[2], 10923);
#endif /* BASOP_NOGLOB */

    tmp_pc = pc;
    move16();
@@ -1325,7 +1337,11 @@ void noise_est_fx(
     *-----------------------------------------------------------------*/
    Ltmp = L_mult(st_fx->voicing_fx[0], 16384);
    Ltmp = L_mac(Ltmp, st_fx->voicing_fx[1], 16384);
#ifdef BASOP_NOGLOB
    cor_tmp = mac_ro(Ltmp, corr_shift,MAX_16, &Overflow);
#else /* BASOP_NOGLOB */
    cor_tmp = mac_r(Ltmp, corr_shift,MAX_16);
#endif /* BASOP_NOGLOB */

    LepsP = eps_quota_fx(epsP_h[2] , epsP_l[2],
                         epsP_h[16], epsP_l[16] , 11 );  /* L_epsP in Q11 */
+8 −0
Original line number Diff line number Diff line
@@ -880,7 +880,11 @@ void pitch_ol_fx(
        move16();
        pitch_tmp[i] = pitchX[i][ind];
        move16();
#ifdef BASOP_NOGLOB
        cor_tmp[i] = add_o(corX[i][ind], corr_shift, &Overflow);
#else /* BASOP_NOGLOB */
        cor_tmp[i] = add(corX[i][ind], corr_shift);
#endif /* BASOP_NOGLOB */
        move16();

        /* Higher is the neighbour's correlation, higher is the weighting */
@@ -894,7 +898,11 @@ void pitch_ol_fx(
        move16();
        pitch_tmp[i+NHFR] = pitchX[i][ind1];
        move16();
#ifdef BASOP_NOGLOB
        cor_tmp[i+NHFR] = add_o(corX[i][ind1], corr_shift, &Overflow);
#else /* BASOP_NOGLOB */
        cor_tmp[i+NHFR] = add(corX[i][ind1], corr_shift);
#endif /* BASOP_NOGLOB */
        move16();

        /* Higher is the neighbour's correlation, higher is the weighting */
Loading