Commit 742a5b64 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

lib_com/syn_filt_fx.c

lib_com/tcx_ltp_fx.c
lib_com/tcx_mdct_fx.c
lib_com/tcx_utils_fx.c
lib_com/tns_base.c : completed overflow op replacement
parent 219fd4d1
Loading
Loading
Loading
Loading
+43 −3
Original line number Diff line number Diff line
@@ -11,11 +11,16 @@

static Word32 syn_kern_2( Word32 L_tmp, const Word16 a[], const Word16 y[] )
{
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
    L_tmp = L_msu_o( L_tmp, y[-1], a[1], &Overflow );
    return L_msu_o( L_tmp, y[-2], a[2], &Overflow );
#else
    L_tmp = L_msu_sat( L_tmp, y[-1], a[1] );  //??sat
    return L_msu_sat( L_tmp, y[-2], a[2] );   //??sat
#endif
}

static Word32 syn_kern_4( Word32 L_tmp, const Word16 a[], const Word16 y[] )
@@ -341,9 +346,11 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
    Word32 L_tmp;
    Word16 q;
    Word32 ( *syn_kern )( Word32 L_tmp, const Word16 a[], const Word16 y[] ) = NULL;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    if ( EQ_16( m, 6 ) )
@@ -377,8 +384,13 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
     *-----------------------------------------------------------------------*/
    /* Filtering Only from Input + Memory */
    L_tmp = syn_kern( L_mult( a0, *x++ ), a, mem );
#ifdef ISSUE_1836_replace_overflow_libcom
    L_tmp = L_shl_sat( L_tmp, q );  //??sat
    *y++ = round_fx_sat( L_tmp );   //??sat
#else
    L_tmp = L_shl_o( L_tmp, q, &Overflow );
    *y++ = round_fx_o( L_tmp, &Overflow );
#endif
    move16();

    /* Filtering from Input + Mix of Memory & Output Signal Past */
@@ -388,15 +400,24 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
        /* Process Output Signal Past */
        FOR( j = 1; j <= i; j++ )
        {
#ifdef ISSUE_1836_replace_overflow_libcom
            L_tmp = L_msu_sat( L_tmp, a[j], y[-j] ); //??sat
#else
            L_tmp = L_msu_o( L_tmp, a[j], y[-j], &Overflow );
#endif
        }
        /* Process Memory */
        FOR( ; j <= m; j++ )
        {
            L_tmp = L_msu_sat( L_tmp, a[j], mem[i - j] );
        }
#ifdef ISSUE_1836_replace_overflow_libcom
        L_tmp = L_shl_sat( L_tmp, q );  //??sat
        *y++ = round_fx_sat( L_tmp );   //??sat
#else
        L_tmp = L_shl_o( L_tmp, q, &Overflow );
        *y++ = round_fx_o( L_tmp, &Overflow );
#endif
        move16();
    }

@@ -404,8 +425,13 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
    FOR( ; i < lg; i++ )
    {
        L_tmp = syn_kern( L_mult( a0, *x++ ), a, y );
#ifdef ISSUE_1836_replace_overflow_libcom
        L_tmp = L_shl_sat( L_tmp, q );
        *y++ = round_fx_sat( L_tmp );
#else
        L_tmp = L_shl_o( L_tmp, q, &Overflow );
        *y++ = round_fx_o( L_tmp, &Overflow );
#endif
        move16();
    }

@@ -452,8 +478,10 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
    Word32 L_tmp;
    Word16 q;
    Word32 ( *syn_kern )( Word32 L_tmp, const Word32 a[], const Word32 y[] ) = NULL;
#ifdef ISSUE_1836_replace_overflow_libcom
    Flag Overflow = 0;
    move32();
