Commit 655d660e authored by multrus's avatar multrus
Browse files

Merge branch...

Merge branch '1867-replace-overflow-basop-operators-by-overflow-free-variants-in-lib_enc' into 'main'

Resolve "Replace Overflow BASOP-Operators by overflow-free variants in lib_enc"

Closes #1867

See merge request !1993
parents c379f745 180b81b1
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -73,7 +73,8 @@

/* 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_1836_replace_overflow_libcom                   /* FhG: BE - replace overflow operators by non-overflow-alternatives in lib_com */
#define ISSUE_1867_replace_overflow_libenc                   /* FhG: BE - replace overflow operators by non-overflow-alternatives all over the lib_enc module */
#define FIX_1942_ASSERTION_LOWSHELF                          /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */
#define FIX_1944_CRASH_FOR_STEREO                            /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */
#define FIX_1970_SBA_CRASH                                   /* Dlb: Fix for issue 1970, SBA crash */
+2 −2
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ void stat_noise_uv_mod_fx(
            {
                exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */
#ifdef ISSUE_1836_replace_overflow_libcom
                exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15  */ //??Sat
                exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15  */
#else
                exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15  */
#endif
@@ -197,7 +197,7 @@ void stat_noise_uv_mod_fx(
            tmp_den = shl( tmp_den, tmp_shift );
            tmp_res = div_s( tmp_nom, tmp_den );
#ifdef ISSUE_1836_replace_overflow_libcom
            tmp_res = shl_sat( tmp_res, tmp_shift ); //??Sat
            tmp_res = shl_sat( tmp_res, tmp_shift );
#else
            tmp_res = shl_o( tmp_res, tmp_shift, &Overflow );
#endif
+13 −1
Original line number Diff line number Diff line
@@ -726,9 +726,11 @@ static void bwe_switch_enc_fx(
    Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */
    Word16 n, L;
    BSTR_ENC_HANDLE hBstr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    hBstr = st_fx->hBstr;
    L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
@@ -845,7 +847,11 @@ static void bwe_switch_enc_fx(
    L_tmp1 = L_mult( tmp, E2_fx );      /*30-q_tmp1+q_tmp2 */
    q_tmp2 = sub( q_tmp1, q_tmp2 );     /*30-q_tmp2 */
    L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) );
#ifdef ISSUE_1867_replace_overflow_libenc
    gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12  */
#else
    gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12  */
#endif
    ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); /* Q0 */
    push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 );

@@ -872,9 +878,11 @@ static void bwe_switch_enc_ivas_fx(
    Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */
    Word16 n, L;
    BSTR_ENC_HANDLE hBstr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    hBstr = st_fx->hBstr;
    L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
@@ -988,7 +996,11 @@ static void bwe_switch_enc_ivas_fx(
    L_tmp1 = L_mult( tmp, E2_fx );      /*30-q_tmp1+q_tmp2 */
    q_tmp2 = sub( q_tmp1, q_tmp2 );     /*30-q_tmp2 */
    L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) );
#ifdef ISSUE_1867_replace_overflow_libenc
    gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12  */
#else
    gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12  */
#endif
    ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) );
    push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 );

+14 −2
Original line number Diff line number Diff line
@@ -161,8 +161,10 @@ void E_ACELP_conv(
{
    Word16 i, k;
    Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif
    FOR( k = 0; k < L_SUBFR; k++ )
    {
@@ -175,7 +177,11 @@ void E_ACELP_conv(
            L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/
        }
        L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */
#ifdef ISSUE_1867_replace_overflow_libenc
        cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Q0 */
#else
        cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */
#endif
    }
}

@@ -187,8 +193,10 @@ void E_ACELP_conv_ivas_fx(
{
    Word16 i, k;
    Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif
    FOR( k = 0; k < L_SUBFR; k++ )
    {
@@ -201,7 +209,11 @@ void E_ACELP_conv_ivas_fx(
            L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/
        }
        L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */
#ifdef ISSUE_1867_replace_overflow_libenc
        cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/
#else
        cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/
#endif
        move16();
    }
}
+26 −8
Original line number Diff line number Diff line
@@ -898,10 +898,12 @@ static void find_enr(
    Word32 etot;
    Word16 exp_etot;
    Word32 *tmpptr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    ptR = &data[1];         /* first real */
@@ -949,7 +951,11 @@ static void find_enr(
            /* *ptE *= 4.0 / (L_FFT*L_FFT) */
            /* normalization - corresponds to FFT normalization by 2/L_FFT */
            BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef ISSUE_1867_replace_overflow_libenc
            *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */
#else
            *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow );       /* Q_new + QSCALE - 2 */
#endif
            move32(); /* scaled by Q_new + QSCALE - 2 */
            BASOP_SATURATE_WARNING_ON_EVS;
            /*band[i] += *ptE++;*/
@@ -975,7 +981,11 @@ static void find_enr(
        exp_band = sub( exp_band, shift_to_norm );
        exp_band = sub( diff_scaleP1, exp_band );
        BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef ISSUE_1867_replace_overflow_libenc
        band[i] = L_shl_sat( Ltmp1, exp_band ); /* Q15 + exp_band */
#else
        band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );           /* Q15 + exp_band */
#endif
        move32(); /* band scaled by Q_new + QSCALE */
        BASOP_SATURATE_WARNING_ON_EVS;

@@ -1026,7 +1036,11 @@ static void find_enr(
                /* *ptE *= 4.0 / (L_FFT*L_FFT) */
                /* normalization - corresponds to FFT normalization by 2/L_FFT  */
                BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef ISSUE_1867_replace_overflow_libenc
                *Bin_E = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE */
#else
                *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE */
#endif
                move32(); /* scaled by Q_new + QSCALE - 2 */
                BASOP_SATURATE_WARNING_ON_EVS;
                Bin_E++;
@@ -1048,7 +1062,11 @@ static void find_enr(
            exp_band = sub( exp_band, shift_to_norm );
            exp_band = sub( diff_scaleP1, exp_band );
            BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */
#ifdef ISSUE_1867_replace_overflow_libenc
            band[i] = L_shl_sat( Ltmp1, exp_band );
#else
            band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
#endif
            move32(); /* band scaled by Q_new + QSCALE */
            BASOP_SATURATE_WARNING_ON_EVS;

Loading