Commit 1566d0e8 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

some more overflow op replacements

parent 0fe117d7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -729,9 +729,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 );
@@ -848,7 +850,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  */ //??sat
#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 );

@@ -875,9 +881,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 );
@@ -991,7 +999,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  */   //??sat
#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 );

+12 −0
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 */  //??sat //??sat
#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*/   //??sat   //??sat
#else
        cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/
#endif
        move16();
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -918,10 +918,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 */
@@ -969,7 +971,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 */   //??sat
#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++;*/
@@ -995,7 +1001,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;

@@ -1046,7 +1056,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++;
@@ -1068,7 +1082,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;

+6 −0
Original line number Diff line number Diff line
@@ -241,9 +241,11 @@ Word16 SearchPeriodicityIndex_fx(
    Word32 Lag;
    Word16 s, tmp, tmp2, tmp3;
    Word32 tmp32;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* Debug init (not instrumented) */
@@ -457,7 +459,11 @@ Word16 SearchPeriodicityIndex_fx(
        tmp32 = L_mult0( Score, NumToConsider ); /* -> 16Q15 */
        tmp = sub( norm_l( tmp32 ), 1 );
        tmp2 = norm_l( AbsTotal );
#ifdef ISSUE_1867_replace_overflow_libenc
        tmp3 = div_s( round_fx_sat( L_shl( tmp32, tmp ) ), round_fx_sat( L_shl( AbsTotal, tmp2 ) ) );   //??sat  //??sat
#else
        tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) );
#endif
        *RelativeScore = shr_sat( tmp3, add( sub( tmp, tmp2 ), 2 ) ); /* -> 2Q13 */
        move16();
    }
+14 −11
Original line number Diff line number Diff line
@@ -48,10 +48,12 @@ static Word16 tcx_arith_estimate_scale(
{
    Word16 scale, tmp, k, s, s1;
    Word32 L_tmp, accu;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    /* compute normalised standard deviation and determine approximate scale */
@@ -72,7 +74,11 @@ static Word16 tcx_arith_estimate_scale(
            s1 = norm_l( abs_spectrum[k] );
        }

#ifdef ISSUE_1867_replace_overflow_libenc
        tmp = mult_r( round_fx_sat( L_shl( abs_spectrum[k], s1 ) ), envelope[k] );   //??sat
#else
        tmp = mult_r( round_fx_o( L_shl( abs_spectrum[k], s1 ), &Overflow ), envelope[k] );
#endif
        L_tmp = L_mult0( tmp, tmp );
        tmp = sub( shl( s1, 1 ), 1 );

@@ -367,7 +373,7 @@ static Word16 tcx_arith_rateloop(
    Word32 L_tmp;
    Word16 tmp, tmp3;
    Word32 tmp2;
#ifndef ISSUE_1796_replace_shl_o
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -381,8 +387,8 @@ static Word16 tcx_arith_rateloop(

    scale_max = tcx_arith_find_max_scale( abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, exps, deadzone, scale_e );

#ifdef ISSUE_1796_replace_shl_o
    scale = shl_sat( scale, sub( tmp, *scale_e ) );
#ifdef ISSUE_1867_replace_overflow_libenc
    scale = shl_sat( scale, sub( tmp, *scale_e ) );   //??sat
#else
    scale = shl_o( scale, sub( tmp, *scale_e ), &Overflow );
#endif
@@ -446,8 +452,8 @@ static Word16 tcx_arith_rateloop(
            {
                /* Update estimator temporal compensation factor */
                tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 1 << 9 ), bits, &s );
#ifdef ISSUE_1796_replace_shl_o
                tmp = shl_sat( mult_r( *target_bits_fac, tmp ), s );
#ifdef ISSUE_1867_replace_overflow_libenc
                tmp = shl_sat( mult_r( *target_bits_fac, tmp ), s );  //??sat
#else
                tmp = shl_o( mult_r( *target_bits_fac, tmp ), s, &Overflow );
#endif
@@ -480,14 +486,11 @@ static Word16 tcx_arith_rateloop(
            {
                /* adjust = 1.25f * target_bits / (float)bits; */
                tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 0x280 ), bits, &s );
#ifdef ISSUE_1796_replace_shl_o
                adjust = shl_sat( tmp, sub( s, 1 ) ); /* Q14 */
#ifdef ISSUE_1867_replace_overflow_libenc
                adjust = shl_sat( tmp, sub( s, 1 ) ); /* Q14 */   //??sat
                scale = shl_sat( mult_r( scale, adjust ), 1 );  //??sat
#else
                adjust = shl_o( tmp, sub( s, 1 ), &Overflow ); /* Q14 */
#endif
#ifdef ISSUE_1796_replace_shl_o
                scale = shl_sat( mult_r( scale, adjust ), 1 );
#else
                scale = shl_o( mult_r( scale, adjust ), 1, &Overflow );
#endif
                scale = s_min( scale, scale_max );