#endif

    if ( EQ_16( m, 6 ) )
    {
@@ -480,8 +508,8 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
     *-----------------------------------------------------------------------*/
    mem += m; /*move32();*/

#ifdef ISSUE_1799_replace_L_shr_o
    a0 = L_shr_sat( a[0], shift ); /* input / 2^shift */
#ifdef ISSUE_1836_replace_overflow_libcom
    a0 = L_shr_sat( a[0], shift ); /* input / 2^shift */  //??sat
#else
    a0 = L_shr_o( a[0], shift, &Overflow ); /* input / 2^shift */
#endif
@@ -491,7 +519,11 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
     *-----------------------------------------------------------------------*/
    /* Filtering Only from Input + Memory */
    L_tmp = syn_kern( Mpy_32_32( a0, *x++ ), a, mem );
#ifdef ISSUE_1836_replace_overflow_libcom
    L_tmp = L_shl_sat( L_tmp, q ); //??sat
#else
    L_tmp = L_shl_o( L_tmp, q, &Overflow );
#endif
    *y++ = L_tmp;
    move32();

@@ -509,7 +541,11 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
        {
            L_tmp = Msub_32_32_r( L_tmp, a[j], mem[i - j] );
        }
        L_tmp = L_shl_o( L_tmp, q, &Overflow );
#ifdef ISSUE_1836_replace_overflow_libcom
        L_tmp = L_shl_sat( L_tmp, q ); //??sat
#else
        L_tmp = L_shl_o( L_tmp, q );
#endif
        *y++ = L_tmp;
        move32();
    }
@@ -518,7 +554,11 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[]
    FOR( ; i < lg; i++ )
    {
        L_tmp = syn_kern( Mpy_32_32( a0, *x++ ), a, y );
#ifdef ISSUE_1836_replace_overflow_libcom
        L_tmp = L_shl_sat( L_tmp, q );  //??sat
#else
        L_tmp = L_shl_o( L_tmp, q, &Overflow );
#endif
        *y++ = L_tmp;
        move32();
    }
+9 −0
Original line number Diff line number Diff line
@@ -389,9 +389,11 @@ void predict_signal(
    Word16 j;
    Word32 s;
    const Word16 *x0, *win;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    x0 = &excI[-T0 - 1];
    frac = negate( frac );
@@ -408,10 +410,17 @@ void predict_signal(

    FOR( j = 0; j < L_subfr; j++ )
    {
#ifdef ISSUE_1836_replace_overflow_libcom
        s = L_mult_sat( win[0], x0[0] );          /* Qx + 16 */   //??sat
        s = L_mac_sat( s, win[1], x0[1] );        /* Qx + 16 */   //??sat
        s = L_mac_sat( s, win[2], x0[2] );        /* Qx + 16 */   //??sat
        excO[j] = mac_r_sat( s, win[3], x0[3] );  /* Qx + 16 */   //??sat
#else
        s = L_mult_o( win[0], x0[0], &Overflow );        /* Qx + 16 */
        s = L_mac_o( s, win[1], x0[1], &Overflow );      /* Qx + 16 */
        s = L_mac_o( s, win[2], x0[2], &Overflow );      /* Qx + 16 */
        excO[j] = mac_ro( s, win[3], x0[3], &Overflow ); /* Qx + 16 */
#endif
        move16();

        x0++;
+16 −0
Original line number Diff line number Diff line
@@ -107,9 +107,11 @@ void TCX_MDCT(
    Word16 factor, neg_factor;
    Word16 factor_e;
    (void) element_mode;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e );
    *y_e = add( *y_e, factor_e );
@@ -126,7 +128,11 @@ void TCX_MDCT(
    }
    FOR( i = 0; i < l / 2; i++ )
    {
#ifdef ISSUE_1836_replace_overflow_libcom
        y[m / 2 + r / 2 + m / 2 + i] = L_msu_sat( L_mult( x[i], factor ), x[l - 1 - i], factor ); /* exp(y_e) */ //??sat
#else
        y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], factor ), x[l - 1 - i], factor, &Overflow ); /* exp(y_e) */
#endif
        move32();
    }
    FOR( i = 0; i < m / 2; i++ )
@@ -136,7 +142,11 @@ void TCX_MDCT(
    }
    FOR( i = 0; i < r / 2; i++ )
    {
#ifdef ISSUE_1836_replace_overflow_libcom
        y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_sat( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor ); /* exp(y_e) */
#else
        y[m / 2 + r / 2 - 1 - m / 2 - i] = L_mac_o( L_mult( x[l + m + i], neg_factor ), x[l + m + r - 1 - i], neg_factor, &Overflow ); /* exp(y_e) */
#endif
        move32();
    }

@@ -163,9 +173,11 @@ void TCX_MDST(
    Word16 factor, neg_factor;
    Word16 factor_e;
    (void) element_mode;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    factor = TCX_MDCT_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &factor_e ); /* exp(factor_e) */
    *y_e = add( *y_e, factor_e );
