Commit 87e8dc91 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

some more overflow op replacements

parent 291406b5
Loading
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -67,9 +67,11 @@ void bw_detect_fx(
    const Word32 *pt32;
    Word32 max_NB32, max_WB32, max_SWB32, max_FB32, mean_NB32, mean_WB32, mean_SWB32, mean_FB32; /* Q11*/ /* we need Word32 for the new cldfb energy vectors */
    Word16 bwd_count_wider_bw;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    Word16 lp_noise_fx;

@@ -128,7 +130,11 @@ void bw_detect_fx(
                move32();
            }
            L_tmp = BASOP_Util_Log2( cldfb_bin[0] );                                                           /*(log2(660423549*2^(-31))/64)*2^31*/
#ifdef ISSUE_1867_replace_overflow_libenc
            L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ //??sat
#else
            L_tmp = L_add_o( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ), &Overflow ); /* Q25 */
#endif
            cldfb_bin[0] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ );
            move32(); /* 1/log2(10) */ /* Q25 */

@@ -297,8 +303,8 @@ void bw_detect_fx(

                FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ )
                {
#ifdef ISSUE_1799_replace_L_shr_o
                    spect[i] = round_fx_o( L_shr_sat( spect32[i], Q_dct ), &Overflow );
#ifdef ISSUE_1867_replace_overflow_libenc
                    spect[i] = round_fx_sat( L_shr_sat( spect32[i], Q_dct ) );   //??sat //??sat
#else
                    spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow );
#endif
@@ -339,7 +345,11 @@ void bw_detect_fx(
                    pt1 = &spect[i_mult2( i, bin_width )];
                    FOR( j = 0; j < bin_width; j++ )
                    {
#ifdef ISSUE_1867_replace_overflow_libenc
                        sum32 = L_mac0_sat( sum32, *pt1, *pt1 );   //??sat
#else
                        sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow );
#endif
                        pt1++;
                    }
                    tmp_1 = BASOP_Util_Cmp_Mant32Exp( sum32, E_spect_bin, MAX_32, Q31 - 41 ); /* Any sum32 in Q_dct if it is less than MAX_32 in Q41 will be less than 0.001 */
