Commit 8a153d4e authored by multrus's avatar multrus
Browse files

[cleanup] accept ISSUE_1866_replace_overflow_libdec

parent 3d3a8eab
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */

#define ISSUE_1836_replace_overflow_libcom                   /* FhG: replace overflow operators by non-overflow-alternatives in lib_com - BE */
#define ISSUE_1866_replace_overflow_libdec                   /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */

#define FIX_1917_DIRAC_RENDER_PTR_INCR                       /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */
#define FIX_CDLFB_BUFFER_SCALING                             /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */
+0 −58
Original line number Diff line number Diff line
@@ -43,12 +43,6 @@ static void Regression_Anal_fx(
    Word32 L_tmp1, L_tmp2;
    Word16 aindex_fx[MAX_PGF + 1]; // Q0
    Word32 b_p_fx[MAX_PGF + 1];    // Q10
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* Initialize */
    FOR( i = 0; i < add( num_pgf, 1 ); i++ )
@@ -80,11 +74,7 @@ static void Regression_Anal_fx(
    {
        b_p_fx[0] = L_add( b_p_fx[0], L_shr( values_fx[i], 2 ) ); /*10 */
        move32();
#ifdef ISSUE_1866_replace_overflow_libdec
        b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_sat( sub( num_pgf, i ), 13 ) ) ); /*10 */
#else
        b_p_fx[1] = L_add( b_p_fx[1], Mult_32_16( values_fx[i], shl_o( sub( num_pgf, i ), 13, &Overflow ) ) ); /*10 */
#endif
        move32();
    }

@@ -168,12 +158,6 @@ void HQ_FEC_processing_fx(
    Word16 energy_diff_fx; // Q10
    HQ_NBFEC_HANDLE hHQ_nbfec;
    HQ_DEC_HANDLE hHQ_core;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    hHQ_nbfec = st_fx->hHQ_nbfec;
    hHQ_core = st_fx->hHQ_core;

@@ -390,11 +374,7 @@ void HQ_FEC_processing_fx(

                FOR( j = 0; j < Num_bands_p[i]; j++ )
                {
#ifdef ISSUE_1866_replace_overflow_libdec
                    hHQ_nbfec->Norm_gain_fx[k] = shl_sat( tmp_fx, 1 );
#else
                    hHQ_nbfec->Norm_gain_fx[k] = shl_o( tmp_fx, 1, &Overflow );
#endif
                    move16();
                    k = add( k, 1 );
                }
@@ -449,12 +429,6 @@ void ivas_HQ_FEC_Mem_update_fx(
    HQ_DEC_HANDLE hHQ_core;
    hHQ_nbfec = st_fx->hHQ_nbfec;
    hHQ_core = st_fx->hHQ_core;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    move32(); // for tmp_energy_fx
    IF( EQ_16( output_frame, L_FRAME8k ) )
    {
@@ -532,11 +506,7 @@ void ivas_HQ_FEC_Mem_update_fx(
                L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
                k = add( k, 1 );
            }
#ifdef ISSUE_1866_replace_overflow_libdec
            tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/
#else
            tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/
#endif
            norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/
            move32();
            tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/
@@ -656,11 +626,7 @@ void ivas_HQ_FEC_Mem_update_fx(
            exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
            tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
            exp = add( 15, sub( exp1, exp2 ) );
#ifdef ISSUE_1866_replace_overflow_libdec
            *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) );
#else
            *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow );
#endif
            move16();
        }
        *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
@@ -742,12 +708,6 @@ void HQ_FEC_Mem_update_fx(
    HQ_DEC_HANDLE hHQ_core;
    hHQ_nbfec = st_fx->hHQ_nbfec;
    hHQ_core = st_fx->hHQ_core;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    move32(); // tmp_energy_fx

    IF( EQ_16( output_frame, L_FRAME8k ) )
@@ -827,11 +787,7 @@ void HQ_FEC_Mem_update_fx(
                L_tmp = L_add( L_tmp, L_shr( normq_fx[k], 3 ) ); /*11*/
                k = add( k, 1 );
            }
#ifdef ISSUE_1866_replace_overflow_libdec
            tmp_fx = shl_sat( inv_tbl_fx[Num_bands_p[i]], 1 ); /*16*/
#else
            tmp_fx = shl_o( inv_tbl_fx[Num_bands_p[i]], 1, &Overflow ); /*16*/
#endif
            norm_values_fx[0] = Mult_32_16( L_tmp, tmp_fx ); /*11 + 16 - 15*/
            move32();
            tmp_energy_fx = L_add( tmp_energy_fx, L_shr( L_tmp, 3 ) ); /*8*/
@@ -952,11 +908,7 @@ void HQ_FEC_Mem_update_fx(
            exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
            tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
            exp = add( 15, sub( exp1, exp2 ) );
#ifdef ISSUE_1866_replace_overflow_libdec
            *mean_en_high_fx = add_sat( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ) );
#else
            *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow );
#endif
            move16();
        }
        *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
