Commit d2ce4bfb authored by vaillancour's avatar vaillancour
Browse files

addition of another crititcal overflow

parent 5e897c98
Loading
Loading
Loading
Loading
+46 −2
Original line number Diff line number Diff line
@@ -11,16 +11,26 @@
 *
 * Find Energy of the 1/A(z) impulse response
 *-------------------------------------------------------------------*/
#ifdef BASOP_NOGLOB
Word16 Enr_1_Az_fx_o(       /* o  : impulse response energy      Q3  */
    const Word16 Aq[],      /* i  : LP filter coefs              Qx based on the fact that Aq[0] == 1.0 */
    const Word16 len,       /* i  : impulse response length      Q0  */
    Flag* Overflow_out      /* o :  propagating the Overflow flag to upper level */
)
#else
Word16 Enr_1_Az_fx(         /* o  : impulse response energy      Q3  */
    const Word16 Aq[],      /* i  : LP filter coefs              Qx based on the fact that Aq[0] == 1.0 */
    const Word16 len        /* i  : impulse response length      Q0  */
)
#endif
{
    Word16 h1[2*L_SUBFR];
    Word16 *y;
    Word16 i, j, a0, q;
    Word32 L_tmp, L_tmp2;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    /* Find the impulse response */

    q = sub( 3, norm_s(Aq[0]) );
@@ -50,12 +60,22 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */
        L_tmp = L_msu(0, Aq[1], y[-1]);
        FOR (j = 2; j <= i; j++)
        {
#ifdef BASOP_NOGLOB
            L_tmp = L_msu_o(L_tmp, Aq[j], y[-j], &Overflow);
#else
            L_tmp = L_msu(L_tmp, Aq[j], y[-j]);
#endif
        }

#ifdef BASOP_NOGLOB
        L_tmp = L_shl_o(L_tmp, q, &Overflow);
        *y = round_fx_o(L_tmp, &Overflow);
        L_tmp2 = L_mac_o(L_tmp2, *y, *y, &Overflow);
#else
        L_tmp = L_shl(L_tmp, q);
        *y = round_fx(L_tmp);
        L_tmp2 = L_mac(L_tmp2, *y, *y);
#endif
        y++;
    }
    /* Normal Filtering */
@@ -64,14 +84,38 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */
        L_tmp = L_msu(0, Aq[1], y[-1]);
        FOR (j = 2; j <= M; j++)
        {
#ifdef BASOP_NOGLOB
            L_tmp = L_msu_o(L_tmp, Aq[j], y[-j], &Overflow);
#else
            L_tmp = L_msu(L_tmp, Aq[j], y[-j]);
#endif
        }

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

    *Overflow_out = Overflow;
#ifdef BASOP_NOGLOB
    return round_fx_o(L_tmp2, Overflow_out); /* Q19 to Q3 */
#else
    return round_fx(L_tmp2); /* Q19 to Q3 */