+57 −3
Original line number Diff line number Diff line
@@ -108,9 +108,11 @@ void CNG_enc_fx(
    st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx;
    move16();
    Word16 lp_ener_thr_scale;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    /* Temp variables for floating point functions */

@@ -635,7 +637,11 @@ void CNG_enc_fx(
            FOR( i = 0; i < M; i++ )
            {
                dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */
#ifdef ISSUE_1867_replace_overflow_libenc
                dist = add_sat( dist, dev );         /*Q15 */  //??sat
#else
                dist = add_o( dist, dev, &Overflow );         /*Q15 */
#endif
                if ( GT_16( dev, max_dev ) )
                {
                    max_dev = dev;
@@ -765,9 +771,15 @@ void CNG_enc_fx(
    FOR( i = 0; i < NUM_ENV_CNG; i++ )
    {
        /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
#ifdef ISSUE_1867_replace_overflow_libenc
        L_tmp = L_mult_sat( *ptR, *ptR );                     /* 2*Q_new+1 */   //??sat
        L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */   //??sat
        L_tmp = L_add_sat( L_tmp, L_tmp );                    /* 2*Q_new+1 */   //??sat
#else
        L_tmp = L_mult_o( *ptR, *ptR, &Overflow );                              /* 2*Q_new+1 */
        L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */
        L_tmp = L_add_o( L_tmp, L_tmp, &Overflow );                             /* 2*Q_new+1 */
#endif
        L_tmp = Mult_32_16( L_tmp, 128 );                                       /* 2*Q_new+1 */
        tmp1 = add( add( Q_new, Q_new ), 1 );
        env[i] = L_shr( L_tmp, sub( tmp1, 6 ) );
@@ -1046,7 +1058,11 @@ void CNG_enc_fx(
                    exp = norm_l( L_tmp );
                    L_tmp = L_shl( L_tmp, exp );                        /*Q(exp+6)*/
                    tmp1 = extract_h( L_tmp );                          /*Q(exp+6-16)=exp-10*/
#ifdef ISSUE_1867_replace_overflow_libenc
                    L_tmp = L_mult_sat( tmp1, tmp1 );          /*Q(2*exp - 19)*/   //??sat
#else
                    L_tmp = L_mult_o( tmp1, tmp1, &Overflow );          /*Q(2*exp - 19)*/
#endif
                    L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */
                    d = L_add( d, L_tmp );
                }
@@ -1233,9 +1249,11 @@ void CNG_enc_ivas_fx(
    Word64 w_temp;
    Word32 inv_frame_len;
    Word32 L_ener;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    step_inv = 0;
    move16();
@@ -1939,9 +1957,15 @@ void CNG_enc_ivas_fx(
    FOR( i = 0; i < NUM_ENV_CNG; i++ )
    {
        /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
#ifdef ISSUE_1867_replace_overflow_libenc
        L_tmp = L_mult_sat( *ptR, *ptR );                              /* 2*Q_new+1 */   //??sat
        L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */   //??sat
        L_tmp = L_add_sat( L_tmp, L_tmp );                             /* 2*Q_new+1 */   //??sat
#else
           L_tmp = L_mult_o( *ptR, *ptR, &Overflow );                              /* 2*Q_new+1 */
        L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */
        L_tmp = L_add_o( L_tmp, L_tmp, &Overflow );                             /* 2*Q_new+1 */
#endif
        L_tmp = Mult_32_16( L_tmp, 128 );                                       /* 2*Q_new+1 */
        tmp1 = add( add( Q_new, Q_new ), 1 );
        env[i] = L_shr( L_tmp, sub( tmp1, 6 ) );
@@ -2244,7 +2268,11 @@ void CNG_enc_ivas_fx(
                    exp = norm_l( L_tmp );
                    L_tmp = L_shl( L_tmp, exp );                        /*Q(exp+6)*/
                    tmp1 = extract_h( L_tmp );                          /*Q(exp+6-16)=exp-10*/
#ifdef ISSUE_1867_replace_overflow_libenc
                    L_tmp = L_mult_sat( tmp1, tmp1 );          /*Q(2*exp - 19)*/   //??sat
#else
                    L_tmp = L_mult_o( tmp1, tmp1, &Overflow );          /*Q(2*exp - 19)*/
#endif
                    L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */
                    d = L_add( d, L_tmp );                              /* Q17 */
                }
@@ -2511,9 +2539,11 @@ static Word16 shb_DTX_fx(
    DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
    TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
    TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4;
    Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 );
@@ -2531,7 +2561,11 @@ static Word16 shb_DTX_fx(
    wb_ener_fx = L_deposit_l( 0 );
    FOR( i = 0; i < st_fx->L_frame; i++ )
    {
#ifdef ISSUE_1867_replace_overflow_libenc
        wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] );  //??sat
#else
        wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow );
#endif
    }

    wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */
@@ -2540,7 +2574,11 @@ static Word16 shb_DTX_fx(
    fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
    exp = sub( 30 - 1, exp );
    wb_ener_fx = Mpy_32_16( exp, fra, LG10 );
#ifdef ISSUE_1867_replace_overflow_libenc
    log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */  //??sat //??sat
#else
    log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */
#endif
    exp = norm_l( shb_ener_fx );
    fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) );
    exp = sub( 30 - 1, exp );
@@ -2559,7 +2597,11 @@ static Word16 shb_DTX_fx(
        move16();
    }

#ifdef ISSUE_1867_replace_overflow_libenc
    log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ //??sat //??sat   //??sat
#else
    log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att, &Overflow ); /* log_shb_ener_fx in Q8 */
#endif
    IF( hDtxEnc->first_CNG == 0 )
    {
        hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx;
@@ -2968,10 +3010,11 @@ static Word16 shb_DTX_ivas_fx(
    TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
    TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD;


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

    shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4;
@@ -2990,7 +3033,11 @@ static Word16 shb_DTX_ivas_fx(
    wb_ener_fx = L_deposit_l( 0 );
    FOR( i = 0; i < st->L_frame; i++ )
    {
#ifdef ISSUE_1867_replace_overflow_libenc
        wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac  //??sat
#else
        wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac
#endif
    }

    wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */
@@ -3000,7 +3047,11 @@ static Word16 shb_DTX_ivas_fx(
    exp = sub( 30 - 1, exp );
    wb_ener_fx = Mpy_32_16( exp, fra, LG10 );

#ifdef ISSUE_1867_replace_overflow_libenc
    log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */  //??sat   //??sat
#else
    log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */
#endif
    exp = norm_l( shb_ener_fx );
    fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) );
    exp = sub( 30 - 1, exp );
@@ -3024,8 +3075,11 @@ static Word16 shb_DTX_ivas_fx(
        move16();
    }


#ifdef ISSUE_1867_replace_overflow_libenc
    log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att_fx ); /* log_shb_ener_fx in Q8 */   //??sat   //??sat   //??sat
#else
    log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */
#endif

    IF( st->hDtxEnc->first_CNG == 0 )
    {