Skip to content
Commits on Source (104)
...@@ -73,7 +73,8 @@ ...@@ -73,7 +73,8 @@
/* Note: each compile switch (FIX_1101_...) is independent from the other ones */ /* 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_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_1944_CRASH_FOR_STEREO /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */
#define FIX_1970_SBA_CRASH /* Dlb: Fix for issue 1970, SBA crash */ #define FIX_1970_SBA_CRASH /* Dlb: Fix for issue 1970, SBA crash */
......
...@@ -168,7 +168,7 @@ void stat_noise_uv_mod_fx( ...@@ -168,7 +168,7 @@ void stat_noise_uv_mod_fx(
{ {
exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */
#ifdef ISSUE_1836_replace_overflow_libcom #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 #else
exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15 */ exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15 */
#endif #endif
...@@ -197,7 +197,7 @@ void stat_noise_uv_mod_fx( ...@@ -197,7 +197,7 @@ void stat_noise_uv_mod_fx(
tmp_den = shl( tmp_den, tmp_shift ); tmp_den = shl( tmp_den, tmp_shift );
tmp_res = div_s( tmp_nom, tmp_den ); tmp_res = div_s( tmp_nom, tmp_den );
#ifdef ISSUE_1836_replace_overflow_libcom #ifdef ISSUE_1836_replace_overflow_libcom
tmp_res = shl_sat( tmp_res, tmp_shift ); //??Sat tmp_res = shl_sat( tmp_res, tmp_shift );
#else #else
tmp_res = shl_o( tmp_res, tmp_shift, &Overflow ); tmp_res = shl_o( tmp_res, tmp_shift, &Overflow );
#endif #endif
......
...@@ -1249,13 +1249,8 @@ Word16 maximum_exp_fx( /* o : index of the maximum value ...@@ -1249,13 +1249,8 @@ Word16 maximum_exp_fx( /* o : index of the maximum value
#elif 1 #elif 1
{ {
Word16 j, ind; Word16 j, ind;
Word16 tmp, exp;
ind = 0; ind = 0;
move16(); move16();
tmp = vec_fx[0];
move16();
exp = exp_vec[0];
move16();
FOR( j = 1; j < lvec_fx; j++ ) FOR( j = 1; j < lvec_fx; j++ )
{ {
......
...@@ -726,9 +726,11 @@ static void bwe_switch_enc_fx( ...@@ -726,9 +726,11 @@ static void bwe_switch_enc_fx(
Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */ Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */
Word16 n, L; Word16 n, L;
BSTR_ENC_HANDLE hBstr; BSTR_ENC_HANDLE hBstr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
hBstr = st_fx->hBstr; hBstr = st_fx->hBstr;
L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS ); L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
...@@ -845,7 +847,11 @@ static void bwe_switch_enc_fx( ...@@ -845,7 +847,11 @@ static void bwe_switch_enc_fx(
L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */
q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */
L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); 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 */ 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 */ 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 ); push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 );
...@@ -872,9 +878,11 @@ static void bwe_switch_enc_ivas_fx( ...@@ -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 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */
Word16 n, L; Word16 n, L;
BSTR_ENC_HANDLE hBstr; BSTR_ENC_HANDLE hBstr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
hBstr = st_fx->hBstr; hBstr = st_fx->hBstr;
L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS ); L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS );
...@@ -988,7 +996,11 @@ static void bwe_switch_enc_ivas_fx( ...@@ -988,7 +996,11 @@ static void bwe_switch_enc_ivas_fx(
L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */
q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */
L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); 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 */ 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 ) ); 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 ); push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 );
......
...@@ -161,8 +161,10 @@ void E_ACELP_conv( ...@@ -161,8 +161,10 @@ void E_ACELP_conv(
{ {
Word16 i, k; Word16 i, k;
Word32 L_tmp; Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
#endif
#endif #endif
FOR( k = 0; k < L_SUBFR; k++ ) FOR( k = 0; k < L_SUBFR; k++ )
{ {
...@@ -175,7 +177,11 @@ void E_ACELP_conv( ...@@ -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_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/
} }
L_tmp = W_sat_l( L_tmp_64 ); /* 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 */ 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( ...@@ -187,8 +193,10 @@ void E_ACELP_conv_ivas_fx(
{ {
Word16 i, k; Word16 i, k;
Word32 L_tmp; Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
#endif
#endif #endif
FOR( k = 0; k < L_SUBFR; k++ ) FOR( k = 0; k < L_SUBFR; k++ )
{ {
...@@ -201,7 +209,11 @@ void E_ACELP_conv_ivas_fx( ...@@ -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_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 */ 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*/ cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/
#endif
move16(); move16();
} }
} }
......
...@@ -898,10 +898,12 @@ static void find_enr( ...@@ -898,10 +898,12 @@ static void find_enr(
Word32 etot; Word32 etot;
Word16 exp_etot; Word16 exp_etot;
Word32 *tmpptr; Word32 *tmpptr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
ptR = &data[1]; /* first real */ ptR = &data[1]; /* first real */
...@@ -949,7 +951,11 @@ static void find_enr( ...@@ -949,7 +951,11 @@ static void find_enr(
/* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* *ptE *= 4.0 / (L_FFT*L_FFT) */
/* normalization - corresponds to FFT normalization by 2/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) */ 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 */ *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */
#endif
move32(); /* scaled by Q_new + QSCALE - 2 */ move32(); /* scaled by Q_new + QSCALE - 2 */
BASOP_SATURATE_WARNING_ON_EVS; BASOP_SATURATE_WARNING_ON_EVS;
/*band[i] += *ptE++;*/ /*band[i] += *ptE++;*/
...@@ -975,7 +981,11 @@ static void find_enr( ...@@ -975,7 +981,11 @@ static void find_enr(
exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( exp_band, shift_to_norm );
exp_band = sub( diff_scaleP1, exp_band ); exp_band = sub( diff_scaleP1, exp_band );
BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ 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 */ band[i] = L_shl_o( Ltmp1, exp_band, &Overflow ); /* Q15 + exp_band */
#endif
move32(); /* band scaled by Q_new + QSCALE */ move32(); /* band scaled by Q_new + QSCALE */
BASOP_SATURATE_WARNING_ON_EVS; BASOP_SATURATE_WARNING_ON_EVS;
...@@ -1026,7 +1036,11 @@ static void find_enr( ...@@ -1026,7 +1036,11 @@ static void find_enr(
/* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* *ptE *= 4.0 / (L_FFT*L_FFT) */
/* normalization - corresponds to FFT normalization by 2/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) */ 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 */ *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE */
#endif
move32(); /* scaled by Q_new + QSCALE - 2 */ move32(); /* scaled by Q_new + QSCALE - 2 */
BASOP_SATURATE_WARNING_ON_EVS; BASOP_SATURATE_WARNING_ON_EVS;
Bin_E++; Bin_E++;
...@@ -1048,7 +1062,11 @@ static void find_enr( ...@@ -1048,7 +1062,11 @@ static void find_enr(
exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( exp_band, shift_to_norm );
exp_band = sub( diff_scaleP1, exp_band ); exp_band = sub( diff_scaleP1, exp_band );
BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ 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 ); band[i] = L_shl_o( Ltmp1, exp_band, &Overflow );
#endif
move32(); /* band scaled by Q_new + QSCALE */ move32(); /* band scaled by Q_new + QSCALE */
BASOP_SATURATE_WARNING_ON_EVS; BASOP_SATURATE_WARNING_ON_EVS;
......
...@@ -241,9 +241,11 @@ Word16 SearchPeriodicityIndex_fx( ...@@ -241,9 +241,11 @@ Word16 SearchPeriodicityIndex_fx(
Word32 Lag; Word32 Lag;
Word16 s, tmp, tmp2, tmp3; Word16 s, tmp, tmp2, tmp3;
Word32 tmp32; Word32 tmp32;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
/* Debug init (not instrumented) */ /* Debug init (not instrumented) */
...@@ -457,7 +459,11 @@ Word16 SearchPeriodicityIndex_fx( ...@@ -457,7 +459,11 @@ Word16 SearchPeriodicityIndex_fx(
tmp32 = L_mult0( Score, NumToConsider ); /* -> 16Q15 */ tmp32 = L_mult0( Score, NumToConsider ); /* -> 16Q15 */
tmp = sub( norm_l( tmp32 ), 1 ); tmp = sub( norm_l( tmp32 ), 1 );
tmp2 = norm_l( AbsTotal ); 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 ) ) );
#else
tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) ); 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 */ *RelativeScore = shr_sat( tmp3, add( sub( tmp, tmp2 ), 2 ) ); /* -> 2Q13 */
move16(); move16();
} }
......
...@@ -48,10 +48,12 @@ static Word16 tcx_arith_estimate_scale( ...@@ -48,10 +48,12 @@ static Word16 tcx_arith_estimate_scale(
{ {
Word16 scale, tmp, k, s, s1; Word16 scale, tmp, k, s, s1;
Word32 L_tmp, accu; Word32 L_tmp, accu;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
/* compute normalised standard deviation and determine approximate scale */ /* compute normalised standard deviation and determine approximate scale */
...@@ -72,7 +74,11 @@ static Word16 tcx_arith_estimate_scale( ...@@ -72,7 +74,11 @@ static Word16 tcx_arith_estimate_scale(
s1 = norm_l( abs_spectrum[k] ); 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] );
#else
tmp = mult_r( round_fx_o( L_shl( abs_spectrum[k], s1 ), &Overflow ), envelope[k] ); tmp = mult_r( round_fx_o( L_shl( abs_spectrum[k], s1 ), &Overflow ), envelope[k] );
#endif
L_tmp = L_mult0( tmp, tmp ); L_tmp = L_mult0( tmp, tmp );
tmp = sub( shl( s1, 1 ), 1 ); tmp = sub( shl( s1, 1 ), 1 );
...@@ -367,6 +373,12 @@ static Word16 tcx_arith_rateloop( ...@@ -367,6 +373,12 @@ static Word16 tcx_arith_rateloop(
Word32 L_tmp; Word32 L_tmp;
Word16 tmp, tmp3; Word16 tmp, tmp3;
Word32 tmp2; Word32 tmp2;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move32();
#endif
#endif
scale = tcx_arith_estimate_scale( abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, &tmp ); scale = tcx_arith_estimate_scale( abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, &tmp );
......
...@@ -33,8 +33,10 @@ void AVQ_cod_fx( /* o: comfort noise gain factor ...@@ -33,8 +33,10 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
Word16 ebits[NSV_MAX], e_ebits, f_ebits, e_tmp, f_tmp, tmp16, l_8; Word16 ebits[NSV_MAX], e_ebits, f_ebits, e_tmp, f_tmp, tmp16, l_8;
Word32 Lener, Ltmp, Lgain, x1[8]; Word32 Lener, Ltmp, Lgain, x1[8];
Word16 tot_est_bits, Q_in; Word16 tot_est_bits, Q_in;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
#endif
#endif #endif
Q_in = sub( Q_in_ref, 1 ); Q_in = sub( Q_in_ref, 1 );
move16(); move16();
...@@ -51,7 +53,11 @@ void AVQ_cod_fx( /* o: comfort noise gain factor ...@@ -51,7 +53,11 @@ void AVQ_cod_fx( /* o: comfort noise gain factor
Lener = L_shl( 4, shl( Q_in, 1 ) ); /* to set ebits >= 0 */ Lener = L_shl( 4, shl( Q_in, 1 ) ); /* to set ebits >= 0 */
FOR( i = 0; i < 8; i++ ) FOR( i = 0; i < 8; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
Lener = L_mac_sat( Lener, xri[l * 8 + i], xri[l * 8 + i] );
#else
Lener = L_mac_o( Lener, xri[l * 8 + i], xri[l * 8 + i], &Overflow ); Lener = L_mac_o( Lener, xri[l * 8 + i], xri[l * 8 + i], &Overflow );
#endif
} }
/* estimated bit consumption when gain=1 */ /* estimated bit consumption when gain=1 */
/* ebits[l] = 5.0 * FAC_LOG2 * (Word16)log10(ener * 0.5) */ /* ebits[l] = 5.0 * FAC_LOG2 * (Word16)log10(ener * 0.5) */
......
...@@ -36,10 +36,12 @@ Word16 bass_pf_enc_fx( ...@@ -36,10 +36,12 @@ Word16 bass_pf_enc_fx(
Word32 cross_n_d, nrg_n; Word32 cross_n_d, nrg_n;
const Word16 *pFilt; const Word16 *pFilt;
Word32 ener2; Word32 ener2;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
IF( NE_16( l_frame, L_FRAME16k ) ) IF( NE_16( l_frame, L_FRAME16k ) )
...@@ -153,6 +155,16 @@ Word16 bass_pf_enc_fx( ...@@ -153,6 +155,16 @@ Word16 bass_pf_enc_fx(
FOR( i = 0; i < lg; i++ ) FOR( i = 0; i < lg; i++ )
{ {
tmp32 = L_msu0( 0, gain, syn[i + i_subfr - T] ); tmp32 = L_msu0( 0, gain, syn[i + i_subfr - T] );
#ifdef ISSUE_1867_replace_overflow_libenc
tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr + T] );
tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */
lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ );
lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */
tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */
ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */
#else
tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr + T], &Overflow ); tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr + T], &Overflow );
tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */ tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */
...@@ -161,6 +173,7 @@ Word16 bass_pf_enc_fx( ...@@ -161,6 +173,7 @@ Word16 bass_pf_enc_fx(
tmp16 = round_fx_o( L_shl_o( lp_error, s1, &Overflow ), &Overflow ); /* Q0+s1-3 */ tmp16 = round_fx_o( L_shl_o( lp_error, s1, &Overflow ), &Overflow ); /* Q0+s1-3 */
ener2 = L_mac0_o( ener2, tmp16, tmp16, &Overflow ); /* Q0+(s1-3)*2 */ ener2 = L_mac0_o( ener2, tmp16, tmp16, &Overflow ); /* Q0+(s1-3)*2 */
#endif
} }
} }
...@@ -169,6 +182,15 @@ Word16 bass_pf_enc_fx( ...@@ -169,6 +182,15 @@ Word16 bass_pf_enc_fx(
FOR( i = lg; i < l_subfr; i++ ) FOR( i = lg; i < l_subfr; i++ )
{ {
tmp32 = L_mult0( gain, syn[i + i_subfr] ); tmp32 = L_mult0( gain, syn[i + i_subfr] );
#ifdef ISSUE_1867_replace_overflow_libenc
tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr - T] ); /* Q0 */
tmp16 = round_fx_sat( tmp32 );
lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ );
lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */
tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */
ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */
#else
tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr - T], &Overflow ); /* Q0 */ tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr - T], &Overflow ); /* Q0 */
tmp16 = round_fx_o( tmp32, &Overflow ); tmp16 = round_fx_o( tmp32, &Overflow );
lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ );
...@@ -176,6 +198,7 @@ Word16 bass_pf_enc_fx( ...@@ -176,6 +198,7 @@ Word16 bass_pf_enc_fx(
tmp16 = round_fx_o( L_shl_o( lp_error, s1, &Overflow ), &Overflow ); /* Q0+s1-3 */ tmp16 = round_fx_o( L_shl_o( lp_error, s1, &Overflow ), &Overflow ); /* Q0+s1-3 */
ener2 = L_mac0_o( ener2, tmp16, tmp16, &Overflow ); /* Q0+(s1-3)*2 */ ener2 = L_mac0_o( ener2, tmp16, tmp16, &Overflow ); /* Q0+(s1-3)*2 */
#endif
} }
} }
...@@ -236,7 +259,11 @@ Word16 bass_pf_enc_fx( ...@@ -236,7 +259,11 @@ Word16 bass_pf_enc_fx(
tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] ); tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] );
noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */ noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */
#ifdef ISSUE_1867_replace_overflow_libenc
error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/
#else
error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/
#endif
move16(); move16();
} }
} }
...@@ -250,7 +277,11 @@ Word16 bass_pf_enc_fx( ...@@ -250,7 +277,11 @@ Word16 bass_pf_enc_fx(
noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */ noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */
move16(); move16();
#ifdef ISSUE_1867_replace_overflow_libenc
error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/
#else
error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/
#endif
move16(); move16();
} }
} }
......
...@@ -67,9 +67,11 @@ void bw_detect_fx( ...@@ -67,9 +67,11 @@ void bw_detect_fx(
const Word32 *pt32; 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 */ 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; Word16 bwd_count_wider_bw;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
Word16 lp_noise_fx; Word16 lp_noise_fx;
...@@ -128,7 +130,11 @@ void bw_detect_fx( ...@@ -128,7 +130,11 @@ void bw_detect_fx(
move32(); move32();
} }
L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ 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 */
#else
L_tmp = L_add_o( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ), &Overflow ); /* Q25 */ 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*/ ); cldfb_bin[0] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ );
move32(); /* 1/log2(10) */ /* Q25 */ move32(); /* 1/log2(10) */ /* Q25 */
...@@ -297,7 +303,11 @@ void bw_detect_fx( ...@@ -297,7 +303,11 @@ void bw_detect_fx(
FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ )
{ {
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 ) );
#else
spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow );
#endif
move16(); move16();
} }
Q_dct = -2; Q_dct = -2;
...@@ -335,7 +345,11 @@ void bw_detect_fx( ...@@ -335,7 +345,11 @@ void bw_detect_fx(
pt1 = &spect[i_mult2( i, bin_width )]; pt1 = &spect[i_mult2( i, bin_width )];
FOR( j = 0; j < bin_width; j++ ) FOR( j = 0; j < bin_width; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
sum32 = L_mac0_sat( sum32, *pt1, *pt1 );
#else
sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow );
#endif
pt1++; 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 */ 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 */
......
...@@ -108,9 +108,11 @@ void CNG_enc_fx( ...@@ -108,9 +108,11 @@ void CNG_enc_fx(
st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx;
move16(); move16();
Word16 lp_ener_thr_scale; Word16 lp_ener_thr_scale;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
/* Temp variables for floating point functions */ /* Temp variables for floating point functions */
...@@ -635,7 +637,11 @@ void CNG_enc_fx( ...@@ -635,7 +637,11 @@ void CNG_enc_fx(
FOR( i = 0; i < M; i++ ) FOR( i = 0; i < M; i++ )
{ {
dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */
#ifdef ISSUE_1867_replace_overflow_libenc
dist = add_sat( dist, dev ); /*Q15 */
#else
dist = add_o( dist, dev, &Overflow ); /*Q15 */ dist = add_o( dist, dev, &Overflow ); /*Q15 */
#endif
if ( GT_16( dev, max_dev ) ) if ( GT_16( dev, max_dev ) )
{ {
max_dev = dev; max_dev = dev;
...@@ -765,9 +771,15 @@ void CNG_enc_fx( ...@@ -765,9 +771,15 @@ void CNG_enc_fx(
FOR( i = 0; i < NUM_ENV_CNG; i++ ) FOR( i = 0; i < NUM_ENV_CNG; i++ )
{ {
/* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ /* 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 */
L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */
L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */
#else
L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ 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_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */
L_tmp = L_add_o( L_tmp, L_tmp, &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 */ L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */
tmp1 = add( add( Q_new, Q_new ), 1 ); tmp1 = add( add( Q_new, Q_new ), 1 );
env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) );
...@@ -1046,7 +1058,11 @@ void CNG_enc_fx( ...@@ -1046,7 +1058,11 @@ void CNG_enc_fx(
exp = norm_l( L_tmp ); exp = norm_l( L_tmp );
L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/
tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ 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)*/
#else
L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ 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 */ L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */
d = L_add( d, L_tmp ); d = L_add( d, L_tmp );
} }
...@@ -1233,9 +1249,11 @@ void CNG_enc_ivas_fx( ...@@ -1233,9 +1249,11 @@ void CNG_enc_ivas_fx(
Word64 w_temp; Word64 w_temp;
Word32 inv_frame_len; Word32 inv_frame_len;
Word32 L_ener; Word32 L_ener;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
step_inv = 0; step_inv = 0;
move16(); move16();
...@@ -1939,9 +1957,15 @@ void CNG_enc_ivas_fx( ...@@ -1939,9 +1957,15 @@ void CNG_enc_ivas_fx(
FOR( i = 0; i < NUM_ENV_CNG; i++ ) FOR( i = 0; i < NUM_ENV_CNG; i++ )
{ {
/* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ /* 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 */
L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */
L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */
#else
L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ 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_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */
L_tmp = L_add_o( L_tmp, L_tmp, &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 */ L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */
tmp1 = add( add( Q_new, Q_new ), 1 ); tmp1 = add( add( Q_new, Q_new ), 1 );
env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) );
...@@ -2244,7 +2268,11 @@ void CNG_enc_ivas_fx( ...@@ -2244,7 +2268,11 @@ void CNG_enc_ivas_fx(
exp = norm_l( L_tmp ); exp = norm_l( L_tmp );
L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/
tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ 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)*/
#else
L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ 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 */ L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */
d = L_add( d, L_tmp ); /* Q17 */ d = L_add( d, L_tmp ); /* Q17 */
} }
...@@ -2511,9 +2539,11 @@ static Word16 shb_DTX_fx( ...@@ -2511,9 +2539,11 @@ static Word16 shb_DTX_fx(
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; 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 ); 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( ...@@ -2531,7 +2561,11 @@ static Word16 shb_DTX_fx(
wb_ener_fx = L_deposit_l( 0 ); wb_ener_fx = L_deposit_l( 0 );
FOR( i = 0; i < st_fx->L_frame; i++ ) 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] );
#else
wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow ); 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 */ 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( ...@@ -2540,7 +2574,11 @@ static Word16 shb_DTX_fx(
fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) );
exp = sub( 30 - 1, exp ); exp = sub( 30 - 1, exp );
wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); 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 */
#else
log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ 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 ); exp = norm_l( shb_ener_fx );
fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) );
exp = sub( 30 - 1, exp ); exp = sub( 30 - 1, exp );
...@@ -2559,7 +2597,11 @@ static Word16 shb_DTX_fx( ...@@ -2559,7 +2597,11 @@ static Word16 shb_DTX_fx(
move16(); 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 */
#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 */ 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 ) IF( hDtxEnc->first_CNG == 0 )
{ {
hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx;
...@@ -2968,10 +3010,11 @@ static Word16 shb_DTX_ivas_fx( ...@@ -2968,10 +3010,11 @@ static Word16 shb_DTX_ivas_fx(
TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc;
TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move16(); move16();
#endif
#endif #endif
shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; 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( ...@@ -2990,7 +3033,11 @@ static Word16 shb_DTX_ivas_fx(
wb_ener_fx = L_deposit_l( 0 ); wb_ener_fx = L_deposit_l( 0 );
FOR( i = 0; i < st->L_frame; i++ ) 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
#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 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 */ 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( ...@@ -3000,7 +3047,11 @@ static Word16 shb_DTX_ivas_fx(
exp = sub( 30 - 1, exp ); exp = sub( 30 - 1, exp );
wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); 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 */
#else
log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ 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 ); exp = norm_l( shb_ener_fx );
fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) );
exp = sub( 30 - 1, exp ); exp = sub( 30 - 1, exp );
...@@ -3024,8 +3075,11 @@ static Word16 shb_DTX_ivas_fx( ...@@ -3024,8 +3075,11 @@ static Word16 shb_DTX_ivas_fx(
move16(); 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 */
#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 */ 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 ) IF( st->hDtxEnc->first_CNG == 0 )
{ {
......
...@@ -47,9 +47,11 @@ void acelp_2t32_fx( ...@@ -47,9 +47,11 @@ void acelp_2t32_fx(
Word32 L_tmp; Word32 L_tmp;
Word16 rrixix[NB_TRACK_FCB_2T][NB_POS_FCB_2T]; Word16 rrixix[NB_TRACK_FCB_2T][NB_POS_FCB_2T];
Word16 rrixiy[MSIZE]; Word16 rrixiy[MSIZE];
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
/*----------------------------------------------------------------* /*----------------------------------------------------------------*
* Compute rrixix[][] needed for the codebook search. * Compute rrixix[][] needed for the codebook search.
...@@ -63,11 +65,19 @@ void acelp_2t32_fx( ...@@ -63,11 +65,19 @@ void acelp_2t32_fx(
L_cor = L_deposit_h( 1 ); L_cor = L_deposit_h( 1 );
FOR( i = 0; i < NB_POS_FCB_2T; i++ ) FOR( i = 0; i < NB_POS_FCB_2T; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 );
#else
L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow );
#endif
ptr_h1++; ptr_h1++;
*p1-- = extract_h( L_cor ); *p1-- = extract_h( L_cor );
move16(); /*Q9 Q7*/ move16(); /*Q9 Q7*/
#ifdef ISSUE_1867_replace_overflow_libenc
L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 );
#else
L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow );
#endif
ptr_h1++; ptr_h1++;
*p0-- = extract_h( L_cor ); *p0-- = extract_h( L_cor );
move16(); /*Q9 Q7*/ move16(); /*Q9 Q7*/
...@@ -108,17 +118,28 @@ void acelp_2t32_fx( ...@@ -108,17 +118,28 @@ void acelp_2t32_fx(
L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q(12+12+1) L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q(12+12+1)
FOR( i = k; i < NB_POS_FCB_2T - 1; i++ ) FOR( i = k; i < NB_POS_FCB_2T - 1; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
*p1 = round_fx_sat( L_cor ); // Q(25-16)
L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ );
*p0 = round_fx_sat( L_cor ); // Q(9)
L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ );
#else
*p1 = round_fx_o( L_cor, &Overflow ); // Q(25-16) *p1 = round_fx_o( L_cor, &Overflow ); // Q(25-16)
L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow );
*p0 = round_fx_o( L_cor, &Overflow ); // Q(9) *p0 = round_fx_o( L_cor, &Overflow ); // Q(9)
L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow );
#endif
move16(); move16();
move16(); move16();
p1 -= ( NB_POS_FCB_2T + 1 ); p1 -= ( NB_POS_FCB_2T + 1 );
p0 -= ( NB_POS_FCB_2T + 1 ); p0 -= ( NB_POS_FCB_2T + 1 );
} }
#ifdef ISSUE_1867_replace_overflow_libenc
*p1 = round_fx_sat( L_cor ); // Q9
#else
*p1 = round_fx_o( L_cor, &Overflow ); // Q9 *p1 = round_fx_o( L_cor, &Overflow ); // Q9
#endif
pos -= NB_POS_FCB_2T; pos -= NB_POS_FCB_2T;
move16(); move16();
pos2--; pos2--;
...@@ -221,9 +242,15 @@ void acelp_2t32_fx( ...@@ -221,9 +242,15 @@ void acelp_2t32_fx(
FOR( i1 = 1; i1 < L_SUBFR; i1 += STEP ) FOR( i1 = 1; i1 < L_SUBFR; i1 += STEP )
{ {
ps2 = add( ps1, dn_p[i1] ); ps2 = add( ps1, dn_p[i1] );
#ifdef ISSUE_1867_replace_overflow_libenc
alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) );
sq = mult( ps2, ps2 );
s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 );
#else
alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow );
sq = mult( ps2, ps2 ); sq = mult( ps2, ps2 );
s = L_msu_o( L_mult( alpk, sq ), psk, alp2, &Overflow ); s = L_msu_o( L_mult( alpk, sq ), psk, alp2, &Overflow );
#endif
IF( s > 0 ) IF( s > 0 )
{ {
psk = sq; psk = sq;
......
...@@ -75,9 +75,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * ...@@ -75,9 +75,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
Word16 dummy = 0; Word16 dummy = 0;
move16(); move16();
ACELP_config *acelp_cfg; ACELP_config *acelp_cfg;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
acelp_cfg = &( st->acelp_cfg ); acelp_cfg = &( st->acelp_cfg );
...@@ -351,13 +353,22 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * ...@@ -351,13 +353,22 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision *
Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); Ltmp = Mpy_32_16_1( gain_code2, code2[i] );
Ltmp = L_shl( Ltmp, Q_new_p5 ); Ltmp = L_shl( Ltmp, Q_new_p5 );
Ltmp = L_mac( Ltmp, gain_pit, exc[i + i_subfr] ); Ltmp = L_mac( Ltmp, gain_pit, exc[i + i_subfr] );
#ifdef ISSUE_1867_replace_overflow_libenc
exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) );
#else
exc2[i] = round_fx_sat( L_shl_o( Ltmp, 1, &Overflow ) ); exc2[i] = round_fx_sat( L_shl_o( Ltmp, 1, &Overflow ) );
#endif
move16(); move16();
Ltmp2 = Mpy_32_16_1( gain_code, code[i] ); Ltmp2 = Mpy_32_16_1( gain_code, code[i] );
Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 );
Ltmp = L_add_sat( Ltmp, Ltmp2 ); Ltmp = L_add_sat( Ltmp, Ltmp2 );
#ifdef ISSUE_1867_replace_overflow_libenc
Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */
exc[i + i_subfr] = round_fx_sat( Ltmp );
#else
Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */
exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow );
#endif
move16(); move16();
} }
/*-----------------------------------------------------------------* /*-----------------------------------------------------------------*
......
...@@ -82,10 +82,13 @@ void core_encode_openloop_fx( ...@@ -82,10 +82,13 @@ void core_encode_openloop_fx(
Word16 lsp_old_q_rf[M + 1], lsf_old_q_rf[M + 1]; Word16 lsp_old_q_rf[M + 1], lsf_old_q_rf[M + 1];
(void) vad_hover_flag; (void) vad_hover_flag;
(void) vad_flag_dtx; (void) vad_flag_dtx;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
RF_ENC_HANDLE hRF = st->hRF; RF_ENC_HANDLE hRF = st->hRF;
...@@ -552,7 +555,11 @@ void core_encode_openloop_fx( ...@@ -552,7 +555,11 @@ void core_encode_openloop_fx(
/*v_sub(lsf_uq_rf, lsf_q_1st_rf, lsf_q_d_rf, M);*/ /*v_sub(lsf_uq_rf, lsf_q_1st_rf, lsf_q_d_rf, M);*/
FOR( i = 0; i < M; i++ ) FOR( i = 0; i < M; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
lsf_q_d_rf[i] = shl_sat( mult_r( sub_sat( lsf_uq_rf[i], lsf_q_1st_rf[i] ), 25600 ), 5 );
#else
lsf_q_d_rf[i] = shl_sat( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5 ); lsf_q_d_rf[i] = shl_sat( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5 );
#endif
move16(); move16();
/*input value is in Qx2.56, convert to Q6 to match table, quantizer table kept at Q6 to avoid losing precision */ /*input value is in Qx2.56, convert to Q6 to match table, quantizer table kept at Q6 to avoid losing precision */
/*Assume this difference data max range can be represented by Q6*/ /*Assume this difference data max range can be represented by Q6*/
...@@ -753,9 +760,11 @@ static void closest_centroid_rf( ...@@ -753,9 +760,11 @@ static void closest_centroid_rf(
Word16 tmp, tmpL; Word16 tmp, tmpL;
Word64 werr_64; Word64 werr_64;
Word32 L_tmp, best_werr, werr; Word32 L_tmp, best_werr, werr;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
ind_vec[0] = 0; ind_vec[0] = 0;
...@@ -771,8 +780,13 @@ static void closest_centroid_rf( ...@@ -771,8 +780,13 @@ static void closest_centroid_rf(
tmpL = i_mult2( i, length ); tmpL = i_mult2( i, length );
FOR( j = 0; j < length; j++ ) FOR( j = 0; j < length; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
tmp = sub_sat( data[j], quantizer[tmpL + j] );
L_tmp = L_mult_sat( tmp, tmp );
#else
tmp = sub_o( data[j], quantizer[tmpL + j], &Overflow ); tmp = sub_o( data[j], quantizer[tmpL + j], &Overflow );
L_tmp = L_mult_o( tmp, tmp, &Overflow ); L_tmp = L_mult_o( tmp, tmp, &Overflow );
#endif
werr_64 = W_mac_32_16( werr_64, L_tmp, weights[j] ); werr_64 = W_mac_32_16( werr_64, L_tmp, weights[j] );
} }
werr = W_sat_m( werr_64 ); werr = W_sat_m( werr_64 );
...@@ -824,9 +838,11 @@ void core_acelp_tcx20_switching_fx( ...@@ -824,9 +838,11 @@ void core_acelp_tcx20_switching_fx(
Word16 snr_tcx, snr_acelp, dsnr; Word16 snr_tcx, snr_acelp, dsnr;
TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc;
SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
/* Check minimum pitch for quantization */ /* Check minimum pitch for quantization */
...@@ -1103,7 +1119,11 @@ void core_acelp_tcx20_switching_fx( ...@@ -1103,7 +1119,11 @@ void core_acelp_tcx20_switching_fx(
FOR( j = 0; j < L_SUBFR; j++ ) FOR( j = 0; j < L_SUBFR; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
tmp32 = L_mac0_sat( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j] );
#else
tmp32 = L_mac0_o( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); tmp32 = L_mac0_o( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow );
#endif
} }
tmp32 = L_shr( BASOP_Util_Log2( tmp32 ), 9 ); /* 15Q16 */ tmp32 = L_shr( BASOP_Util_Log2( tmp32 ), 9 ); /* 15Q16 */
tmp32 = L_add( tmp32, L_sub( 0x1F0000, L_shl( L_deposit_h( add( Q_new, sub( shift, 1 ) ) ), 1 ) ) ); /* wspeech_enc scaling */ tmp32 = L_add( tmp32, L_sub( 0x1F0000, L_shl( L_deposit_h( add( Q_new, sub( shift, 1 ) ) ), 1 ) ) ); /* wspeech_enc scaling */
...@@ -1121,7 +1141,11 @@ void core_acelp_tcx20_switching_fx( ...@@ -1121,7 +1141,11 @@ void core_acelp_tcx20_switching_fx(
tcx_snr = L_shl( Mpy_32_16_1( tcx_snr, 0x6054 ), 2 ); /* 0x6054 -> 10/log2(10) (2Q13) */ tcx_snr = L_shl( Mpy_32_16_1( tcx_snr, 0x6054 ), 2 ); /* 0x6054 -> 10/log2(10) (2Q13) */
BASOP_SATURATE_WARNING_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS
#ifdef ISSUE_1867_replace_overflow_libenc
snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */
#else
snr_tcx = round_fx_o( L_shl_o( tcx_snr, 8, &Overflow ), &Overflow ); /* 7Q8 */ snr_tcx = round_fx_o( L_shl_o( tcx_snr, 8, &Overflow ), &Overflow ); /* 7Q8 */
#endif
BASOP_SATURATE_WARNING_ON_EVS BASOP_SATURATE_WARNING_ON_EVS
/*--------------------------------------------------------------* /*--------------------------------------------------------------*
...@@ -1155,11 +1179,19 @@ void core_acelp_tcx20_switching_fx( ...@@ -1155,11 +1179,19 @@ void core_acelp_tcx20_switching_fx(
FOR( j = 0; j < L_SUBFR; j++ ) FOR( j = 0; j < L_SUBFR; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
signal = L_mac0_sat( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j] );
tmp16 = round_fx_sat( L_shl_sat( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15 ) );
tmp16 = sub_sat( st->wspeech_enc[i + j], tmp16 );
noise = L_mac0_sat( noise, tmp16, tmp16 );
#else
signal = L_mac0_o( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); signal = L_mac0_o( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow );
tmp16 = round_fx_o( L_shl_o( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15, &Overflow ), &Overflow ); tmp16 = round_fx_o( L_shl_o( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15, &Overflow ), &Overflow );
tmp16 = sub_o( st->wspeech_enc[i + j], tmp16, &Overflow ); tmp16 = sub_o( st->wspeech_enc[i + j], tmp16, &Overflow );
noise = L_mac0_o( noise, tmp16, tmp16, &Overflow ); noise = L_mac0_o( noise, tmp16, tmp16, &Overflow );
#endif
} }
/* Assume always 4 sub frames. */ /* Assume always 4 sub frames. */
/*assert( (st->L_frame / L_SUBFR) == 4);*/ /*assert( (st->L_frame / L_SUBFR) == 4);*/
...@@ -1212,7 +1244,11 @@ void core_acelp_tcx20_switching_fx( ...@@ -1212,7 +1244,11 @@ void core_acelp_tcx20_switching_fx(
test(); test();
if ( ( GT_16( snr_acelp, snr_tcx ) ) && if ( ( GT_16( snr_acelp, snr_tcx ) ) &&
( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) && ( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) &&
#ifdef ISSUE_1867_replace_overflow_libenc
( LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) ||
#else
( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) ||
#endif
( EQ_32( st->sr_core, INT_FS_12k8 ) && EQ_16( st->sp_aud_decision0, 1 ) && LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 2560 /*20.f Q7*/ ) ) ) && ( EQ_32( st->sr_core, INT_FS_12k8 ) && EQ_16( st->sp_aud_decision0, 1 ) && LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 2560 /*20.f Q7*/ ) ) ) &&
( LE_16( st->acelpFramesCount, 6 ) ) ) ( LE_16( st->acelpFramesCount, 6 ) ) )
{ {
......
...@@ -31,9 +31,11 @@ void corr_xh_fx( ...@@ -31,9 +31,11 @@ void corr_xh_fx(
{ {
Word16 i, j, k; Word16 i, j, k;
Word32 L_tmp, y32[L_SUBFR], L_maxloc, L_tot; Word32 L_tmp, y32[L_SUBFR], L_maxloc, L_tot;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move16(); move16();
#endif
#endif #endif
/* first keep the result on 32 bits and find absolute maximum */ /* first keep the result on 32 bits and find absolute maximum */
...@@ -47,7 +49,11 @@ void corr_xh_fx( ...@@ -47,7 +49,11 @@ void corr_xh_fx(
L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/ L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/
FOR( j = i; j < L_SUBFR - 1; j++ ) FOR( j = i; j < L_SUBFR - 1; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac_sat( L_tmp, x[j + 1], h[j + 1 - i] ); /*Qx+15*/
#else
L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/
#endif
} }
y32[i] = L_tmp; /*Qx+15*/ y32[i] = L_tmp; /*Qx+15*/
...@@ -57,8 +63,13 @@ void corr_xh_fx( ...@@ -57,8 +63,13 @@ void corr_xh_fx(
} }
/* tot += 3*max / 8 */ /* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 ); L_maxloc = L_shr( L_maxloc, 2 );
#ifdef ISSUE_1867_replace_overflow_libenc
L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */
L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */
#else
L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */ L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */
L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */
#endif
} }
/* Find the number of right shifts to do on y32[] so that */ /* Find the number of right shifts to do on y32[] so that */
...@@ -82,9 +93,11 @@ void corr_hh_ivas_fx( ...@@ -82,9 +93,11 @@ void corr_hh_ivas_fx(
{ {
Word16 i, j, k; Word16 i, j, k;
Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot; Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move16(); move16();
#endif
#endif #endif
/* first keep the result on 32 bits and find absolute maximum */ /* first keep the result on 32 bits and find absolute maximum */
...@@ -98,7 +111,11 @@ void corr_hh_ivas_fx( ...@@ -98,7 +111,11 @@ void corr_hh_ivas_fx(
L_tmp = L_mac( 1L, shr( h[i], 3 ), shr( h[0], 3 ) ); /* 1 -> to avoid null dn[] */ // 2*(15 - norm_s(h[0]) -3) - 1 L_tmp = L_mac( 1L, shr( h[i], 3 ), shr( h[0], 3 ) ); /* 1 -> to avoid null dn[] */ // 2*(15 - norm_s(h[0]) -3) - 1
FOR( j = i; j < L_subfr - 1; j++ ) FOR( j = i; j < L_subfr - 1; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac_sat( L_tmp, shr( h[j + 1], 3 ), shr( h[j + 1 - i], 3 ) ); // 2*(15 - norm_s(h[0]) -3) - 1 //?sat
#else
L_tmp = L_mac_o( L_tmp, shr( h[j + 1], 3 ), shr( h[j + 1 - i], 3 ), &Overflow ); // 2*(15 - norm_s(h[0]) -3) - 1 L_tmp = L_mac_o( L_tmp, shr( h[j + 1], 3 ), shr( h[j + 1 - i], 3 ), &Overflow ); // 2*(15 - norm_s(h[0]) -3) - 1
#endif
} }
y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1 y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1
...@@ -108,8 +125,13 @@ void corr_hh_ivas_fx( ...@@ -108,8 +125,13 @@ void corr_hh_ivas_fx(
} }
/* tot += 3*max / 8 */ /* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 ); L_maxloc = L_shr( L_maxloc, 2 );
#ifdef ISSUE_1867_replace_overflow_libenc
L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */
L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */
#else
L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */ L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */
L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */
#endif
} }
/* Find the number of right shifts to do on y32[] so that */ /* Find the number of right shifts to do on y32[] so that */
...@@ -139,9 +161,11 @@ void corr_xh_ivas_fx( ...@@ -139,9 +161,11 @@ void corr_xh_ivas_fx(
{ {
Word16 i, j, k; Word16 i, j, k;
Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot; Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move16(); move16();
#endif
#endif #endif
/* first keep the result on 32 bits and find absolute maximum */ /* first keep the result on 32 bits and find absolute maximum */
...@@ -155,7 +179,11 @@ void corr_xh_ivas_fx( ...@@ -155,7 +179,11 @@ void corr_xh_ivas_fx(
L_tmp = L_mac( 0, x[i], h[0] ); // Qx+(14 - norm_s(h[0])) + 1 L_tmp = L_mac( 0, x[i], h[0] ); // Qx+(14 - norm_s(h[0])) + 1
FOR( j = i; j < L_subfr - 1; j++ ) FOR( j = i; j < L_subfr - 1; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac_sat( L_tmp, x[j + 1], h[j + 1 - i] ); // Qx+(14 - norm_s(h[0])) + 1
#else
L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); // Qx+(14 - norm_s(h[0])) + 1 L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); // Qx+(14 - norm_s(h[0])) + 1
#endif
} }
y32[i] = L_tmp; // Qx+(14 - norm_s(h[0])) + 1 y32[i] = L_tmp; // Qx+(14 - norm_s(h[0])) + 1
...@@ -165,8 +193,13 @@ void corr_xh_ivas_fx( ...@@ -165,8 +193,13 @@ void corr_xh_ivas_fx(
} }
/* tot += 3*max / 8 */ /* tot += 3*max / 8 */
L_maxloc = L_shr( L_maxloc, 2 ); L_maxloc = L_shr( L_maxloc, 2 );
#ifdef ISSUE_1867_replace_overflow_libenc
L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */
L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */
#else
L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */ L_tot = L_add_o( L_tot, L_maxloc, &Overflow ); /* +max/4 */
L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */
#endif
} }
/* Find the number of right shifts to do on y32[] so that */ /* Find the number of right shifts to do on y32[] so that */
......
...@@ -62,22 +62,34 @@ static void hp_filter_fx( ...@@ -62,22 +62,34 @@ static void hp_filter_fx(
{ {
Word16 i; Word16 i;
Word32 L_tmp; Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
/*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */ /*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mult( sub_sat( x[0], *oldx ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */
#else
L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */
#endif
L_tmp = L_mac_sat( L_tmp, *oldy, 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ L_tmp = L_mac_sat( L_tmp, *oldy, 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */
y[0] = round_fx_sat( L_tmp ); /*Q_new */ y[0] = round_fx_sat( L_tmp ); /*Q_new */
FOR( i = 1; i < L; i++ ) FOR( i = 1; i < L; i++ )
{ {
/*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mult( sub_sat( x[i], x[i - 1] ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */
L_tmp = L_mac_sat( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */
y[i] = round_fx_sat( L_tmp ); /*Q_new */
#else
L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ L_tmp = L_mult( sub_o( x[i], x[i - 1], &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */
L_tmp = L_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */ L_tmp = L_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */
y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */ y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */
#endif
} }
*oldx = x[L - 1]; *oldx = x[L - 1];
...@@ -117,9 +129,11 @@ Word16 detect_transient_fx( ...@@ -117,9 +129,11 @@ Word16 detect_transient_fx(
Word32 E_low_fx, E_high_fx; Word32 E_low_fx, E_high_fx;
Word16 temp16, Thres_fx = 0; Word16 temp16, Thres_fx = 0;
Word16 exp; Word16 exp;
#ifdef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
shift = 0; shift = 0;
...@@ -151,7 +165,11 @@ Word16 detect_transient_fx( ...@@ -151,7 +165,11 @@ Word16 detect_transient_fx(
FOR( i = 0; i < L / 4; i++ ) FOR( i = 0; i < L / 4; i++ )
{ {
/*EnergyLT += out_filt[i] * out_filt[i]; */ /*EnergyLT += out_filt[i] * out_filt[i]; */
#ifdef ISSUE_1867_replace_overflow_libenc
EnergyLT = L_mac0_sat( EnergyLT, out_filt_fx[i], out_filt_fx[i] ); /*2Q_new */
#else
EnergyLT = L_mac0_o( EnergyLT, out_filt_fx[i], out_filt_fx[i], &Overflow ); /*2Q_new */ EnergyLT = L_mac0_o( EnergyLT, out_filt_fx[i], out_filt_fx[i], &Overflow ); /*2Q_new */
#endif
} }
} }
ELSE ELSE
...@@ -170,14 +188,27 @@ Word16 detect_transient_fx( ...@@ -170,14 +188,27 @@ Word16 detect_transient_fx(
FOR( i = 0; i < L / 4; i++ ) FOR( i = 0; i < L / 4; i++ )
{ {
temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) );
#ifdef ISSUE_1867_replace_overflow_libenc
Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) );
#else
Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow ); Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow );
#endif
temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/
#ifdef ISSUE_1867_replace_overflow_libenc
Energy_in_fx[blk + 1] = L_add_sat( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); /*Q0*/
#else
Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/ Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/
#endif
move32(); move32();
} }
#ifdef ISSUE_1867_replace_overflow_libenc
E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/
E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/
#else
E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow ); /*Q0*/ E_in_fx = L_add_o( E_in_fx, Energy_in_fx[blk + 1], &Overflow ); /*Q0*/
E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/ E_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/
#endif
Thres_fx = 2185; /*1 /15 Q15*/ Thres_fx = 2185; /*1 /15 Q15*/
move16(); move16();
...@@ -201,13 +232,21 @@ Word16 detect_transient_fx( ...@@ -201,13 +232,21 @@ Word16 detect_transient_fx(
FOR( i = 0; i < L / 8; i++ ) FOR( i = 0; i < L / 8; i++ )
{ {
/*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac0_sat( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */
#else
L_tmp = L_mac0_o( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ L_tmp = L_mac0_o( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */
#endif
} }
L_tmp2 = L_deposit_l( 0 ); L_tmp2 = L_deposit_l( 0 );
FOR( ; i < L / 4; i++ ) FOR( ; i < L / 4; i++ )
{ {
/*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp2 = L_mac0_sat( L_tmp2, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */
#else
L_tmp2 = L_mac0_o( L_tmp2, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ L_tmp2 = L_mac0_o( L_tmp2, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */
#endif
} }
Overflow = 0; Overflow = 0;
move16(); move16();
...@@ -218,10 +257,14 @@ Word16 detect_transient_fx( ...@@ -218,10 +257,14 @@ Word16 detect_transient_fx(
shift = 1; shift = 1;
move16(); move16();
} }
#ifndef ISSUE_1867_replace_overflow_libenc
Overflow = 0; Overflow = 0;
move16(); move16();
Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow ); /*2Q_new - shift*/ Energy = L_add_o( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ), &Overflow ); /*2Q_new - shift*/
#else
Energy = L_add_sat( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) ); /*2Q_new - shift*/
#endif
test(); test();
IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) )
{ {
...@@ -262,7 +305,11 @@ Word16 detect_transient_fx( ...@@ -262,7 +305,11 @@ Word16 detect_transient_fx(
} }
/*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */
/*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */
#ifdef ISSUE_1867_replace_overflow_libenc
EnergyLT = L_add_sat( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ) ); /*2Q_new */
#else
EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ), &Overflow ); /*2Q_new */ EnergyLT = L_add_o( Mult_32_16( EnergyLT, 24576 /*0.75f in Q15*/ ), Mult_32_16( Energy, shl( 8192 /*0.25 in Q15*/, shift ) ), &Overflow ); /*2Q_new */
#endif
} }
} }
st_fx->EnergyLT_fx = EnergyLT; st_fx->EnergyLT_fx = EnergyLT;
......
...@@ -74,9 +74,11 @@ void dtx_ivas_fx( ...@@ -74,9 +74,11 @@ void dtx_ivas_fx(
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
Word32 total_brate_ref; Word32 total_brate_ref;
...@@ -461,7 +463,11 @@ void dtx_ivas_fx( ...@@ -461,7 +463,11 @@ void dtx_ivas_fx(
speech++; speech++;
FOR( i = 1; i < L_FRAME / 16; i++ ) FOR( i = 1; i < L_FRAME / 16; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/
#else
L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/
#endif
speech++; speech++;
} }
hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */ hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /* Q(-7) */
...@@ -631,9 +637,11 @@ void dtx_fx( ...@@ -631,9 +637,11 @@ void dtx_fx(
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
IF( st_fx->dtx_sce_sba != 0 ) IF( st_fx->dtx_sce_sba != 0 )
...@@ -931,7 +939,11 @@ void dtx_fx( ...@@ -931,7 +939,11 @@ void dtx_fx(
speech++; speech++;
FOR( i = 1; i < L_FRAME / 16; i++ ) FOR( i = 1; i < L_FRAME / 16; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/
#else
L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/
#endif
speech++; speech++;
} }
hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */ hDtxEnc->frame_ener_fx = L_add( hDtxEnc->frame_ener_fx, L_shr( L_tmp, Q_speech2 ) ); /*Q(-7) */
...@@ -1236,8 +1248,10 @@ void dtx_hangover_control_fx( ...@@ -1236,8 +1248,10 @@ void dtx_hangover_control_fx(
VAD_HANDLE hVAD = st_fx->hVAD; VAD_HANDLE hVAD = st_fx->hVAD;
DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
#endif
#endif #endif
/* get current frame exc energy in log2 */ /* get current frame exc energy in log2 */
...@@ -1407,7 +1421,11 @@ void dtx_hangover_control_fx( ...@@ -1407,7 +1421,11 @@ void dtx_hangover_control_fx(
move16(); move16();
FOR( j = 0; j < m; j++ ) FOR( j = 0; j < m; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */
#else
lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */
#endif
} }
lsp_est[i] = sub( lsp_est[i], tmp[max_idx[0] * M + i] ); /*Q15 */ lsp_est[i] = sub( lsp_est[i], tmp[max_idx[0] * M + i] ); /*Q15 */
...@@ -1423,10 +1441,18 @@ void dtx_hangover_control_fx( ...@@ -1423,10 +1441,18 @@ void dtx_hangover_control_fx(
move16(); move16();
FOR( j = 0; j < m; j++ ) FOR( j = 0; j < m; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */
#else
lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */
#endif
} }
#ifdef ISSUE_1867_replace_overflow_libenc
lsp_est[i] = sub_sat( lsp_est[i], add_sat( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i] ) ); /*Q15 */
#else
lsp_est[i] = sub_o( lsp_est[i], add_o( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i], &Overflow ), &Overflow ); /*Q15 */ lsp_est[i] = sub_o( lsp_est[i], add_o( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i], &Overflow ), &Overflow ); /*Q15 */
#endif
S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */ S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */
lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */ lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */
} }
...@@ -1436,7 +1462,11 @@ void dtx_hangover_control_fx( ...@@ -1436,7 +1462,11 @@ void dtx_hangover_control_fx(
move16(); move16();
FOR( i = 0; i < M; i++ ) FOR( i = 0; i < M; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
Dlsp_n2e = add_sat( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ) ); /*Q15 */
#else
Dlsp_n2e = add_o( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ), &Overflow ); /*Q15 */ Dlsp_n2e = add_o( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ), &Overflow ); /*Q15 */
#endif
lsp_est[i] = add( mult_r( 26214, lsp_est[i] ), mult_r( 6554, lsp_new_fx[i] ) ); /*Q15 */ lsp_est[i] = add( mult_r( 26214, lsp_est[i] ), mult_r( 6554, lsp_new_fx[i] ) ); /*Q15 */
} }
...@@ -1449,7 +1479,11 @@ void dtx_hangover_control_fx( ...@@ -1449,7 +1479,11 @@ void dtx_hangover_control_fx(
FOR( i = 0; i < M; i++ ) FOR( i = 0; i < M; i++ )
{ {
S_tmp = abs_s( sub( hDtxEnc->lspCNG_fx[i], lsp_est[i] ) ); /*Q15 */ S_tmp = abs_s( sub( hDtxEnc->lspCNG_fx[i], lsp_est[i] ) ); /*Q15 */
#ifdef ISSUE_1867_replace_overflow_libenc
Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */
#else
Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */
#endif
IF( GT_16( S_tmp, S_max ) ) IF( GT_16( S_tmp, S_max ) )
{ {
S_max = S_tmp; /*Q15 */ S_max = S_tmp; /*Q15 */
......
...@@ -58,9 +58,11 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac ...@@ -58,9 +58,11 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
Word16 *dn2; Word16 *dn2;
Word16 *p0, *p1, *p2; Word16 *p0, *p1, *p2;
Word32 L_sum; Word32 L_sum;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
dn2 = &dn2_pos[( track * 8 )]; /*Q0*/ dn2 = &dn2_pos[( track * 8 )]; /*Q0*/
...@@ -75,20 +77,36 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac ...@@ -75,20 +77,36 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
p2 = &vec[dn]; /*Qx*/ p2 = &vec[dn]; /*Qx*/
FOR( j = dn; j < L_SUBFR - 1; j++ ) FOR( j = dn; j < L_SUBFR - 1; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_sum = L_mac_sat( L_sum, *p1++, *p2++ ); /*2*Qx+1*/
#else
L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /*2*Qx+1*/ L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /*2*Qx+1*/
#endif
} }
#ifdef ISSUE_1867_replace_overflow_libenc
corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/
#else
corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/
#endif
/*cor[dn >> 2] = sign[dn] * s + p0[dn >> 2];*/ /*cor[dn >> 2] = sign[dn] * s + p0[dn >> 2];*/
j = shr( dn, 2 ); j = shr( dn, 2 );
if ( sign[dn] > 0 ) if ( sign[dn] > 0 )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
corr = add_sat( p0[j], corr ); /*Q9*/
#else
corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ corr = add_o( p0[j], corr, &Overflow ); /*Q9*/
#endif
} }
if ( sign[dn] < 0 ) if ( sign[dn] < 0 )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
corr = sub_sat( p0[j], corr ); /*Q9*/
#else
corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/
#endif
} }
cor[j] = corr; /*Q9*/ cor[j] = corr; /*Q9*/
...@@ -102,9 +120,11 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac ...@@ -102,9 +120,11 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
Word16 i, j, pos, corr; Word16 i, j, pos, corr;
Word16 *p0, *p1, *p2; Word16 *p0, *p1, *p2;
Word32 L_sum; Word32 L_sum;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
p0 = rrixix[track]; /*Q9*/ p0 = rrixix[track]; /*Q9*/
...@@ -118,12 +138,30 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac ...@@ -118,12 +138,30 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
p2 = &vec[pos]; /*Qx*/ p2 = &vec[pos]; /*Qx*/
FOR( j = pos; j < L_SUBFR - 1; j++ ) FOR( j = pos; j < L_SUBFR - 1; j++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_sum = L_mac_sat( L_sum, *p1++, *p2++ ); /* 2*Qx+1 */
#else
L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /* 2*Qx+1 */ L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /* 2*Qx+1 */
#endif
} }
#ifdef ISSUE_1867_replace_overflow_libenc
corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/
#else
corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/
#endif
/*cor[i] = s * sign[track] + p0[i];*/ /*cor[i] = s * sign[track] + p0[i];*/
#ifdef ISSUE_1867_replace_overflow_libenc
if ( sign[pos] > 0 )
{
corr = add_sat( *p0++, corr ); /*Q9*/
}
if ( sign[pos] < 0 )
{
corr = sub_sat( *p0++, corr ); /*Q9*/
}
#else
if ( sign[pos] > 0 ) if ( sign[pos] > 0 )
{ {
corr = add_o( *p0++, corr, &Overflow ); /*Q9*/ corr = add_o( *p0++, corr, &Overflow ); /*Q9*/
...@@ -132,6 +170,7 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac ...@@ -132,6 +170,7 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
{ {
corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/ corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/
} }
#endif
cor[i] = corr; /*Q9*/ cor[i] = corr; /*Q9*/
move16(); move16();
...@@ -174,10 +213,12 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* ...@@ -174,10 +213,12 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
Word32 xy_save; Word32 xy_save;
Word16 check = 0; /* debug code not instrumented */ Word16 check = 0; /* debug code not instrumented */
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
/* eight dn2 max positions per track */ /* eight dn2 max positions per track */
...@@ -195,7 +236,11 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* ...@@ -195,7 +236,11 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
sqk[0] = -1; sqk[0] = -1;
move16(); move16();
x2 = shr( pos_x[0], 2 ); /*Qdn*/ x2 = shr( pos_x[0], 2 ); /*Qdn*/
#ifdef ISSUE_1867_replace_overflow_libenc
if ( mac_r_sat( L_mac_sat( L_mac_sat( alp0, cor_x[x2], _1_ ), cor_y[0], _1_ ), rrixiy[track_x][( x2 * 16 )], _1_ ) < 0 )
#else
if ( mac_ro( L_mac_o( L_mac_o( alp0, cor_x[x2], _1_, &Overflow ), cor_y[0], _1_, &Overflow ), rrixiy[track_x][( x2 * 16 )], _1_, &Overflow ) < 0 ) if ( mac_ro( L_mac_o( L_mac_o( alp0, cor_x[x2], _1_, &Overflow ), cor_y[0], _1_, &Overflow ), rrixiy[track_x][( x2 * 16 )], _1_, &Overflow ) < 0 )
#endif
{ {
sqk[0] = 1; sqk[0] = 1;
move16(); move16();
...@@ -215,7 +260,11 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* ...@@ -215,7 +260,11 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
ps1 = add( ps0, dn[x] ); /*Qdn*/ ps1 = add( ps0, dn[x] ); /*Qdn*/
/*alp1 = alp0 + cor_x[x2];*/ /*alp1 = alp0 + cor_x[x2];*/
#ifdef ISSUE_1867_replace_overflow_libenc
alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/
#else
alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/ alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/
#endif
p1 = cor_y; /*Qx*/ p1 = cor_y; /*Qx*/
p2 = &rrixiy[track_x][( x2 * 16 )]; /*Q9*/ p2 = &rrixiy[track_x][( x2 * 16 )]; /*Q9*/
...@@ -227,8 +276,13 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* ...@@ -227,8 +276,13 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
move16(); move16();
/*alp2 = alp1 + (*p1++) + (*p2++);*/ /*alp2 = alp1 + (*p1++) + (*p2++);*/
#ifdef ISSUE_1867_replace_overflow_libenc
alp2 = L_mac_sat( alp1, *p1++, _1_ ); /*Qx+12+1*/
alp2_16 = mac_r_sat( alp2, *p2++, _1_ ); /*Q6*/
#else
alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/ alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/
alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/
#endif
alpk[1 - ik] = alp2_16; /*Q6*/ alpk[1 - ik] = alp2_16; /*Q6*/
move16(); move16();
...@@ -523,19 +577,29 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn ...@@ -523,19 +577,29 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
Word16 i, Q_xn; Word16 i, Q_xn;
Word16 xy, yy, exp_xy, exp_yy, gain; Word16 xy, yy, exp_xy, exp_yy, gain;
Word32 L_off; Word32 L_off;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, s_min( add( exp_xn, exp_xn ), 31 ) ); L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, s_min( add( exp_xn, exp_xn ), 31 ) );
L_off = L_max( 1, L_off ); /* ensure at least a '1' */ L_off = L_max( 1, L_off ); /* ensure at least a '1' */
/* Compute scalar product t1: <y1[] * y1[]> */ /* Compute scalar product t1: <y1[] * y1[]> */
#ifdef ISSUE_1867_replace_overflow_libenc
yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/
#else
yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow ); /*Q15 - exp_yy*/ yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow ); /*Q15 - exp_yy*/
#endif
/* Compute scalar product t0: <xn[] * y1[]> */ /* Compute scalar product t0: <xn[] * y1[]> */
#ifdef ISSUE_1867_replace_overflow_libenc
xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/
#else
xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow ); /*Q15 - exp_xy*/ xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow ); /*Q15 - exp_xy*/
#endif
/* Compute doubled format out of the exponent */ /* Compute doubled format out of the exponent */
Q_xn = shl( sub( 15, exp_xn ), 1 ); Q_xn = shl( sub( 15, exp_xn ), 1 );
g_corr->y1y1 = yy; g_corr->y1y1 = yy;
...@@ -577,7 +641,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn ...@@ -577,7 +641,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
Word16 tmp, exp_tmp, exp_div; Word16 tmp, exp_tmp, exp_div;
/* Compute scalar product <xn[],xn[]> */ /* Compute scalar product <xn[],xn[]> */
#ifdef ISSUE_1867_replace_overflow_libenc
tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/
#else
tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/ tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/
#endif
/* gain_p_snr = sqrt(<xn,xn>/<y1,y1>) */ /* gain_p_snr = sqrt(<xn,xn>/<y1,y1>) */
tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div ); tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div );
exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div ); exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div );
...@@ -587,7 +655,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn ...@@ -587,7 +655,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
/* Note: shl works as shl or shr. */ /* Note: shl works as shl or shr. */
exp_tmp = sub( exp_tmp, 1 ); exp_tmp = sub( exp_tmp, 1 );
BASOP_SATURATE_WARNING_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS
#ifdef ISSUE_1867_replace_overflow_libenc
tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) ); /*Q14*/
#else
tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/ tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/
#endif
BASOP_SATURATE_WARNING_ON_EVS BASOP_SATURATE_WARNING_ON_EVS
gain = s_min( gain, tmp ); /*Q14*/ gain = s_min( gain, tmp ); /*Q14*/
...@@ -684,9 +756,11 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, ...@@ -684,9 +756,11 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/,
{ {
Word16 i, Q15_flag; Word16 i, Q15_flag;
Word32 L_tmp; Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
assert( gain >= 0 ); assert( gain >= 0 );
...@@ -704,9 +778,17 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, ...@@ -704,9 +778,17 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/,
L_tmp = L_deposit_h( x[i] ); /*Q_xn+16*/ L_tmp = L_deposit_h( x[i] ); /*Q_xn+16*/
if ( Q15_flag == 0 ) if ( Q15_flag == 0 )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/
#else
L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow ); /*Q_xn+15*/ L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow ); /*Q_xn+15*/
#endif
} }
#ifdef ISSUE_1867_replace_overflow_libenc
x2[i] = msu_r_sat( L_tmp, y[i], gain ); /*Q_xn*/
#else
x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/ x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/
#endif
move16(); move16();
} }
} }
...@@ -740,10 +822,12 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 ...@@ -740,10 +822,12 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
Word16 signs[3]; Word16 signs[3];
Word16 *ptr16; Word16 *ptr16;
Word16 val, index; Word16 val, index;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
/* calculate energy for normalization of cn[] and dn[] */ /* calculate energy for normalization of cn[] and dn[] */
...@@ -752,7 +836,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 ...@@ -752,7 +836,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
FOR( i = 1; i < L_subfr; i++ ) FOR( i = 1; i < L_subfr; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
Lval = L_mac0_sat( Lval, cn[i], cn[i] ); /*2*Q_xn*/
#else
Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/ Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/
#endif
Lcor = L_mac0( Lcor, dn[i], dn[i] ); /*2*Qdn*/ Lcor = L_mac0( Lcor, dn[i], dn[i] ); /*2*Qdn*/
} }
...@@ -769,8 +857,13 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 ...@@ -769,8 +857,13 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
if ( i > 0 ) if ( i > 0 )
Lcor = L_shr( Lcor, i ); Lcor = L_shr( Lcor, i );
#ifdef ISSUE_1867_replace_overflow_libenc
k_dn = round_fx_sat( Lval ); /*Q15 - e_dn*/
k_cn = round_fx_sat( Lcor ); /*Q15 - e_cn*/
#else
k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/ k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/
k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/
#endif
k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */ k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */
k_dn = mult_r( alp, k_dn ); /* alp in Q13 */ k_dn = mult_r( alp, k_dn ); /* alp in Q13 */
...@@ -790,7 +883,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 ...@@ -790,7 +883,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
/*cor = (s * cn[i]) + (alp * dn[i]); MULT(1);MAC(1);*/ /*cor = (s * cn[i]) + (alp * dn[i]); MULT(1);MAC(1);*/
Lcor = L_mult( cn[i], k_cn ); /*Q_xn + Q15 - e_cn + 1*/ Lcor = L_mult( cn[i], k_cn ); /*Q_xn + Q15 - e_cn + 1*/
Lcor = L_mac( Lcor, dn[i], k_dn ); /*Qdn + Q15 - e_dn + 1*/ Lcor = L_mac( Lcor, dn[i], k_dn ); /*Qdn + Q15 - e_dn + 1*/
#ifdef ISSUE_1867_replace_overflow_libenc
val = round_fx_sat( L_shl_sat( Lcor, 4 ) ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/
#else
val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/ val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/
#endif
index = shr( val, 15 ); index = shr( val, 15 );
sign[i] = ptr16[index]; /*Q15*/ sign[i] = ptr16[index]; /*Q15*/
...@@ -1086,10 +1183,12 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const ...@@ -1086,10 +1183,12 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
Word32 s, L_tmp; Word32 s, L_tmp;
Word16 nb_pulse, nb_pulse_m2; Word16 nb_pulse, nb_pulse_m2;
Word16 check = 0; /* debug code not instrumented */ Word16 check = 0; /* debug code not instrumented */
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif #endif
#endif
alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */ alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */
...@@ -1128,7 +1227,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const ...@@ -1128,7 +1227,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
BASOP_SATURATE_WARNING_OFF_EVS BASOP_SATURATE_WARNING_OFF_EVS
FOR( i = 0; i < L_SUBFR; i++ ) FOR( i = 0; i < L_SUBFR; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/
#else
L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/ L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/
#endif
} }
val = extract_h( L_tmp ); /*Q9*/ val = extract_h( L_tmp ); /*Q9*/
BASOP_SATURATE_WARNING_ON_EVS BASOP_SATURATE_WARNING_ON_EVS
...@@ -1278,7 +1381,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const ...@@ -1278,7 +1381,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/ L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/
FOR( i = 1; i < L_SUBFR; i++ ) FOR( i = 1; i < L_SUBFR; i++ )
#ifdef ISSUE_1867_replace_overflow_libenc
L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/
#else
L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/ L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/
#endif
alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/ alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/
...@@ -1335,7 +1442,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const ...@@ -1335,7 +1442,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
FOR( i = 0; i < L_SUBFR; i++ ) FOR( i = 0; i < L_SUBFR; i++ )
{ {
tmp = add( *p0++, *p1++ ); tmp = add( *p0++, *p1++ );
#ifdef ISSUE_1867_replace_overflow_libenc
vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */
#else
vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */ vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */
#endif
move16(); move16();
} }
} }
...@@ -1385,7 +1496,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const ...@@ -1385,7 +1496,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
} }
FOR( i = 0; i < L_SUBFR; i++ ) FOR( i = 0; i < L_SUBFR; i++ )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/
#else
y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/
#endif
move16(); move16();
} }
} }
......
...@@ -139,9 +139,11 @@ static void E_ACELP_2pulse_searchx_fx( ...@@ -139,9 +139,11 @@ static void E_ACELP_2pulse_searchx_fx(
Word32 alp0, alp1, alp2, s; Word32 alp0, alp1, alp2, s;
Word16 *pR, sgnx; Word16 *pR, sgnx;
Word16 sqk[2], alpk[2], ik; Word16 sqk[2], alpk[2], ik;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
/* eight dn2 max positions per track */ /* eight dn2 max positions per track */
...@@ -167,8 +169,11 @@ static void E_ACELP_2pulse_searchx_fx( ...@@ -167,8 +169,11 @@ static void E_ACELP_2pulse_searchx_fx(
{ {
sgnx = negate( sgnx ); sgnx = negate( sgnx );
} }
#ifdef ISSUE_1867_replace_overflow_libenc
if ( mac_r_sat( L_mac_sat( L_mac_sat( alp0, cor[x], sign[x] ), cor[track_y], sign[track_y] ), R[track_y - x], sgnx ) < 0 )
#else
if ( mac_ro( L_mac_o( L_mac_o( alp0, cor[x], sign[x], &Overflow ), cor[track_y], sign[track_y], &Overflow ), R[track_y - x], sgnx, &Overflow ) < 0 ) if ( mac_ro( L_mac_o( L_mac_o( alp0, cor[x], sign[x], &Overflow ), cor[track_y], sign[track_y], &Overflow ), R[track_y - x], sgnx, &Overflow ) < 0 )
#endif
{ {
sqk[0] = 1; sqk[0] = 1;
move16(); move16();
...@@ -189,7 +194,11 @@ static void E_ACELP_2pulse_searchx_fx( ...@@ -189,7 +194,11 @@ static void E_ACELP_2pulse_searchx_fx(
/*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/ /*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/
ps1 = add_sat( ps0, dn[x] ); /*Qdn*/ ps1 = add_sat( ps0, dn[x] ); /*Qdn*/
/*alp1 = alp0 + 2*sgnx*cor[x]; INDIRECT(1);MULT(1); MAC(1);*/ /*alp1 = alp0 + 2*sgnx*cor[x]; INDIRECT(1);MULT(1); MAC(1);*/
#ifdef ISSUE_1867_replace_overflow_libenc
alp1 = L_mac_sat( alp0, cor[x], sgnx ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#else
alp1 = L_mac_o( alp0, cor[x], sgnx, &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ alp1 = L_mac_o( alp0, cor[x], sgnx, &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
pR = R - x; /*Q9+scale*/ pR = R - x; /*Q9+scale*/
FOR( y = track_y; y < L_SUBFR; y += 4 ) FOR( y = track_y; y < L_SUBFR; y += 4 )
...@@ -204,14 +213,26 @@ static void E_ACELP_2pulse_searchx_fx( ...@@ -204,14 +213,26 @@ static void E_ACELP_2pulse_searchx_fx(
assert( sgnx != 0 ); assert( sgnx != 0 );
alp2_16 = 0; alp2_16 = 0;
#ifdef ISSUE_1867_replace_overflow_libenc
alp2 = L_mac_sat( alp1, cor[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#else
alp2 = L_mac_o( alp1, cor[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ alp2 = L_mac_o( alp1, cor[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
if ( sgnx > 0 ) if ( sgnx > 0 )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
alp2_16 = mac_r_sat( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#else
alp2_16 = mac_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ alp2_16 = mac_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
} }
if ( sgnx < 0 ) if ( sgnx < 0 )
{ {
#ifdef ISSUE_1867_replace_overflow_libenc
alp2_16 = msu_r_sat( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#else
alp2_16 = msu_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ alp2_16 = msu_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
} }
alpk[1 - ik] = alp2_16; /* Qalp */ alpk[1 - ik] = alp2_16; /* Qalp */
move16(); move16();
...@@ -223,7 +244,11 @@ static void E_ACELP_2pulse_searchx_fx( ...@@ -223,7 +244,11 @@ static void E_ACELP_2pulse_searchx_fx(
/*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/ /*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/
#ifdef ISSUE_1867_replace_overflow_libenc
s = L_msu_sat( L_mult( alpk[ik], sq ), sqk[ik], alp2_16 ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */
#else
s = L_msu_o( L_mult( alpk[ik], sq ), sqk[ik], alp2_16, &Overflow ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ s = L_msu_o( L_mult( alpk[ik], sq ), sqk[ik], alp2_16, &Overflow ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */
#endif
if ( s > 0 ) if ( s > 0 )
{ {
ik = sub( 1, ik ); ik = sub( 1, ik );
...@@ -281,9 +306,11 @@ static void E_ACELP_1pulse_searchx_fx( ...@@ -281,9 +306,11 @@ static void E_ACELP_1pulse_searchx_fx(
Word16 ntracks, t; Word16 ntracks, t;
Word16 sqk[2], alpk[2], ik; Word16 sqk[2], alpk[2], ik;
move16(); move16();
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0; Flag Overflow = 0;
move32(); move32();
#endif
#endif #endif
/* save these to limit memory searches */ /* save these to limit memory searches */
/*alp0 = *alp + R[0]; INDIRECT(1);*/ /*alp0 = *alp + R[0]; INDIRECT(1);*/
...@@ -299,7 +326,11 @@ static void E_ACELP_1pulse_searchx_fx( ...@@ -299,7 +326,11 @@ static void E_ACELP_1pulse_searchx_fx(
sqk[0] = -1; sqk[0] = -1;
ik = 0; ik = 0;
move16(); move16();
#ifdef ISSUE_1867_replace_overflow_libenc
if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 )
#else
if ( mac_ro( alp0, cor[tracks[0]], sign[tracks[0]], &Overflow ) < 0 ) if ( mac_ro( alp0, cor[tracks[0]], sign[tracks[0]], &Overflow ) < 0 )
#endif
{ {
sqk[0] = 1; sqk[0] = 1;
move16(); move16();
...@@ -323,7 +354,11 @@ static void E_ACELP_1pulse_searchx_fx( ...@@ -323,7 +354,11 @@ static void E_ACELP_1pulse_searchx_fx(
ps1 = add( ps0, dn[x] ); ps1 = add( ps0, dn[x] );
/* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(1);*/ /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(1);*/
assert( sign[x] == sign_val_1 << 1 || sign[x] == -( sign_val_1 << 1 ) ); assert( sign[x] == sign_val_1 << 1 || sign[x] == -( sign_val_1 << 1 ) );
#ifdef ISSUE_1867_replace_overflow_libenc
alp1 = mac_r_sat( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#else
alp1 = mac_ro( alp0, cor[x], sign[x], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ alp1 = mac_ro( alp0, cor[x], sign[x], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */
#endif
alpk[1 - ik] = alp1; /* Qalp */ alpk[1 - ik] = alp1; /* Qalp */
move16(); move16();
...@@ -334,7 +369,11 @@ static void E_ACELP_1pulse_searchx_fx( ...@@ -334,7 +369,11 @@ static void E_ACELP_1pulse_searchx_fx(
move16(); move16();
/*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/ /*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/
#ifdef ISSUE_1867_replace_overflow_libenc
s = L_msu_sat( L_mult_sat( alpk[ik], sq ), sqk[ik], alp1 ); /* Q9+Qalp+1 */
#else
s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */ s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */
#endif
if ( s > 0 ) if ( s > 0 )
{ {
ik = sub( 1, ik ); ik = sub( 1, ik );
......