#endif
}
#ifdef BASOP_NOGLOB
Word16 Enr_1_Az_fx(         /* o  : impulse response energy      Q3  */
    const Word16 Aq[],      /* i  : LP filter coefs              Qx based on the fact that Aq[0] == 1.0 */
    const Word16 len        /* i  : impulse response length      Q0  */
)
{
    Flag Overflow = 0;
    return Enr_1_Az_fx_o(Aq, len, &Overflow);
}
#endif
+24 −0
Original line number Diff line number Diff line
@@ -659,7 +659,11 @@ void lsp2lpc_fx(
    move16();
    FOR ( i=0; i < order/2; i++ )
    {
#ifdef BASOP_NOGLOB   /* Critical Overflow */
        Ltemp = L_add_o( pq[ i ], pq[ i + 1 ], &Overflow);
#else
        Ltemp = L_add( pq[ i ], pq[ i + 1 ] );
#endif
        giOverflow = ( Word16 )Overflow;
        move16();
        IF ( EQ_16(giOverflow,1))
@@ -691,7 +695,11 @@ void lsp2lpc_fx(

    FOR ( i=0; i < order/2; i++ )
    {
#ifdef BASOP_NOGLOB   /* Critical Overflow */
        Ltemp = L_sub_o( pq[ i+1 ], pq[i], &Overflow );
#else
        Ltemp = L_sub( pq[ i+1 ], pq[i] );
#endif
        giOverflow = ( Word16 ) Overflow;
        move16();
        IF ( EQ_16(giOverflow,1))
@@ -717,7 +725,11 @@ void lsp2lpc_fx(
        {
            Overflow = 0;
            move16();
#ifdef BASOP_NOGLOB   /* Critical Overflow */
            Lacc = L_add_o( p[i], q[i], &Overflow );  /* p[i], q[i] in Q24 */
#else
            Lacc = L_add( p[i], q[i] );  /* p[i], q[i] in Q24 */
#endif
            if ( Overflow )
            {
                giOverflow = 1;
@@ -727,7 +739,11 @@ void lsp2lpc_fx(
            Lacc = L_negate( Lacc  );    /* Lacc=-(p[i]-q[i])/2 in Q25 */
            Overflow = 0;
            move16();
#ifdef BASOP_NOGLOB   /* Critical Overflow */
            Lacc = L_add_o( L_shl_o( Lacc, 3, &Overflow ), 0x08000, &Overflow);  /* rounding */
#else
            Lacc = L_add( L_shl( Lacc, 3 ), 0x08000 );  /* rounding */
#endif
            if ( Overflow )
            {
                giOverflow = 1;
@@ -746,7 +762,11 @@ void lsp2lpc_fx(
        {
            Overflow = 0;
            move16();
#ifdef BASOP_NOGLOB   /* Critical Overflow */
            Lacc = L_sub_o( q[i], p[i], &Overflow );  /* p[i], q[i] in Q24 */
#else
            Lacc = L_sub( q[i], p[i] );  /* p[i], q[i] in Q24 */
#endif
            if( Overflow )
            {
                giOverflow = 1;
@@ -754,7 +774,11 @@ void lsp2lpc_fx(
            }
            Overflow = 0;
            move16();
#ifdef BASOP_NOGLOB   /* Critical Overflow */
            Lacc = L_add_o( L_shl_o( Lacc, 3, &Overflow ), 0x08000, &Overflow);  /* rounding */
#else
            Lacc = L_add( L_shl( Lacc, 3 ), 0x08000);  /* rounding */
#endif
            if ( Overflow )
            {
                giOverflow = 1;
+7 −0
Original line number Diff line number Diff line
@@ -707,6 +707,13 @@ Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */
    const Word16 Aq[],              /* i  : LP filter coefs              Qx based on the fact that Aq[0] == 1.0 */
    const Word16 len                /* i  : impulse response length      Q0  */
);
#ifdef BASOP_NOGLOB
Word16 Enr_1_Az_fx_o(       /* o  : impulse response energy      Q3  */
    const Word16 Aq[],      /* i  : LP filter coefs              Qx based on the fact that Aq[0] == 1.0 */
    const Word16 len,       /* i  : impulse response length      Q0  */
    Flag* Overflow_out      /* o :  propagating the Overflow flag to upper level */
);
#endif
void FEC_scale_syn_fx(
    const Word16 L_frame,           /* i  : length of the frame                     */
    Word16* update_flg,             /* o: flag indicating re-synthesis after scaling*/
+4 −1
Original line number Diff line number Diff line
@@ -462,8 +462,11 @@ void improv_amr_wb_gs_fx(

            FOR( i=0; i < NB_SUBFR; i++ )
            {
#ifdef BASOP_NOGLOB
                enr_LP_new = Enr_1_Az_fx_o( Aq_fx+i*(M+1), L_SUBFR, &Overflow );
#else
                enr_LP_new = Enr_1_Az_fx( Aq_fx+i*(M+1), L_SUBFR );

#endif
                IF( (shr(enr_LP_new,7) > enr_LP_old) || Overflow )
                {
                    /* filter is unstable, do not modify the excitation */
+4 −4
Original line number Diff line number Diff line
@@ -198,20 +198,20 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation energy mant
    Word16 ener, i;
    Word16 exc_tmp[L_FRAME16k], xn_tmp[L_FRAME16k];
    Word32 Ltmp;
#ifdef BASOP_NOGLOB
#ifdef BASOP_NOGLOB  /* Critical Overflow */
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */

    Overflow = 0;
    move16();
#ifdef BASOP_NOGLOB
#ifdef BASOP_NOGLOB   /* Critical Overflow */
    Overflow =
#endif
        conv_fx( exc, h1, y1, L_subfr );

    IF (use_prev_sf_pit_gain == 0)
    {
#ifdef BASOP_NOGLOB
#ifdef BASOP_NOGLOB  /* Critical Overflow */
        *gain = corr_xy1_fx( xn, y1, g_corr, L_subfr, codec_mode == MODE2, &Overflow );
#else
        *gain = corr_xy1_fx( xn, y1, g_corr, L_subfr, codec_mode == MODE2 );
@@ -311,7 +311,7 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */
    Copy(y1_1, y1, L_subfr);
    Overflow  = 0;
    move16();
#ifdef BASOP_NOGLOB
#ifdef BASOP_NOGLOB        /* Critical Overflow */
    Ltmp1 = Dot_product12_o(y1, y1, L_subfr, &exp_yy, &Overflow);
    *Overflow_out |= Overflow;
    move16();