Commit b46c8a45 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

lib_com/hq2_noise_inject_fx.c

lib_com/ifft_rel_fx.c
lib_com/igf_base_fx.c
lib_com/interpol_fx.c
lib_com/low_rate_band_att_fx.c
lib_com/lpc_tools_fx.c : completed overflow op replacement
parent fa2e5f00
Loading
Loading
Loading
Loading
Loading
+34 −4
Original line number Diff line number Diff line
@@ -80,9 +80,11 @@ void hq2_noise_inject_fx(

    Word16 i, j, k, ni_end_band, satur, count[BANDS_MAX], max_pos_pulse, pos;
    Word16 sb = bands;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif

    satur = 0;
@@ -90,7 +92,11 @@ void hq2_noise_inject_fx(

    FOR( i = 0; i < bands; i++ )
    {
#ifdef ISSUE_1836_replace_overflow_libcom
        Ep_fx[i] = L_shl_sat( Ep_fx[i], 6 ); /* Q-6 -> Q0 */  //??sat
#else
        Ep_fx[i] = L_shl_o( Ep_fx[i], 6, &Overflow ); /* Q-6 -> Q0 */
#endif
        move32();
    }

@@ -155,7 +161,11 @@ void hq2_noise_inject_fx(
        Q_env_fx[k] = sub( 31, exp2 );
        move16();
        tmp = sub( 17, Q_env_fx[k] );
#ifdef ISSUE_1836_replace_overflow_libcom
        env_fx2[k] = extract_h( L_shl_sat( env_fx[k], tmp ) ); /*Q1 */  //??sat
#else
        env_fx2[k] = extract_h( L_shl_o( env_fx[k], tmp, &Overflow ) ); /*Q1 */
#endif
        peak_fx[k] = 0;
        move16();
        count[k] = 0;
@@ -166,7 +176,11 @@ void hq2_noise_inject_fx(
            FOR( i = band_start[k]; i <= band_end[k]; i++ )
            {
                L_tmp = L_mult0( y2hat_fx[i], y2hat_fx[i] ); /* Q0 */
#ifdef ISSUE_1836_replace_overflow_libcom
                Ep_fx[k] = L_sub_sat( Ep_fx[k], L_tmp );  //??sat
#else
                Ep_fx[k] = L_sub_o( Ep_fx[k], L_tmp, &Overflow );
#endif
                move32(); /* Q0 */
                IF( GT_16( abs_s( y2hat_fx[i] ), peak_fx[k] ) )
                {
@@ -387,7 +401,11 @@ void hq2_noise_inject_fx(
                        ELSE IF( count[k - 1] == 0 && tmp4 > 0 )
                        {
                            L_tmp = L_mult( env_fx2[k - 1], tmp );                                  /* Q(1+Q_speech+1 = Q_speech+2) */
#ifdef ISSUE_1836_replace_overflow_libcom
                            fac_fx = extract_h( L_shl_sat( L_tmp, sub( 26, Q_speech ) ) ); /*Q12 */
#else
                            fac_fx = extract_h( L_shl_o( L_tmp, sub( 26, Q_speech ), &Overflow ) ); /*Q12 */
#endif
                        }
                    }

@@ -467,8 +485,8 @@ void hq2_noise_inject_fx(
            }

            L_tmp = Mult_32_16( Ep_fx[k], fac_fx ); /*Q(Q_Ep_fx[k]+12-15 = Q_Ep_fx[k]-3) */
#ifdef ISSUE_1799_replace_L_shr_o
            ni_gain_fx[k] = L_shr_sat( L_tmp, sub( Q_Ep_fx[k], 20 ) );
#ifdef ISSUE_1836_replace_overflow_libcom
            ni_gain_fx[k] = L_shr_sat( L_tmp, sub( Q_Ep_fx[k], 20 ) );  //??sat
#else
            ni_gain_fx[k] = L_shr_o( L_tmp, sub( Q_Ep_fx[k], 20 ), &Overflow );
#endif
@@ -593,14 +611,22 @@ void hq2_noise_inject_fx(
                L_tmp = Mult_32_16( Ep_fx[k], tmp );        /*Q(Q_Ep_fx[k]+28-Q_speech-15 = Q_Ep_fx[k]+13-Q_speech) */
                tmp = sub( Q_Ep_fx[k], Q_speech );
                tmp = sub( 15, tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
                tmp = extract_h( L_shl_sat( L_tmp, tmp ) ); /*Q12 */  //??sat
#else
                tmp = extract_h( L_shl_o( L_tmp, tmp, &Overflow ) ); /*Q12 */
#endif
            }
            ELSE
            {
                tmp = 0x7fff;                        /*Q0 */
                L_tmp = Mult_32_16( Ep_fx[k], tmp ); /*Q(Q_Ep_fx[k]+0-15 = Q_Ep_fx[k]-15) */
                tmp = sub( 43, Q_Ep_fx[k] );
#ifdef ISSUE_1836_replace_overflow_libcom
                tmp = extract_h( L_shl_sat( L_tmp, tmp ) ); /*Q12 */  //??sat
#else
                tmp = extract_h( L_shl_o( L_tmp, tmp, &Overflow ) ); /*Q12 */
#endif
            }
            fac_fx = s_max( tmp, 4096 /* 1 in Q12 */ ); /*Q12 */

@@ -612,8 +638,8 @@ void hq2_noise_inject_fx(
                    IF( band_width[k] != 0 )
                    {
                        Q_speech = norm_s( band_width[k] );
#ifdef ISSUE_1796_replace_shl_o
                        tmp = shl_sat( band_width[k], Q_speech ); /*Q(Q_speech) */
#ifdef ISSUE_1836_replace_overflow_libcom
                        tmp = shl_sat( band_width[k], Q_speech ); /*Q(Q_speech) */  //??sat
#else
                        tmp = shl_o( band_width[k], Q_speech, &Overflow ); /*Q(Q_speech) */
#endif
@@ -629,7 +655,11 @@ void hq2_noise_inject_fx(
                    tmp1 = sub( fac_fx, 4096 /* 1 in Q12 */ );                          /*Q12 */
                    L_tmp = L_mult( tmp1, j );                                          /*Q13 */
                    L_tmp = Mult_32_16( L_tmp, tmp );                                   /*Q(13+29-Q_speech-15 = 27-Q_speech) */
#ifdef ISSUE_1836_replace_overflow_libcom
                    tmp = extract_h( L_shl_sat( L_tmp, add( 1, Q_speech ) ) ); /*Q12 */  //??sat
#else
                    tmp = extract_h( L_shl_o( L_tmp, add( 1, Q_speech ), &Overflow ) ); /*Q12 */
#endif
                    tmp = sub( fac_fx, tmp );                                           /*Q12 */
                    L_tmp = Mult_32_16( ni_gain_fx[k], tmp );                           /*Q(17+12-15=14) */
                    L_y2[i] = L_add( L_y2[i], L_shr( Mult_32_16( L_tmp, rand_fx ), 2 ) );
+75 −20
Original line number Diff line number Diff line
@@ -77,10 +77,12 @@ void ifft_rel_fx(

    Word16 cc1, cc3, ss1, ss3;
    Word16 tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif


    /*-----------------------------------------------------------------*
@@ -108,30 +110,43 @@ void ifft_rel_fx(

            FOR( i = is; i < n; i += id )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                t1 = sub_sat( *xi1, *xi3 );               /*Qx*/  //??sat
                *xi1 = add_sat( *xi1, *xi3 );             /*Qx*/  //??sat
                move16();
                *xi2 = shl_sat( *xi2, 1 );                /*Qx*/  //??sat
                move16();
                *xi3 = sub_sat( t1, shl_sat( *xi4, 1 ) ); /*Qx*/  //??sat
                move16();
                *xi4 = add_sat( t1, shl_sat( *xi4, 1 ) ); /*Qx*/  //??sat
                move16();
#else
                t1 = sub_o( *xi1, *xi3, &Overflow );   /*Qx*/
                *xi1 = add_o( *xi1, *xi3, &Overflow ); /*Qx*/
                move16();
#ifdef ISSUE_1796_replace_shl_o
                *xi2 = shl_sat( *xi2, 1 ); /*Qx*/
#else
                *xi2 = shl_o( *xi2, 1, &Overflow );                                              /*Qx*/
#endif
                move16();
#ifdef ISSUE_1796_replace_shl_o
                *xi3 = sub_o( t1, shl_sat( *xi4, 1 ), &Overflow ); /*Qx*/
#else
                *xi3 = sub_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow );                      /*Qx*/
#endif
                move16();
#ifdef ISSUE_1796_replace_shl_o
                *xi4 = add_o( t1, shl_sat( *xi4, 1 ), &Overflow ); /*Qx*/
#else
                *xi4 = add_o( t1, shl_o( *xi4, 1, &Overflow ), &Overflow );                      /*Qx*/
#endif
                move16();
#endif

                IF( NE_16( n4, 1 ) )
                {
#ifdef ISSUE_1836_replace_overflow_libcom
                    t1 = mult_r( sub_sat( *( xi2 + n8 ), *( xi1 + n8 ) ), INV_SQR2_FX /*Q15*/ );  /*Qx*/  //??sat
                    t2 = mult_r( add_sat( *( xi4 + n8 ), *( xi3 + n8 ) ), INV_SQR2_FX /*Q15*/ );  /*Qx*/ //??sat

                    *( xi1 + n8 ) = add_sat( *( xi1 + n8 ), *( xi2 + n8 ) );                      /*Qx*/ //??sat
                    move16();
                    *( xi2 + n8 ) = sub_sat( *( xi4 + n8 ), *( xi3 + n8 ) );                      /*Qx*/ //??sat
                    move16();
                    *( xi3 + n8 ) = negate( shl_sat( add_sat( t2, t1 ), 1 ) );                    /*Qx*/ //??sat
                    move16();
                    *( xi4 + n8 ) = shl_sat( sub_sat( t1, t2 ), 1 );                              /*Qx*/ //??sat
                    move16();
#else
                    t1 = mult_r( sub_o( *( xi2 + n8 ), *( xi1 + n8 ), &Overflow ), INV_SQR2_FX /*Q15*/ ); /*Qx*/
                    t2 = mult_r( add_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ), INV_SQR2_FX /*Q15*/ ); /*Qx*/

@@ -139,18 +154,11 @@ void ifft_rel_fx(
                    move16();
                    *( xi2 + n8 ) = sub_o( *( xi4 + n8 ), *( xi3 + n8 ), &Overflow ); /*Qx*/
                    move16();
#ifdef ISSUE_1796_replace_shl_o
                    *( xi3 + n8 ) = negate( shl_sat( add_o( t2, t1, &Overflow ), 1 ) ); /*Qx*/
#else
                    *( xi3 + n8 ) = negate( shl_o( add_o( t2, t1, &Overflow ), 1, &Overflow ) ); /*Qx*/
#endif
                    move16();
#ifdef ISSUE_1796_replace_shl_o
                    *( xi4 + n8 ) = shl_sat( sub_o( t1, t2, &Overflow ), 1 ); /*Qx*/
#else
                    *( xi4 + n8 ) = shl_o( sub_o( t1, t2, &Overflow ), 1, &Overflow );           /*Qx*/
#endif
                    move16();
#endif
                }
                xi1 += id;
                xi2 += id;
@@ -198,6 +206,45 @@ void ifft_rel_fx(

                FOR( i = is; i < n; i += id )
                {
#ifdef ISSUE_1836_replace_overflow_libcom
                    t1 = sub_sat( *xup1, *xdn6 );    /*Qx*/ //??sat
                    *xup1 = add_sat( *xup1, *xdn6 ); /*Qx*/ //??sat
                    move16();
                    xup1 += n4;
                    xdn6 -= n4;

                    t2 = sub_sat( *xdn6, *xup1 );    /*Qx*/ //??sat
                    *xdn6 = add_sat( *xup1, *xdn6 ); /*Qx*/ //??sat
                    move16();

                    xdn6 += n4;
                    t3 = add_sat( *xdn8, *xup3 );    /*Qx*/ //??sat
                    *xdn6 = sub_sat( *xdn8, *xup3 ); /*Qx*/ //??sat
                    move16();

                    xup3 += n4;
                    xdn8 -= n4;

                    t4 = add_sat( *xup3, *xdn8 );    /*Qx*/ //??sat
                    *xup1 = sub_sat( *xup3, *xdn8 ); /*Qx*/ //??sat
                    move16();

                    t5 = sub_sat( t1, t4 );                                  /*Qx*/ //??sat
                    t1 = add_sat( t1, t4 );                                  /*Qx*/ //??sat
                    t4 = sub_sat( t2, t3 );                                  /*Qx*/ //??sat
                    t2 = add_sat( t2, t3 );                                  /*Qx*/ //??sat
                    *xup3 = sub_sat( mult_r( t1, cc3 ), mult_r( t2, ss3 ) ); /*Qx*/ //??sat
                    move16();
                    xup3 -= n4;
                    *xup3 = add_sat( mult_r( t5, cc1 ), mult_r( t4, ss1 ) ); /*Qx*/ //??sat
                    move16();
                    *xdn8 = sub_sat( mult_r( t5, ss1 ), mult_r( t4, cc1 ) ); /*Qx*/ //??sat
                    move16();

                    xdn8 += n4;
                    *xdn8 = add_sat( mult_r( t2, cc3 ), mult_r( t1, ss3 ) ); /*Qx*/ //??sat
                    move16();
#else
                    t1 = sub_o( *xup1, *xdn6, &Overflow );    /*Qx*/
                    *xup1 = add_o( *xup1, *xdn6, &Overflow ); /*Qx*/
                    move16();
@@ -235,6 +282,7 @@ void ifft_rel_fx(
                    xdn8 += n4;
                    *xdn8 = add_o( mult_r( t2, cc3 ), mult_r( t1, ss3 ), &Overflow ); /*Qx*/
                    move16();
#endif

                    xup1 -= n4;
                    xup1 += id;
@@ -265,10 +313,17 @@ void ifft_rel_fx(
        {
            r1 = *xi0;
            move16();
#ifdef ISSUE_1836_replace_overflow_libcom
            *xi0 = add_sat( r1, *xi1 ); /*Qx*/  //??sat
            move16();
            *xi1 = sub_sat( r1, *xi1 ); /*Qx*/  //??sat
            move16();
#else
            *xi0 = add_o( r1, *xi1, &Overflow ); /*Qx*/
            move16();
            *xi1 = sub_o( r1, *xi1, &Overflow ); /*Qx*/
            move16();
#endif
            xi0 += id;
            xi1 += id;
        }
+10 −1
Original line number Diff line number Diff line
@@ -1119,9 +1119,11 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
    Word32 L_c;

#ifdef BASOP_NOGLOB_DECLARE_LOCAL
#ifndef ISSUE_1836_replace_overflow_libcom
    Flag Overflow = 0;
    Flag Carry = 0;
    move16();
#endif
    Flag Carry = 0;
    move16();
#endif

@@ -1142,11 +1144,18 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
        {
            Carry = 0;
            move16();
#ifdef ISSUE_1836_replace_overflow_libcom
            sfbEnergy[sfb] = L_add_c( sfbEnergy[sfb], pPowerSpectrum[line], &Carry ); //??sat
            move32();
            move16();
            L_c = L_macNs_c( L_c, 0, 0, &Carry ); //??sat
#else
            sfbEnergy[sfb] = L_add_co( sfbEnergy[sfb], pPowerSpectrum[line], &Carry, &Overflow );
            move32();
            Overflow = 0;
            move16();
            L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
#endif
        }
        sfbEnergy[sfb] = norm_llQ31( L_c, sfbEnergy[sfb], &( sfbEnergy_exp[sfb] ) );
        move32();
+8 −0
Original line number Diff line number Diff line
@@ -89,8 +89,10 @@ Word16 Interpol_4( /* Qx o : interpolated value */
{
    Word16 i;
    Word32 L_sum;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif

    x = x - L_INTERPOL1 + 1;
@@ -108,7 +110,13 @@ Word16 Interpol_4( /* Qx o : interpolated value */
    }
    BASOP_SATURATE_WARNING_OFF_EVS
    /* Here, saturation might occur by intention */
#ifdef ISSUE_1836_replace_overflow_libcom
    L_sum = L_shl_sat( L_sum, 1 ); /*Qx+14+2*/
    BASOP_SATURATE_WARNING_ON_EVS
    return round_fx_sat( L_sum ); /*Qx*/  //??sat
#else
    L_sum = L_shl_o( L_sum, 1, &Overflow ); /*Qx+14+2*/
    BASOP_SATURATE_WARNING_ON_EVS
    return round_fx_o( L_sum, &Overflow ); /*Qx*/
#endif
}
+16 −4
Original line number Diff line number Diff line
@@ -39,9 +39,11 @@ void ivas_fine_gain_pred_fx(
    Word16 tmp, exp, exp2;
    Word32 L_tmp;
    UWord16 lsb;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif

    FOR( band = 0; band < num_sfm; band++ )
@@ -81,7 +83,11 @@ void ivas_fine_gain_pred_fx(
                tmp1 = shr( tmp1, sub( sub( 15, tmp_exp ), Q11 ) );
                Mpy_32_16_ss( L_tmp, tmp1, &L_tmp, &lsb ); /*31-exp+11-15=27-exp */

#ifdef ISSUE_1836_replace_overflow_libcom
                gp = round_fx_sat( L_shl_sat( L_tmp, add( 1, exp ) ) ); /*27-exp+1+exp-16=12 */ //??sat //??sat
#else
                gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */
#endif
                test();
                test();
                IF( EQ_16( core, HQ_CORE ) && R != NULL && LE_16( R[i_sort[band]], 256 ) ) /* 256 is 32 in Q3 */
@@ -97,8 +103,8 @@ void ivas_fine_gain_pred_fx(

                    /*gp *= 1.0f - 0.05f / accuracy; */
                    tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */
#ifdef ISSUE_1772_replace_shr_o
                    tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */
#ifdef ISSUE_1836_replace_overflow_libcom
                    tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ //??sat
#else
                    tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */
#endif
@@ -158,9 +164,11 @@ void fine_gain_pred_fx(
    Word16 tmp, exp, exp2;
    Word32 L_tmp;
    UWord16 lsb;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    FOR( band = 0; band < num_sfm; band++ )
@@ -193,7 +201,11 @@ void fine_gain_pred_fx(
                exp = sub( 31, add( exp, sub( 30, shl( shift, 1 ) ) ) );
                L_tmp = Isqrt_lc( L_tmp, &exp );                                          /*31 - exp */
                Mpy_32_16_ss( L_tmp, fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb );      /*31-exp+11-15=27-exp */
#ifdef ISSUE_1836_replace_overflow_libcom
                gp = round_fx_sat( L_shl_sat( L_tmp, add( 1, exp ) ) ); /*27-exp+1+exp-16=12 */ //??sat //??sat
#else
                gp = round_fx_o( L_shl_o( L_tmp, add( 1, exp ), &Overflow ), &Overflow ); /*27-exp+1+exp-16=12 */
#endif
                test();
                test();
                IF( EQ_16( core, HQ_CORE ) && R != NULL && LE_16( R[i_sort[band]], 256 ) ) /* 256 is 32 in Q3 */
@@ -209,8 +221,8 @@ void fine_gain_pred_fx(

                    /*gp *= 1.0f - 0.05f / accuracy; */
                    tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */
#ifdef ISSUE_1772_replace_shr_o
                    tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */
#ifdef ISSUE_1836_replace_overflow_libcom
                    tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ //??sat
#else
                    tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */
#endif
Loading