@@ -1027,12 +979,6 @@ static Word16 find_best_delay_fx(
    Word32 min_sq_cross_fx, min_corr_fx;
    Word32 accA_fx, accB_fx;
    Word32 Rxy_fx[MAXDELAY_FEC], Ryy_fx[MAXDELAY_FEC];
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    move16(); // d1m


@@ -1098,11 +1044,7 @@ static Word16 find_best_delay_fx(
        L_tmp1 = L_shl( min_sq_cross_fx, exp1 );
        L_tmp2 = L_shl( min_corr_fx, exp2 );
        tmp = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); /*15 + exp1 - exp2 */
#ifdef ISSUE_1866_replace_overflow_libdec
        tmp = shl_sat( tmp, sub( exp2, add( exp1, 1 ) ) ); /*14 */
#else
        tmp = shl_o( tmp, sub( exp2, add( exp1, 1 ) ), &Overflow ); /*14 */
#endif
    }

    *false_flag = 0;
+0 −11
Original line number Diff line number Diff line
@@ -2916,20 +2916,9 @@ static Word32 mult_32_32_q( const Word32 a, const Word32 b, const Word16 q )
{
    Word32 hi;
    UWord32 lo;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    Mpy_32_32_ss( a, b, &hi, &lo );

    return L_or( L_shl_o( hi, sub( 32 - 1, q ), &Overflow ), L_lshr( (Word32) lo, add( q, 1 ) ) );
#else
    Mpy_32_32_ss( a, b, &hi, &lo );

    return L_or( L_shl_sat( hi, sub( 32 - 1, q ) ), L_lshr( (Word32) lo, add( q, 1 ) ) );
#endif
}

static void fir_dwn_fx(
+0 −40
Original line number Diff line number Diff line
@@ -95,12 +95,6 @@ void FEC_exc_estim_fx(
    Word32 cond3;
    Word32 predPitchLag;
    GSC_DEC_HANDLE hGSCDec;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif
#endif
    hGSCDec = st_fx->hGSCDec;

    AMRWB_IO_DEC_HANDLE hAmrwb_IO;
@@ -128,11 +122,7 @@ void FEC_exc_estim_fx(

        gainCNG = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* In Q3 */
    }
#ifdef ISSUE_1866_replace_overflow_libdec
    tmp1 = shl_sat( st_fx->lp_gainc_fx, 1 );
#else
    tmp1 = shl_o( st_fx->lp_gainc_fx, 1, &Overflow );
#endif
    gainCNG = s_min( gainCNG, tmp1 );
    set16_fx( exc_dct_in, 0, L_FRAME16k );

@@ -193,15 +183,9 @@ void FEC_exc_estim_fx(
    {
        test();
        test();
#ifdef ISSUE_1866_replace_overflow_libdec
        IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl_sat( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) &&
              GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past  */
            GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) )                                                                                /* or last update too far in the past */
#else
        IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), shl_o( mult( 29491, st_fx->bfi_pitch_fx ), 1, &Overflow ) ) &&
              GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past  */
            GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) )                                                                                /* or last update too far in the past */
#endif
        {
            /* take the pitch value of last subframe of the previous frame */
            *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) );
@@ -212,15 +196,9 @@ void FEC_exc_estim_fx(
    {
        test();
        test();
#ifdef ISSUE_1866_replace_overflow_libdec
        IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl_sat( mult( 29491, st_fx->bfi_pitch_fx ), 1 ) ) &&
              GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past  */
            GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) )                                                                                   /* or last update too far in the past */
#else
        IF( ( LT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), shl_o( mult( 29491, st_fx->bfi_pitch_fx ), 1, &Overflow ) ) &&
              GT_16( round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) ), mult( 19661, st_fx->bfi_pitch_fx ) ) ) || /* last pitch coherent with the past  */
            GE_16( st_fx->upd_cnt, MAX_UPD_CNT ) )                                                                                   /* or last update too far in the past */