@@ -182,7 +194,11 @@ void TCX_MDST(
    }
    FOR( i = 0; i < l / 2; i++ )
    {
#ifdef ISSUE_1836_replace_overflow_libcom
        y[m / 2 + r / 2 + m / 2 + i] = L_msu_sat( L_mult( x[i], neg_factor ), x[l - 1 - i], factor ); /* exp(y_e) */ //??sat
#else
        y[m / 2 + r / 2 + m / 2 + i] = L_msu_o( L_mult( x[i], neg_factor ), x[l - 1 - i], factor, &Overflow ); /* exp(y_e) */
#endif
        move32();
    }
    FOR( i = 0; i < m / 2; i++ )
+22 −0
Original line number Diff line number Diff line
@@ -991,8 +991,10 @@ void mdct_shaping(
    Word32 *px = x; /*Qx*/
    Word16 const *pgains = gains;
    Word16 const *pgainsexp = gains_exp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif

    /* FDNS_NPTS = 64 */
@@ -1044,7 +1046,11 @@ void mdct_shaping(

            FOR( l = 0; l < k; l++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                *x = L_shl_sat( Mpy_32_16_r( *x, *gains ), *gains_exp ); /*Qx*/
#else
                *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/
#endif
                move32();
                x++;
            }
@@ -1063,7 +1069,11 @@ void mdct_shaping(
            gains_exp = pgainsexp;
            FOR( i = 0; i < FDNS_NPTS; i++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                *x = L_shl_sat( Mpy_32_16_r( *x, *gains ), *gains_exp ); /*Qx*/
#else
                *x = L_shl_o( Mpy_32_16_r( *x, *gains ), *gains_exp, &Overflow ); /*Qx*/
#endif
                move32();
                x += k;
                gains++;
@@ -1389,9 +1399,11 @@ void PsychAdaptLowFreqDeemph(
    Word16 i;
    Word16 max_val, max_e, fac, min, min_e, tmp, tmp_e;
    Word32 L_tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif


    assert( lpcGains[0] >= 0x4000 );
@@ -1438,7 +1450,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 ISSUE_1836_replace_overflow_libcom
        tmp = round_fx_sat( L_tmp );                                  /* Q15 */
#else
        tmp = round_fx_o( L_tmp, &Overflow );                         /* Q15 */
#endif
        fac = tmp;                                                    /* Q15 */
        move16();

@@ -2081,8 +2097,10 @@ void tcx_get_gain(
    Word32 corr, ener;
    Word16 sx, sy, corr_e, ener_e;
    Word16 i, tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif

    maxX = L_deposit_l( 1 );
@@ -2129,7 +2147,11 @@ void tcx_get_gain(
    ener = L_shl( ener, tmp ); /*Q31 - ener_e + tmp*/
    ener_e = sub( ener_e, tmp );

#ifdef ISSUE_1836_replace_overflow_libcom
    tmp = div_s( abs_s( round_fx_sat( corr ) ), round_fx_sat( ener ) ); /*Q15 - (corr_e - ener_e)*/
#else
    tmp = div_s( abs_s( round_fx_o( corr, &Overflow ) ), round_fx_o( ener, &Overflow ) ); /*Q15 - (corr_e - ener_e)*/
#endif
    if ( corr < 0 )
        tmp = negate( tmp );

+6 −0
Original line number Diff line number Diff line
@@ -439,9 +439,11 @@ Word16 ITF_Detect_fx(
    Word32 L_tmp, tmp32;
    Word16 tmpbuf[325];
    Word16 n, i;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    move16();
@@ -475,7 +477,11 @@ Word16 ITF_Detect_fx(

        /* Check threshold HLM_MIN_NRG */
        BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef ISSUE_1836_replace_overflow_libcom
        tmp32 = L_sub( L_shl_sat( L_tmp, sub( shift, sub( 24, Q ) ) ), 4194304l /*HLM_MIN_NRG Q7*/ ); /*Q7*/
#else
        tmp32 = L_sub( L_shl_o( L_tmp, sub( shift, sub( 24, Q ) ), &Overflow ), 4194304l /*HLM_MIN_NRG Q7*/ ); /*Q7*/
#endif
        BASOP_SATURATE_WARNING_ON_EVS;

        /* get pre-shift for autocorrelation */