Commit 4b5dee1b authored by Fabian Bauer's avatar Fabian Bauer
Browse files

codec_tcx_common_fx.c, deemph_fx.c : replaced overflow ops

parent c3efc79c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ void tcxFormantEnhancement(
    Word16 i, j, k, l, n;
    Word16 fac, fac0, fac1, fac_e, d, tmp;
    Word16 xn_buf_e, xn_one, m, e;
#ifndef ISSUE_1796_replace_shl_o
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -141,7 +141,7 @@ void tcxFormantEnhancement(
            {
                fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
                BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef ISSUE_1796_replace_shl_o
#ifdef ISSUE_1836_replace_overflow_libcom
                xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) );
#else
                xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
@@ -233,7 +233,7 @@ void tcxFormantEnhancement_with_shift(
    Word16 i, j, k, l, n;
    Word16 fac, fac0, fac1, fac_e, d, tmp;
    Word16 xn_buf_e, xn_one, m, e;
#ifndef ISSUE_1796_replace_shl_o
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -317,7 +317,7 @@ void tcxFormantEnhancement_with_shift(
            {
                fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
                BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef ISSUE_1796_replace_shl_o
#ifdef ISSUE_1836_replace_overflow_libcom
                xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) );
#else
                xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
@@ -366,7 +366,7 @@ void tcxFormantEnhancement_with_shift(
    {
        fac = add( fac0, mult( d, extract_l( L_mult0( j, inv_int[n] ) ) ) );
        BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef ISSUE_1796_replace_shl_o
#ifdef ISSUE_1836_replace_overflow_libcom
        xn_buf[l + j] = s_min( xn_one, shl_sat( mult( xn_buf[l + j], fac ), fac_e ) );
#else
        xn_buf[l + j] = s_min( xn_one, shl_o( mult( xn_buf[l + j], fac ), fac_e, &Overflow ) );
+31 −5
Original line number Diff line number Diff line
@@ -93,22 +93,34 @@ void deemph_fx(
{
    Word16 i;
    Word32 L_tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow;
    Overflow = 0;
    move32();
#endif

    L_tmp = L_deposit_h( signal[0] );              /*Qx+16*/
    L_tmp = L_mac_o( L_tmp, *mem, mu, &Overflow ); /*Qx+16*/
    signal[0] = round_fx_o( L_tmp, &Overflow );    /*Qx*/
#else
    L_tmp = L_deposit_h( signal[0] );              /*Qx+16*/
    L_tmp = L_mac_sat( L_tmp, *mem, mu ); /*Qx+16*/
    signal[0] = round_fx_sat( L_tmp );    /*Qx*/
#endif


    move16();

    FOR( i = 1; i < L; i++ )
    {
        L_tmp = L_deposit_h( signal[i] ); /*Qx+16*/
#ifdef ISSUE_1836_replace_overflow_libcom
        L_tmp = L_mac_sat( L_tmp, signal[i - 1], mu );          /*Qx+16*/
        signal[i] = round_fx_sat( L_tmp );                      /*Qx*/
#else
        L_tmp = L_mac_o( L_tmp, signal[i - 1], mu, &Overflow ); /*Qx+16*/
        signal[i] = round_fx_o( L_tmp, &Overflow );             /*Qx*/
#endif
        move16();
    }

@@ -131,10 +143,12 @@ void Deemph2(
{
    Word16 i;
    Word32 L_tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow;
    Overflow = 0;
    move32();
#endif
#endif
    /* saturation can occur in L_mac() */

@@ -145,7 +159,11 @@ void Deemph2(
    FOR( i = 1; i < L; i++ )
    {
        L_tmp = L_mult( x[i], 16384 /*0.5f in Q15*/ );   /*Qx+16*/
#ifdef ISSUE_1836_replace_overflow_libcom
        x[i] = mac_r_sat( L_tmp, x[i - 1], mu );         /*Qx-1*/
#else
        x[i] = mac_ro( L_tmp, x[i - 1], mu, &Overflow ); /*Qx-1*/
#endif
        move16();
    }

@@ -175,10 +193,12 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
{
    Word16 i;
    Word32 L_tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow;
    Overflow = 0;
    move32();
#endif
#endif

    /* signal[0] = signal[0] + mu * (*mem); */
@@ -188,8 +208,13 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
        shift = shr( -32768, shift ); /*Q15 - shift*/
        FOR( i = 0; i < L; i++ )
        {
#ifdef ISSUE_1836_replace_overflow_libcom
            L_tmp = L_msu_sat( Mpy_32_16_1( L_tmp, mu ), x[i], shift ); /*Qx-shift+16*/
            x[i] = round_fx_sat( L_tmp );                               /*Qx-shift*/
#else
            L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), x[i], shift, &Overflow ); /*Qx-shift+16*/
            x[i] = round_fx_o( L_tmp, &Overflow );                               /*Qx-shift*/
#endif
            move16();
        }
    }
@@ -197,12 +222,13 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
    {
        FOR( i = 0; i < L; i++ )
        {
#ifdef ISSUE_1772_replace_shr_o
            L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/
#ifdef ISSUE_1836_replace_overflow_libcom
            L_tmp = L_msu_sat( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/ ); /*Qx-shift+16*/
            x[i] = round_fx_sat( L_tmp ); /*Qx-shift*/
#else
            L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/
#endif
            x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/
#endif
            move16();
        }
    }