#endif

        {
            /* take the pitch value of last subframe of the previous frame */
@@ -315,11 +293,7 @@ void FEC_exc_estim_fx(
        IF( LE_16( st_fx->nbLostCmpt, 1 ) )
        {
            /* if stable, do not decrease the energy, pitch_gain = 0 */
#ifdef ISSUE_1866_replace_overflow_libdec
            alpha = mac_r_sat( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX ); /*st_fx->stab_fac_fx in Q15*/
#else
            alpha = mac_ro( ( 1L << 16 ) * 2 * _ALPHA_U_FX, st_fx->stab_fac_fx, 32768 - 2 * _ALPHA_U_FX, &Overflow );                /*st_fx->stab_fac_fx in Q15*/
#endif
        }
        ELSE IF( EQ_16( st_fx->nbLostCmpt, 2 ) )
        {
@@ -368,11 +342,7 @@ void FEC_exc_estim_fx(
            L_tmp = L_deposit_h( tmp );
            L_tmp = Isqrt_lc( L_tmp, &exp );

#ifdef ISSUE_1866_replace_overflow_libdec
            gain = extract_h( L_shl_sat( L_tmp, exp ) );
#else
            gain = extract_h( L_shl_o( L_tmp, exp, &Overflow ) );
#endif

            gain = s_min( gain, 32113 ); /*0.98 */
            gain = s_max( gain, 27853 ); /*0.85 */
@@ -778,12 +748,6 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1
{
    Word16 tmp_pit, tmp_pit_e, tmp_frame, tmp_frame_e;
    Word32 tmp_pit2;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    tmp_pit = BASOP_Util_Divide1616_Scale( new_pit /*Q0*/, Tc /*Q0*/, &tmp_pit_e ) /*Q15*/;
    tmp_frame = add( extract_l( L_mult0( L_frame, 64 /*1.f/L_SUBFR Q12*/ ) /*Q12*/ ), 4096 /*1.f Q12*/ ); /*Q12*/
@@ -792,11 +756,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1
    tmp_frame = sub( 32767 /*1.f Q15*/, tmp_frame ); /*Q15*/
    BASOP_SATURATE_WARNING_OFF_EVS
    /*To calc Q15 threshold, overflow may happen - do negation and compare with negated value to check also highest possible value*/
#ifdef ISSUE_1866_replace_overflow_libdec
    tmp_pit = shl_sat( negate( tmp_pit ), tmp_pit_e );
#else
    tmp_pit = shl_o( negate( tmp_pit ), tmp_pit_e, &Overflow );
#endif
    BASOP_SATURATE_WARNING_ON_EVS
    *cond1 = sub( tmp_pit, negate( tmp_frame ) );
    move16();
+0 −36
Original line number Diff line number Diff line
@@ -69,11 +69,6 @@ void LD_music_post_filter_fx(
    Word16 mant, exp1, s_ave, tmp16, old_tmp16;
    Word16 diff_sc;
    Word16 old_tmp16_1;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif
    move16();
    move16();
    move16();
@@ -188,11 +183,7 @@ void LD_music_post_filter_fx(
        FOR( k = j; k < mfreq_bindiv_LD[i] + j; k++ )
        {
            /*m_ave += lf_E[k];*/
#ifdef ISSUE_1866_replace_overflow_libdec
            Ltmp = L_add_sat( lf_E[k], Ltmp ); /*2*Qdct+10*/
#else
            Ltmp = L_add_o( lf_E[k], Ltmp, &Overflow ); /*2*Qdct+10*/
#endif
            max_val = L_max( max_val, lf_E[k] );
        }
        Ltmp_max = L_max( Ltmp_max, max_val ); /*2*Qdct+10*/
@@ -448,11 +439,6 @@ static void spectrum_mod_dct_fx(
    Word32 Lshift;
    Word32 dot5_scaled;
    const Word32 *Lpt2;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif

    move16();
    move32();
@@ -531,11 +517,7 @@ static void spectrum_mod_dct_fx(

    IF( music_flag != 0 ) /* prevent subtraction on clean speech */
    {
#ifdef ISSUE_1866_replace_overflow_libdec
        IF( LE_32( maxNoise, L_shl_sat( 10, scaling ) ) )
#else
        IF( LE_32( maxNoise, L_shl_o( 10, scaling, &Overflow ) ) )
#endif
        {
            minE = 18432 / 2; /*Q14*/
            move16();
@@ -611,21 +593,12 @@ static void spectrum_mod_dct_fx(

                    Ltmp = L_mult( tmpN, m_binE ); /*2*Qdct+e_binE+9*/
                    e_binE = sub( add( e_tmp, e_binE ), 15 );
#ifdef ISSUE_1866_replace_overflow_libdec
                    Ltmp = L_shr_sat( Ltmp, e_binE );  /*2*Qdct+9*/
                    Lgain = L_add_sat( Ltmp, Lshift ); /*Saturation can occure here result in Q30*/
#else
                    Ltmp = L_shr_o( Ltmp, e_binE, &Overflow );  /*2*Qdct+9*/
                    Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/
#endif
                }

                Lpt2++;
#ifdef ISSUE_1866_replace_overflow_libdec
                gain = round_fx_sat( Lgain ); /*gain in Q30-16 = Q14*/
#else
                gain = round_fx_o( Lgain, &Overflow );          /*gain in Q30-16 = Q14*/
#endif
                /*if (gain < minE)gain = minE;*/
                gain = s_max( gain, minE ); /*Q14*/
                /*if (gain > 1.0f+MAX_GN)gain = 1.0f+MAX_GN;*/
@@ -922,11 +895,6 @@ static Word16 norm_lfe(
{
    Word32 Ltmp;
    Word16 exp2, tmp16, exp3;
#ifndef ISSUE_1866_replace_overflow_libdec
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif

    move32();

@@ -946,11 +914,7 @@ static Word16 norm_lfe(
        exp3 = sub( exp2, 12 + 16 - 3 ); /* if exp2 < 31, means that tmp >= 1.0 */
        /* Need to shl by 3 to take into account the 3 multiplications */
    }
#ifdef ISSUE_1866_replace_overflow_libdec
    tmp16 = shl_sat( tmp16, exp3 ); /* Result in Q12 */
#else
    tmp16 = shl_o( tmp16, exp3, &Overflow );                    /* Result in Q12 */
#endif

    return tmp16;
}
Loading