From 2296488e32488213d028eb0c6790862393d39a9e Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 7 Aug 2025 14:55:08 +0200 Subject: [PATCH 01/80] introduce switchig macro for this branch --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 9d59d03d9..4539e4641 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,7 @@ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ +#define ISSUE_1867_replace_overflow_libenc /* FhG: BE - replace overflow operators by non-overflow-alternatives all over the lib_enc module */ #define FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR /* issue 1068 : Memory leak in MC to BINAURAL_ROOM decoding with bitrate switching*/ -- GitLab From 1566d0e8ebc0d0075341790e35b4fe68a625daa0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 10:07:38 +0200 Subject: [PATCH 02/80] some more overflow op replacements --- lib_enc/acelp_core_switch_enc_fx.c | 12 ++++++++++++ lib_enc/acelp_enc_util_fx.c | 12 ++++++++++++ lib_enc/analy_sp_fx.c | 18 ++++++++++++++++++ lib_enc/ari_hm_enc_fx.c | 6 ++++++ lib_enc/arith_coder_enc_fx.c | 25 ++++++++++++++----------- 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 8db68e089..7c0313c8f 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -729,9 +729,11 @@ static void bwe_switch_enc_fx( Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */ Word16 n, L; BSTR_ENC_HANDLE hBstr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif hBstr = st_fx->hBstr; L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS ); @@ -848,7 +850,11 @@ static void bwe_switch_enc_fx( L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat +#else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ +#endif ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); /* Q0 */ push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); @@ -875,9 +881,11 @@ static void bwe_switch_enc_ivas_fx( Word16 synth_subfr_bwe_fx[SWITCH_MAX_GAP]; /* synthesized bwe for core switching */ Word16 n, L; BSTR_ENC_HANDLE hBstr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif hBstr = st_fx->hBstr; L = NS2SA_FX2( st_fx->input_Fs, FRAME_SIZE_NS ); @@ -991,7 +999,11 @@ static void bwe_switch_enc_ivas_fx( L_tmp1 = L_mult( tmp, E2_fx ); /*30-q_tmp1+q_tmp2 */ q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat +#else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ +#endif ind1_fx = usquant_fx( gain_fx, &gain_fx, shr( MINVALUEOFFIRSTGAIN_FX, 1 ), shr( DELTAOFFIRSTGAIN_FX, 4 ), ( 1 << NOOFGAINBITS1 ) ); push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 7f57b55da..666eac404 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -161,8 +161,10 @@ void E_ACELP_conv( { Word16 i, k; Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif FOR( k = 0; k < L_SUBFR; k++ ) { @@ -175,7 +177,11 @@ void E_ACELP_conv( L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/ } L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Q0 */ //??sat //??sat +#else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */ +#endif } } @@ -187,8 +193,10 @@ void E_ACELP_conv_ivas_fx( { Word16 i, k; Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif FOR( k = 0; k < L_SUBFR; k++ ) { @@ -201,7 +209,11 @@ void E_ACELP_conv_ivas_fx( L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/ } L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/ //??sat //??sat +#else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/ +#endif move16(); } } diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 8618c8fd7..7d5e633b1 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -918,10 +918,12 @@ static void find_enr( Word32 etot; Word16 exp_etot; Word32 *tmpptr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +endif ptR = &data[1]; /* first real */ @@ -969,7 +971,11 @@ static void find_enr( /* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* normalization - corresponds to FFT normalization by 2/L_FFT */ BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ +#ifdef ISSUE_1867_replace_overflow_libenc + *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ //??sat +#else *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ +#endif move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; /*band[i] += *ptE++;*/ @@ -995,7 +1001,11 @@ static void find_enr( exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( diff_scaleP1, exp_band ); BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ +#ifdef ISSUE_1867_replace_overflow_libenc + band[i] = L_shl_sat( Ltmp1, exp_band ); /* Q15 + exp_band */ +#else band[i] = L_shl_o( Ltmp1, exp_band, &Overflow ); /* Q15 + exp_band */ +#endif move32(); /* band scaled by Q_new + QSCALE */ BASOP_SATURATE_WARNING_ON_EVS; @@ -1046,7 +1056,11 @@ static void find_enr( /* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* normalization - corresponds to FFT normalization by 2/L_FFT */ BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ +#ifdef ISSUE_1867_replace_overflow_libenc + *Bin_E = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE */ +#else *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE */ +#endif move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; Bin_E++; @@ -1068,7 +1082,11 @@ static void find_enr( exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( diff_scaleP1, exp_band ); BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ +#ifdef ISSUE_1867_replace_overflow_libenc + band[i] = L_shl_sat( Ltmp1, exp_band ); +#else band[i] = L_shl_o( Ltmp1, exp_band, &Overflow ); +#endif move32(); /* band scaled by Q_new + QSCALE */ BASOP_SATURATE_WARNING_ON_EVS; diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index d62dcf141..a33577d1c 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -241,9 +241,11 @@ Word16 SearchPeriodicityIndex_fx( Word32 Lag; Word16 s, tmp, tmp2, tmp3; Word32 tmp32; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Debug init (not instrumented) */ @@ -457,7 +459,11 @@ Word16 SearchPeriodicityIndex_fx( tmp32 = L_mult0( Score, NumToConsider ); /* -> 16Q15 */ tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp3 = div_s( round_fx_sat( L_shl( tmp32, tmp ) ), round_fx_sat( L_shl( AbsTotal, tmp2 ) ) ); //??sat //??sat +#else tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) ); +#endif *RelativeScore = shr_sat( tmp3, add( sub( tmp, tmp2 ), 2 ) ); /* -> 2Q13 */ move16(); } diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 2e88b1f00..6ee42e9a2 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -48,10 +48,12 @@ static Word16 tcx_arith_estimate_scale( { Word16 scale, tmp, k, s, s1; Word32 L_tmp, accu; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /* compute normalised standard deviation and determine approximate scale */ @@ -72,7 +74,11 @@ static Word16 tcx_arith_estimate_scale( s1 = norm_l( abs_spectrum[k] ); } +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = mult_r( round_fx_sat( L_shl( abs_spectrum[k], s1 ) ), envelope[k] ); //??sat +#else tmp = mult_r( round_fx_o( L_shl( abs_spectrum[k], s1 ), &Overflow ), envelope[k] ); +#endif L_tmp = L_mult0( tmp, tmp ); tmp = sub( shl( s1, 1 ), 1 ); @@ -367,7 +373,7 @@ static Word16 tcx_arith_rateloop( Word32 L_tmp; Word16 tmp, tmp3; Word32 tmp2; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -381,8 +387,8 @@ static Word16 tcx_arith_rateloop( scale_max = tcx_arith_find_max_scale( abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, exps, deadzone, scale_e ); -#ifdef ISSUE_1796_replace_shl_o - scale = shl_sat( scale, sub( tmp, *scale_e ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + scale = shl_sat( scale, sub( tmp, *scale_e ) ); //??sat #else scale = shl_o( scale, sub( tmp, *scale_e ), &Overflow ); #endif @@ -446,8 +452,8 @@ static Word16 tcx_arith_rateloop( { /* Update estimator temporal compensation factor */ tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 1 << 9 ), bits, &s ); -#ifdef ISSUE_1796_replace_shl_o - tmp = shl_sat( mult_r( *target_bits_fac, tmp ), s ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = shl_sat( mult_r( *target_bits_fac, tmp ), s ); //??sat #else tmp = shl_o( mult_r( *target_bits_fac, tmp ), s, &Overflow ); #endif @@ -480,14 +486,11 @@ static Word16 tcx_arith_rateloop( { /* adjust = 1.25f * target_bits / (float)bits; */ tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 0x280 ), bits, &s ); -#ifdef ISSUE_1796_replace_shl_o - adjust = shl_sat( tmp, sub( s, 1 ) ); /* Q14 */ +#ifdef ISSUE_1867_replace_overflow_libenc + adjust = shl_sat( tmp, sub( s, 1 ) ); /* Q14 */ //??sat + scale = shl_sat( mult_r( scale, adjust ), 1 ); //??sat #else adjust = shl_o( tmp, sub( s, 1 ), &Overflow ); /* Q14 */ -#endif -#ifdef ISSUE_1796_replace_shl_o - scale = shl_sat( mult_r( scale, adjust ), 1 ); -#else scale = shl_o( mult_r( scale, adjust ), 1, &Overflow ); #endif scale = s_min( scale, scale_max ); -- GitLab From addc3fc355a6b9d9af675d5ccc82e20f0cd042cb Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 11:47:13 +0200 Subject: [PATCH 03/80] stop tracking vcxproj and filters --- Workspace_msvc/decoder.vcxproj | 176 ------- Workspace_msvc/encoder.vcxproj | 178 ------- Workspace_msvc/isar_post_rend.vcxproj | 179 ------- Workspace_msvc/lib_com.vcxproj | 346 ------------- Workspace_msvc/lib_com.vcxproj.filters | 646 ------------------------ Workspace_msvc/lib_debug.vcxproj | 121 ----- Workspace_msvc/lib_dec.vcxproj | 351 ------------- Workspace_msvc/lib_dec.vcxproj.filters | 566 --------------------- Workspace_msvc/lib_enc.vcxproj | 371 -------------- Workspace_msvc/lib_enc.vcxproj.filters | 638 ----------------------- Workspace_msvc/lib_isar.vcxproj | 184 ------- Workspace_msvc/lib_lc3plus.vcxproj | 195 ------- Workspace_msvc/lib_rend.vcxproj | 210 -------- Workspace_msvc/lib_rend.vcxproj.filters | 152 ------ Workspace_msvc/lib_util.vcxproj | 161 ------ Workspace_msvc/renderer.vcxproj | 183 ------- 16 files changed, 4657 deletions(-) delete mode 100644 Workspace_msvc/decoder.vcxproj delete mode 100644 Workspace_msvc/encoder.vcxproj delete mode 100644 Workspace_msvc/isar_post_rend.vcxproj delete mode 100644 Workspace_msvc/lib_com.vcxproj delete mode 100644 Workspace_msvc/lib_com.vcxproj.filters delete mode 100644 Workspace_msvc/lib_debug.vcxproj delete mode 100644 Workspace_msvc/lib_dec.vcxproj delete mode 100644 Workspace_msvc/lib_dec.vcxproj.filters delete mode 100644 Workspace_msvc/lib_enc.vcxproj delete mode 100644 Workspace_msvc/lib_enc.vcxproj.filters delete mode 100644 Workspace_msvc/lib_isar.vcxproj delete mode 100644 Workspace_msvc/lib_lc3plus.vcxproj delete mode 100644 Workspace_msvc/lib_rend.vcxproj delete mode 100644 Workspace_msvc/lib_rend.vcxproj.filters delete mode 100644 Workspace_msvc/lib_util.vcxproj delete mode 100644 Workspace_msvc/renderer.vcxproj diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj deleted file mode 100644 index 3ab058c29..000000000 --- a/Workspace_msvc/decoder.vcxproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - decoder - {E3DCBC31-7FC9-D127-E000-529F8460D5FD} - decoder - 10.0.17763.0 - - - - Application - v141 - false - MultiByte - - - Application - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - ..\ - .\Debug_$(ProjectName)\ - false - false - IVAS_dec - - - ..\ - .\Release_$(ProjectName)\ - false - false - IVAS_dec - - - - - - - $(IntDir)$(ProjectName).tlb - - - - Disabled - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - - $(OutDir)$(TargetName).exe - true - - true - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - Precise - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - $(OutDir)$(TargetName).exe - true - - false - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - libcmtd.lib - - - - - - - - - - {e822ddaf-0f5f-4cd0-a694-38ae69de74d3} - false - - - {869a305e-d99e-4c3a-bdb3-aa57abcce619} - - - {2fa8f384-0775-f3b7-f8c3-85209222fc70} - false - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj deleted file mode 100644 index 9578e488d..000000000 --- a/Workspace_msvc/encoder.vcxproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - encoder - {B3FC9DFC-7268-8660-7C0D-B60BAF02C554} - encoder - 10.0.17763.0 - - - - Application - v141 - false - MultiByte - - - Application - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - ..\ - .\Debug_$(ProjectName)\ - false - false - IVAS_cod - - - ..\ - .\Release_$(ProjectName)\ - false - false - IVAS_cod - - - - - - - $(IntDir)$(ProjectName).tlb - - - - Disabled - ..\lib_enc;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - - $(OutDir)$(TargetName).exe - true - - false - true - $(IntDir)$(ProjectName).pdb - Console - - false - - MachineX86 - - - - - - - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_enc;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - Precise - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - $(OutDir)$(TargetName).exe - true - - false - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - - - - - - - - {824da4cf-06f0-45c9-929a-8792f0e19c3e} - false - - - {2fa8f384-0775-f3b7-f8c3-85209222fc70} - false - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj deleted file mode 100644 index 19cb1aff7..000000000 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ /dev/null @@ -1,179 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - isar_post_rend - {12374ADC-0E5C-4FDD-B903-71D572413831} - isar_post_rend - 10.0.17763.0 - - - - Application - v141 - false - MultiByte - - - Application - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - ..\ - .\Debug_$(ProjectName)\ - false - false - ISAR_post_rend - - - ..\ - .\Release_$(ProjectName)\ - false - false - ISAR_post_rend - - - - $(IntDir)$(ProjectName).tlb - - - - Disabled - ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - false - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - - $(OutDir)$(TargetName).exe - true - - true - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - Precise - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - false - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - $(OutDir)$(TargetName).exe - true - - false - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - libcmtd.lib - - - - - - - - - - {54509728-928B-44D9-A118-A6F92F08B34F} - false - - - {869a305e-d99e-4c3a-bdb3-aa57abcce619} - - - {2FA8F384-0775-F3B7-F8C3-85209222FC70} - false - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - false - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj deleted file mode 100644 index 8e37844b9..000000000 --- a/Workspace_msvc/lib_com.vcxproj +++ /dev/null @@ -1,346 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {39EC200D-7795-4FF8-B214-B24EDA5526AE} - common - 10.0.17763.0 - - - - StaticLibrary - v141 - false - MultiByte - - - StaticLibrary - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - libivascom - - - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - libivascom - - - - - - - Disabled - ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions); - - EnableFastChecks - MultiThreadedDebug - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters deleted file mode 100644 index f247d199e..000000000 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ /dev/null @@ -1,646 +0,0 @@ - - - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_evs_c - - - common_all_c - - - common_evs_c - - - common_evs_c - - - common_evs_c - - - common_evs_c - - - common_evs_c - - - common_evs_c - - - common_evs_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_ivas_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_ivas_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_all_c - - - common_ivas_c - - - - common_ivas_c - - - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - - common_h - - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - common_h - - - - - {890c2f45-9385-4fce-859b-6a65469e8dc0} - - - {201ea764-9626-4dca-9cc4-5b4106f8b8b2} - - - {fbb860e2-79d0-45b1-ada1-c3a0a369ce2c} - - - {b95b7bed-a666-4a00-9332-2b528638503e} - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj deleted file mode 100644 index 929dd72a8..000000000 --- a/Workspace_msvc/lib_debug.vcxproj +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {54509728-928B-44D9-A118-A6F92F08B34F} - debug - 10.0.17763.0 - - - - StaticLibrary - v141 - MultiByte - - - StaticLibrary - v141 - MultiByte - true - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - libivasdebug - - - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - libivasdebug - - - - - - - Disabled - ..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;DBG_WAV_WRITER;$(Macros);%(PreprocessorDefinitions) - false - - EnableFastChecks - MultiThreadedDebug - false - $(IntDir)$(ProjectName).pdb - Level4 - OldStyle - Default - %(DisableSpecificWarnings) - - - $(OutDir)$(TargetName).lib - - - - - - - - MaxSpeed - AnySuitable - false - false - ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - $(IntDir)$(ProjectName).pdb - Level4 - - Default - %(DisableSpecificWarnings) - - - $(OutDir)$(TargetName).lib - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj deleted file mode 100644 index e5998e672..000000000 --- a/Workspace_msvc/lib_dec.vcxproj +++ /dev/null @@ -1,351 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - lib_dec - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} - evs_dec - 10.0.17763.0 - - - StaticLibrary - v141 - false - MultiByte - - - - StaticLibrary - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - false - false - libivasdec - - - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - false - false - libivasdec - - - - - - - .\Debug\$(ProjectName).tlb - - - - Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - false - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - false - - - {54509728-928b-44d9-a118-a6f92f08b34f} - false - - - {718DE063-A18B-BB72-9150-62B892E6FFA6} - false - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters deleted file mode 100644 index 170eada9a..000000000 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ /dev/null @@ -1,566 +0,0 @@ - - - - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_evs_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_all_c - - - decoder_all_c - - - decoder_ivas_c - - - decoder_all_c - - - decoder_ivas_c - - - decoder_ivas_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - decoder_all_c - - - - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - decoder_h - - - - - {6d564218-e0e5-4a7b-80b3-6b10661ad36c} - - - {33d78f8d-2d43-40f5-a9b1-711097bd6746} - - - {044baa49-b157-45ed-8bec-29b6d7172e82} - - - {adc81a29-2517-49f0-819f-e8cea3d49ae3} - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj deleted file mode 100644 index 123754142..000000000 --- a/Workspace_msvc/lib_enc.vcxproj +++ /dev/null @@ -1,371 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - lib_enc - {824DA4CF-06F0-45C9-929A-8792F0E19C3E} - evs_enc - 10.0.17763.0 - - - - StaticLibrary - v141 - false - MultiByte - - - StaticLibrary - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - false - false - libivasenc - - - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - false - false - libivasenc - - - - - - - $(IntDir)$(ProjectName).tlb - - - - Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - Precise - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - false - - - {54509728-928b-44d9-a118-a6f92f08b34f} - false - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters deleted file mode 100644 index e8f429f49..000000000 --- a/Workspace_msvc/lib_enc.vcxproj.filters +++ /dev/null @@ -1,638 +0,0 @@ - - - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_evs_c - - - encoder_ivas_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_all_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_ivas_c - - - encoder_all_c - - - - encoder_all_c - - - - - - encoder_h - - - encoder_h - - - encoder_h - - - encoder_h - - - encoder_h - - - encoder_all_c - - - - - {34137975-e4fd-40f0-938f-02fd46da5e22} - - - {c24a3dcd-cde3-411b-aecf-747c29d87668} - - - {e78e5d72-8d6d-4b00-a6e0-64a62c9cf8f2} - - - {597ebb71-22ba-41e8-b4bf-e8691bda2e5b} - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj deleted file mode 100644 index cdc0979a0..000000000 --- a/Workspace_msvc/lib_isar.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - lib_isar - {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} - isar - 10.0.17763.0 - - - - StaticLibrary - v141 - false - MultiByte - - - StaticLibrary - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - libisar - - - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - libisar - - - - - - - Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions); - - EnableFastChecks - MultiThreadedDebug - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - false - - - {54509728-928b-44d9-a118-a6f92f08b34f} - false - - - {95030B82-70CD-4C6B-84D4-61096035BEA2} - false - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj deleted file mode 100644 index 22b5cddd3..000000000 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {95030B82-70CD-4C6B-84D4-61096035BEA2} - Win32Proj - LC3_FL - 10.0.17763.0 - - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - liblc3plus - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - - - LC3plus - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\Obj\ - - - - - - Level3 - ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) - Disabled - MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - 4305;4244;4996 - OldStyle - false - false - - - Console - true - - - - - Level3 - - - ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) - MaxSpeed - MultiThreaded - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - 4244;4305;4996 - false - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj deleted file mode 100644 index f93b5f26d..000000000 --- a/Workspace_msvc/lib_rend.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - lib_rend - {718DE063-A18B-BB72-9150-62B892E6FFA6} - evs_dec - 10.0.17763.0 - - - StaticLibrary - v141 - false - MultiByte - - - - StaticLibrary - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - false - false - libivasrend - - - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - false - false - libivasrend - - - - - - - .\Debug\$(ProjectName).tlb - - - - Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - WS2_32.lib; %(AdditionalDependencies) - $(OutDir)$(TargetName).lib - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - false - - - {54509728-928b-44d9-a118-a6f92f08b34f} - false - - - {95030B82-70CD-4C6B-84D4-61096035BEA2} - false - - - - - - - - - - - diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters deleted file mode 100644 index 820a5c044..000000000 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ /dev/null @@ -1,152 +0,0 @@ - - - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - rend_c - - - - - - - rend_h - - - rend_h - - - rend_h - - - rend_h - - - rend_h - - - rend_h - - - - - {54449ece-ef29-44b5-9512-ed8f555851a8} - - - {672b0eb6-cce8-425c-8bf2-aba4b45639bb} - - - \ No newline at end of file diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj deleted file mode 100644 index ceb342b21..000000000 --- a/Workspace_msvc/lib_util.vcxproj +++ /dev/null @@ -1,161 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {2FA8F384-0775-F3B7-F8C3-85209222FC70} - utility - 10.0.17763.0 - - - - StaticLibrary - v141 - MultiByte - - - StaticLibrary - v141 - MultiByte - true - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - true - .\Debug_$(ProjectName)\ - .\Debug_$(ProjectName)\ - libivasutil - - - false - .\Release_$(ProjectName)\ - .\Release_$(ProjectName)\ - libivasutil - - - - Disabled - ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) - false - - EnableFastChecks - MultiThreadedDebug - false - $(IntDir)$(ProjectName).pdb - Level4 - OldStyle - Default - %(DisableSpecificWarnings) - - - $(OutDir)$(TargetName).lib - - - - - MaxSpeed - AnySuitable - false - false - ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - $(IntDir)$(ProjectName).pdb - Level4 - - Default - %(DisableSpecificWarnings) - - - $(OutDir)$(TargetName).lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj deleted file mode 100644 index 1bc5b5568..000000000 --- a/Workspace_msvc/renderer.vcxproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - renderer - {12B4C8A5-1E06-4E30-B443-D1F916F52B47} - renderer - 10.0.17763.0 - - - - Application - v141 - false - MultiByte - - - Application - v141 - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>15.0.27428.2015 - - - ..\ - .\Debug_$(ProjectName)\ - false - false - IVAS_rend - - - ..\ - .\Release_$(ProjectName)\ - false - false - IVAS_rend - - - - $(IntDir)$(ProjectName).tlb - - - - Disabled - ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) - - EnableFastChecks - MultiThreadedDebug - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - OldStyle - Default - %(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - - $(OutDir)$(TargetName).exe - true - - true - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - - - - - $(IntDir)$(ProjectName).tlb - - - - MaxSpeed - AnySuitable - false - Neither - false - false - ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) - true - - Default - MultiThreaded - true - Precise - false - - - $(IntDir)$(ProjectName).pdb - Level4 - true - - Default - %(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0c0c - - - $(OutDir)$(TargetName).exe - true - - false - $(IntDir)$(ProjectName).pdb - Console - false - - MachineX86 - libcmtd.lib - - - - - - - - {54509728-928B-44D9-A118-A6F92F08B34F} - false - - - {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} - false - - - {869a305e-d99e-4c3a-bdb3-aa57abcce619} - - - {2FA8F384-0775-F3B7-F8C3-85209222FC70} - false - - - {39ec200d-7795-4ff8-b214-b24eda5526ae} - false - - - {718DE063-A18B-BB72-9150-62B892E6FFA6} - false - - - - - - - - - - - \ No newline at end of file -- GitLab From 2f23d36429a3cff7bd2e9eae23e1b09b8d977190 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 11:47:45 +0200 Subject: [PATCH 04/80] some more overflow ops replaced --- lib_enc/avq_cod_fx.c | 6 ++++++ lib_enc/bass_psfilter_enc_fx.c | 39 ++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index b3a49c59e..a72e309ff 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -35,8 +35,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; Word32 Lener, Ltmp, Lgain, x1[8]; Word16 tot_est_bits, Q_in; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif Q_in = sub( Q_in_ref, 1 ); move16(); @@ -53,7 +55,11 @@ void AVQ_cod_fx( /* o: comfort noise gain factor Lener = L_shl( 4, shl( Q_in, 1 ) ); /* to set ebits >= 0 */ 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] ); //??sat +#else Lener = L_mac_o( Lener, xri[l * 8 + i], xri[l * 8 + i], &Overflow ); +#endif } /* estimated bit consumption when gain=1 */ /* ebits[l] = 5.0 * FAC_LOG2 * (Word16)log10(ener * 0.5) */ diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index f417a0904..4304d5e1a 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -36,10 +36,12 @@ Word16 bass_pf_enc_fx( Word32 cross_n_d, nrg_n; const Word16 *pFilt; Word32 ener2; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif IF( NE_16( l_frame, L_FRAME16k ) ) @@ -129,8 +131,8 @@ Word16 bass_pf_enc_fx( /* gain = tmp/nrg; */ gain = BASOP_Util_Divide3232_Scale( tmp, nrg, &tmp16 ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef ISSUE_1796_replace_shl_o - gain = shl_sat( gain, tmp16 ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + gain = shl_sat( gain, tmp16 ); /* Q15 */ //??sat #else gain = shl_o( gain, tmp16, &Overflow ); /* Q15 */ #endif @@ -157,6 +159,16 @@ Word16 bass_pf_enc_fx( FOR( i = 0; i < lg; i++ ) { 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] ); //??sat + tmp16 = mac_rsat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //`??sat + + lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); + lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat + + tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat + ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat +#else tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr + T], &Overflow ); tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */ @@ -165,6 +177,7 @@ Word16 bass_pf_enc_fx( 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 */ +#endif } } @@ -173,6 +186,15 @@ Word16 bass_pf_enc_fx( FOR( i = lg; i < l_subfr; i++ ) { 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 */ //??sat + tmp16 = round_fx_sat( tmp32 ); //??sat + lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); + lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat + + tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat + ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat +#else tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr - T], &Overflow ); /* Q0 */ tmp16 = round_fx_o( tmp32, &Overflow ); lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); @@ -180,6 +202,7 @@ Word16 bass_pf_enc_fx( 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 */ +#endif } } @@ -214,8 +237,8 @@ Word16 bass_pf_enc_fx( tmp32 = L_deposit_l( 1 ); tmp16 = BASOP_Util_Divide3232_Scale( tmp, tmp32, &st ); BASOP_SATURATE_WARNING_OFF_EVS; -#ifdef ISSUE_1796_replace_shl_o - tmp16 = shl_sat( tmp16, sub( st, 2 ) ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp16 = shl_sat( tmp16, sub( st, 2 ) ); /* Q15 */ //??sat #else tmp16 = shl_o( tmp16, sub( st, 2 ), &Overflow ); /* Q15 */ #endif @@ -244,7 +267,11 @@ Word16 bass_pf_enc_fx( tmp32 = L_mac( tmp32, tmp16, syn[i + i_subfr] ); 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*/ //??sat +#else error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ +#endif move16(); } } @@ -258,7 +285,11 @@ Word16 bass_pf_enc_fx( noise_in[i] = round_fx( L_shl( tmp32, s2 ) ); /* Q0+s2 */ move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ //??sat +#else error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ +#endif move16(); } } -- GitLab From bb278924c5ca96b61361dcc90aa8bea99159e8b3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 11:58:23 +0200 Subject: [PATCH 05/80] clang patch --- lib_enc/acelp_core_switch_enc_fx.c | 6 ++--- lib_enc/acelp_enc_util_fx.c | 8 +++---- lib_enc/analy_sp_fx.c | 22 ++++++++--------- lib_enc/ari_hm_enc_fx.c | 2 +- lib_enc/arith_coder_enc_fx.c | 8 +++---- lib_enc/bass_psfilter_enc_fx.c | 38 +++++++++++++++--------------- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 6e9171e8f..9611b01f1 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -862,9 +862,9 @@ static void bwe_switch_enc_fx( q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat #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 */ push_indice( hBstr, IND_CORE_SWITCHING_AUDIO_GAIN, ind1_fx, NOOFGAINBITS1 ); @@ -1011,7 +1011,7 @@ static void bwe_switch_enc_ivas_fx( q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat #else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ #endif diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 666eac404..642e870be 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -176,9 +176,9 @@ void E_ACELP_conv( /*cn2[k]-=cn2[i]*h2[k-i];*/ 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 */ //??sat //??sat + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Q0 */ //??sat //??sat #else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */ #endif @@ -208,9 +208,9 @@ void E_ACELP_conv_ivas_fx( /*cn2[k]-=cn2[i]*h2[k-i];*/ 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*/ //??sat //??sat + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/ //??sat //??sat #else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/ #endif diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 7d5e633b1..694b051f8 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -923,10 +923,10 @@ static void find_enr( Flag Overflow = 0; move32(); #endif -endif + endif - ptR = &data[1]; /* first real */ + ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ /*-----------------------------------------------------------------------------------* @@ -970,13 +970,13 @@ endif /* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* normalization - corresponds to FFT normalization by 2/L_FFT */ - BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ + BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ #ifdef ISSUE_1867_replace_overflow_libenc - *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ //??sat + *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ //??sat #else - *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ + *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; /*band[i] += *ptE++;*/ *Bin_E = *ptE; @@ -1000,13 +1000,13 @@ endif exp_band = sub( exp_band, shift_to_norm ); exp_band = sub( diff_scaleP1, exp_band ); - BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ + 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; test(); @@ -1055,13 +1055,13 @@ endif /* *ptE *= 4.0 / (L_FFT*L_FFT) */ /* normalization - corresponds to FFT normalization by 2/L_FFT */ - BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ + BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ #ifdef ISSUE_1867_replace_overflow_libenc *Bin_E = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE */ #else *Bin_E = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE */ #endif - move32(); /* scaled by Q_new + QSCALE - 2 */ + move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; Bin_E++; Ltmp1 = L_add( Ltmp1, Ltmp ); diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index a33577d1c..7d1f2246e 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -460,7 +460,7 @@ Word16 SearchPeriodicityIndex_fx( tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp3 = div_s( round_fx_sat( L_shl( tmp32, tmp ) ), round_fx_sat( L_shl( AbsTotal, tmp2 ) ) ); //??sat //??sat + tmp3 = div_s( round_fx_sat( L_shl( tmp32, tmp ) ), round_fx_sat( L_shl( AbsTotal, tmp2 ) ) ); //??sat //??sat #else tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) ); #endif diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 6ee42e9a2..6a77c5484 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -75,7 +75,7 @@ static Word16 tcx_arith_estimate_scale( } #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r( round_fx_sat( L_shl( abs_spectrum[k], s1 ) ), envelope[k] ); //??sat + tmp = mult_r( round_fx_sat( L_shl( abs_spectrum[k], s1 ) ), envelope[k] ); //??sat #else tmp = mult_r( round_fx_o( L_shl( abs_spectrum[k], s1 ), &Overflow ), envelope[k] ); #endif @@ -388,7 +388,7 @@ static Word16 tcx_arith_rateloop( scale_max = tcx_arith_find_max_scale( abs_spectrum, abs_spectrum_e, L_frame, envelope, envelope_e, exps, deadzone, scale_e ); #ifdef ISSUE_1867_replace_overflow_libenc - scale = shl_sat( scale, sub( tmp, *scale_e ) ); //??sat + scale = shl_sat( scale, sub( tmp, *scale_e ) ); //??sat #else scale = shl_o( scale, sub( tmp, *scale_e ), &Overflow ); #endif @@ -453,7 +453,7 @@ static Word16 tcx_arith_rateloop( /* Update estimator temporal compensation factor */ tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 1 << 9 ), bits, &s ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = shl_sat( mult_r( *target_bits_fac, tmp ), s ); //??sat + tmp = shl_sat( mult_r( *target_bits_fac, tmp ), s ); //??sat #else tmp = shl_o( mult_r( *target_bits_fac, tmp ), s, &Overflow ); #endif @@ -487,7 +487,7 @@ static Word16 tcx_arith_rateloop( /* adjust = 1.25f * target_bits / (float)bits; */ tmp = BASOP_Util_Divide3232_Scale( L_mult0( target_bits, 0x280 ), bits, &s ); #ifdef ISSUE_1867_replace_overflow_libenc - adjust = shl_sat( tmp, sub( s, 1 ) ); /* Q14 */ //??sat + adjust = shl_sat( tmp, sub( s, 1 ) ); /* Q14 */ //??sat scale = shl_sat( mult_r( scale, adjust ), 1 ); //??sat #else adjust = shl_o( tmp, sub( s, 1 ), &Overflow ); /* Q14 */ diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index 4304d5e1a..3fe6aaa8e 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -132,9 +132,9 @@ Word16 bass_pf_enc_fx( gain = BASOP_Util_Divide3232_Scale( tmp, nrg, &tmp16 ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - gain = shl_sat( gain, tmp16 ); /* Q15 */ //??sat + gain = shl_sat( gain, tmp16 ); /* Q15 */ //??sat #else - gain = shl_o( gain, tmp16, &Overflow ); /* Q15 */ + gain = shl_o( gain, tmp16, &Overflow ); /* Q15 */ #endif BASOP_SATURATE_WARNING_ON_EVS; @@ -160,14 +160,14 @@ Word16 bass_pf_enc_fx( { 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] ); //??sat - tmp16 = mac_rsat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //`??sat + tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr + T] ); //??sat + tmp16 = mac_rsat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //`??sat lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); - lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat + lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat - tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat - ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat + tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat + ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat #else tmp32 = L_msu0_o( tmp32, gain, syn[i + i_subfr + T], &Overflow ); tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */ @@ -187,21 +187,21 @@ Word16 bass_pf_enc_fx( { 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 */ //??sat - tmp16 = round_fx_sat( tmp32 ); //??sat + tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr - T] ); /* Q0 */ //??sat + tmp16 = round_fx_sat( tmp32 ); //??sat lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); - lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat + lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat - tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat - ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat + tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat + ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat #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 ); lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); lp_error = L_mac_o( lp_error, tmp16, 0x1000, &Overflow ); /* Q13 */ - 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 */ + 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 */ #endif } } @@ -238,9 +238,9 @@ Word16 bass_pf_enc_fx( tmp16 = BASOP_Util_Divide3232_Scale( tmp, tmp32, &st ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp16 = shl_sat( tmp16, sub( st, 2 ) ); /* Q15 */ //??sat + tmp16 = shl_sat( tmp16, sub( st, 2 ) ); /* Q15 */ //??sat #else - tmp16 = shl_o( tmp16, sub( st, 2 ), &Overflow ); /* Q15 */ + tmp16 = shl_o( tmp16, sub( st, 2 ), &Overflow ); /* Q15 */ #endif if ( GT_16( tmp16, 16384 /*0.5f Q15*/ ) ) @@ -268,7 +268,7 @@ Word16 bass_pf_enc_fx( 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*/ //??sat + error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ //??sat #else error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ #endif @@ -286,7 +286,7 @@ Word16 bass_pf_enc_fx( move16(); #ifdef ISSUE_1867_replace_overflow_libenc - error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ //??sat + error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ //??sat #else error_in[i] = sub_o( orig[i + i_subfr], syn[i + i_subfr], &Overflow ); /*Q0*/ #endif -- GitLab From 291406b59d6aed9b1c7381a433e1d74a911f04b5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 12:35:12 +0200 Subject: [PATCH 06/80] fix build errors --- lib_enc/analy_sp_fx.c | 2 +- lib_enc/bass_psfilter_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 694b051f8..4483f07d6 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -923,7 +923,7 @@ static void find_enr( Flag Overflow = 0; move32(); #endif - endif +#endif ptR = &data[1]; /* first real */ diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index 3fe6aaa8e..628f64320 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -161,7 +161,7 @@ Word16 bass_pf_enc_fx( 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] ); //??sat - tmp16 = mac_rsat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //`??sat + tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //??sat lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ //??sat -- GitLab From 87e8dc9196af8103ad0175bbb36dd793d3cad9b7 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 12:51:15 +0200 Subject: [PATCH 07/80] some more overflow op replacements --- lib_enc/bw_detect_fx.c | 14 ++++++++-- lib_enc/cng_enc_fx.c | 60 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index eeaf56969..11ea852f4 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -67,9 +67,11 @@ void bw_detect_fx( const Word32 *pt32; Word32 max_NB32, max_WB32, max_SWB32, max_FB32, mean_NB32, mean_WB32, mean_SWB32, mean_FB32; /* Q11*/ /* we need Word32 for the new cldfb energy vectors */ Word16 bwd_count_wider_bw; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 lp_noise_fx; @@ -128,7 +130,11 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ //??sat +#else L_tmp = L_add_o( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ), &Overflow ); /* Q25 */ +#endif cldfb_bin[0] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); move32(); /* 1/log2(10) */ /* Q25 */ @@ -297,8 +303,8 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - spect[i] = round_fx_o( L_shr_sat( spect32[i], Q_dct ), &Overflow ); +#ifdef ISSUE_1867_replace_overflow_libenc + spect[i] = round_fx_sat( L_shr_sat( spect32[i], Q_dct ) ); //??sat //??sat #else spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow ); #endif @@ -339,7 +345,11 @@ void bw_detect_fx( pt1 = &spect[i_mult2( i, bin_width )]; FOR( j = 0; j < bin_width; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); //??sat +#else sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); +#endif pt1++; } tmp_1 = BASOP_Util_Cmp_Mant32Exp( sum32, E_spect_bin, MAX_32, Q31 - 41 ); /* Any sum32 in Q_dct if it is less than MAX_32 in Q41 will be less than 0.001 */ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index ed3663732..dd4b5bcf0 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -108,9 +108,11 @@ void CNG_enc_fx( st_lp_sp_enr = hTdCngEnc->lp_sp_enr_fx; move16(); Word16 lp_ener_thr_scale; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Temp variables for floating point functions */ @@ -635,7 +637,11 @@ void CNG_enc_fx( FOR( i = 0; i < M; i++ ) { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + dist = add_sat( dist, dev ); /*Q15 */ //??sat +#else dist = add_o( dist, dev, &Overflow ); /*Q15 */ +#endif if ( GT_16( dev, max_dev ) ) { max_dev = dev; @@ -765,9 +771,15 @@ void CNG_enc_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat +#else L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_new+1 */ +#endif L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ tmp1 = add( add( Q_new, Q_new ), 1 ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); @@ -1046,7 +1058,11 @@ void CNG_enc_fx( exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat +#else L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ +#endif L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ d = L_add( d, L_tmp ); } @@ -1233,9 +1249,11 @@ void CNG_enc_ivas_fx( Word64 w_temp; Word32 inv_frame_len; Word32 L_ener; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif step_inv = 0; move16(); @@ -1939,9 +1957,15 @@ void CNG_enc_ivas_fx( FOR( i = 0; i < NUM_ENV_CNG; i++ ) { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ - L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat +#else + L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_new+1 */ +#endif L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ tmp1 = add( add( Q_new, Q_new ), 1 ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); @@ -2244,7 +2268,11 @@ void CNG_enc_ivas_fx( exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat +#else L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ +#endif L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ d = L_add( d, L_tmp ); /* Q17 */ } @@ -2511,9 +2539,11 @@ static Word16 shb_DTX_fx( DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; Copy( hBWE_TD->old_speech_shb_fx, shb_old_speech_fx, ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4 ); @@ -2531,7 +2561,11 @@ static Word16 shb_DTX_fx( wb_ener_fx = L_deposit_l( 0 ); FOR( i = 0; i < st_fx->L_frame; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); //??sat +#else wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow ); +#endif } wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ @@ -2540,7 +2574,11 @@ static Word16 shb_DTX_fx( fra = Log2_norm_lc( L_shl( wb_ener_fx, exp ) ); exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); +#ifdef ISSUE_1867_replace_overflow_libenc + log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat +#else log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ +#endif exp = norm_l( shb_ener_fx ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); exp = sub( 30 - 1, exp ); @@ -2559,7 +2597,11 @@ static Word16 shb_DTX_fx( move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat +#else log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att, &Overflow ); /* log_shb_ener_fx in Q8 */ +#endif IF( hDtxEnc->first_CNG == 0 ) { hTdCngEnc->mov_wb_cng_ener_fx = log_wb_ener_fx; @@ -2968,10 +3010,11 @@ static Word16 shb_DTX_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st->hTdCngEnc; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; - +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif shb_new_speech_fx = shb_old_speech_fx + ( ACELP_LOOK_12k8 + L_SUBFR ) * 5 / 4; @@ -2990,7 +3033,11 @@ static Word16 shb_DTX_ivas_fx( wb_ener_fx = L_deposit_l( 0 ); FOR( i = 0; i < st->L_frame; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac //??sat +#else wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac +#endif } wb_ener_fx = L_add( Mpy_32_16_1( wb_ener_fx, 128 ), 1 ); /* 128 in Q15, wb_ener_fx in Q1 */ @@ -3000,7 +3047,11 @@ static Word16 shb_DTX_ivas_fx( exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); +#ifdef ISSUE_1867_replace_overflow_libenc + log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat +#else log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ +#endif exp = norm_l( shb_ener_fx ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); exp = sub( 30 - 1, exp ); @@ -3024,8 +3075,11 @@ static Word16 shb_DTX_ivas_fx( move16(); } - +#ifdef ISSUE_1867_replace_overflow_libenc + log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att_fx ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat +#else log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ +#endif IF( st->hDtxEnc->first_CNG == 0 ) { -- GitLab From 620b9c666c771564ec0eb1c28055af9563ab470f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 13:06:32 +0200 Subject: [PATCH 08/80] clang format patch --- lib_enc/analy_sp_fx.c | 8 ++--- lib_enc/bass_psfilter_enc_fx.c | 2 +- lib_enc/bw_detect_fx.c | 6 ++-- lib_enc/cng_enc_fx.c | 54 +++++++++++++++++----------------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 4483f07d6..2974310a5 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -926,7 +926,7 @@ static void find_enr( #endif - ptR = &data[1]; /* first real */ + ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ /*-----------------------------------------------------------------------------------* @@ -974,7 +974,7 @@ static void find_enr( #ifdef ISSUE_1867_replace_overflow_libenc *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ //??sat #else - *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ + *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ #endif move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; @@ -1004,7 +1004,7 @@ static void find_enr( #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 */ BASOP_SATURATE_WARNING_ON_EVS; @@ -1059,7 +1059,7 @@ static void find_enr( #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 */ BASOP_SATURATE_WARNING_ON_EVS; diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index 628f64320..25573307c 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -160,7 +160,7 @@ Word16 bass_pf_enc_fx( { 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] ); //??sat + tmp32 = L_msu0_sat( tmp32, gain, syn[i + i_subfr + T] ); //??sat tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //??sat lp_error = Mpy_32_16_1( lp_error, 29491 /*0.9f Q15*/ ); diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 11ea852f4..38274d667 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -129,7 +129,7 @@ void bw_detect_fx( cldfb_bin[i] = L_deposit_l( 1 ); 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 */ //??sat #else @@ -304,7 +304,7 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - spect[i] = round_fx_sat( L_shr_sat( spect32[i], Q_dct ) ); //??sat //??sat + spect[i] = round_fx_sat( L_shr_sat( spect32[i], Q_dct ) ); //??sat //??sat #else spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow ); #endif @@ -346,7 +346,7 @@ void bw_detect_fx( FOR( j = 0; j < bin_width; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); //??sat + sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); //??sat #else sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); #endif diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index dd4b5bcf0..836fb2604 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -638,9 +638,9 @@ void CNG_enc_fx( { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - dist = add_sat( dist, dev ); /*Q15 */ //??sat + dist = add_sat( dist, dev ); /*Q15 */ //??sat #else - dist = add_o( dist, dev, &Overflow ); /*Q15 */ + dist = add_o( dist, dev, &Overflow ); /*Q15 */ #endif if ( GT_16( dev, max_dev ) ) { @@ -772,15 +772,15 @@ void CNG_enc_fx( { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat + L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat #else L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_new+1 */ #endif - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ + L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ tmp1 = add( add( Q_new, Q_new ), 1 ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); move32(); /* Q6 */ @@ -1056,12 +1056,12 @@ void CNG_enc_fx( /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/ L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */ exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ - tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ + L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ + tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat #else - L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ + L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ #endif L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ d = L_add( d, L_tmp ); @@ -1958,15 +1958,15 @@ void CNG_enc_ivas_fx( { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat + L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat + L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat #else - L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ + L_tmp = L_mult_o( *ptR, *ptR, &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_new+1 */ #endif - L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ + L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_new+1 */ tmp1 = add( add( Q_new, Q_new ), 1 ); env[i] = L_shr( L_tmp, sub( tmp1, 6 ) ); move32(); /* Q6 */ @@ -2266,12 +2266,12 @@ void CNG_enc_ivas_fx( /* d += (env[j] - CNG_details_codebook_fx[i][j]) * (env[j] - CNG_details_codebook_fx[i][j]);*/ L_tmp = L_sub( env[j], L_deposit_l( CNG_details_codebook_fx[i][j] ) ); /* Q6 */ exp = norm_l( L_tmp ); - L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ - tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ + L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ + tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat #else - L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ + L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ #endif L_tmp = L_shr( L_tmp, sub( add( exp, exp ), 36 ) ); /* Q17 */ d = L_add( d, L_tmp ); /* Q17 */ @@ -2562,7 +2562,7 @@ static Word16 shb_DTX_fx( FOR( i = 0; i < st_fx->L_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); //??sat + wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); //??sat #else wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i], &Overflow ); #endif @@ -2575,9 +2575,9 @@ static Word16 shb_DTX_fx( exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); #ifdef ISSUE_1867_replace_overflow_libenc - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat + log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat #else - log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ + log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ #endif exp = norm_l( shb_ener_fx ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); @@ -2600,7 +2600,7 @@ static Word16 shb_DTX_fx( #ifdef ISSUE_1867_replace_overflow_libenc log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat #else - log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att, &Overflow ); /* log_shb_ener_fx in Q8 */ + 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 ) { @@ -3036,7 +3036,7 @@ static Word16 shb_DTX_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac //??sat #else - wb_ener_fx = L_mac_o( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i], &Overflow ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac + 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 } @@ -3048,9 +3048,9 @@ static Word16 shb_DTX_ivas_fx( wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); #ifdef ISSUE_1867_replace_overflow_libenc - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat + log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat #else - log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ + log_wb_ener_fx = round_fx_o( L_shl_o( wb_ener_fx, 10, &Overflow ), &Overflow ); /* log_wb_ener_fx in Q8 */ #endif exp = norm_l( shb_ener_fx ); fra = Log2_norm_lc( L_shl( shb_ener_fx, exp ) ); @@ -3076,7 +3076,7 @@ static Word16 shb_DTX_ivas_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att_fx ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat + log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att_fx ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat #else log_shb_ener_fx = sub_o( round_fx_o( L_shl_o( shb_ener_fx, 10, &Overflow ), &Overflow ), att_fx, &Overflow ); /* log_shb_ener_fx in Q8 */ #endif -- GitLab From 661f1469515a3a2b3663aae34037e1cad26180be Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 13:51:44 +0200 Subject: [PATCH 09/80] re-add project files --- Workspace_msvc/decoder.vcxproj | 176 +++++++ Workspace_msvc/encoder.vcxproj | 178 +++++++ Workspace_msvc/isar_post_rend.vcxproj | 179 +++++++ Workspace_msvc/lib_com.vcxproj | 346 +++++++++++++ Workspace_msvc/lib_com.vcxproj.filters | 218 ++++++++ Workspace_msvc/lib_debug.vcxproj | 121 +++++ Workspace_msvc/lib_dec.vcxproj | 351 +++++++++++++ Workspace_msvc/lib_dec.vcxproj.filters | 566 +++++++++++++++++++++ Workspace_msvc/lib_enc.vcxproj | 371 ++++++++++++++ Workspace_msvc/lib_enc.vcxproj.filters | 638 ++++++++++++++++++++++++ Workspace_msvc/lib_isar.vcxproj | 184 +++++++ Workspace_msvc/lib_lc3plus.vcxproj | 201 ++++++++ Workspace_msvc/lib_rend.vcxproj | 210 ++++++++ Workspace_msvc/lib_rend.vcxproj.filters | 149 ++++++ Workspace_msvc/lib_util.vcxproj | 161 ++++++ Workspace_msvc/renderer.vcxproj | 183 +++++++ 16 files changed, 4232 insertions(+) create mode 100644 Workspace_msvc/decoder.vcxproj create mode 100644 Workspace_msvc/encoder.vcxproj create mode 100644 Workspace_msvc/isar_post_rend.vcxproj create mode 100644 Workspace_msvc/lib_com.vcxproj create mode 100644 Workspace_msvc/lib_com.vcxproj.filters create mode 100644 Workspace_msvc/lib_debug.vcxproj create mode 100644 Workspace_msvc/lib_dec.vcxproj create mode 100644 Workspace_msvc/lib_dec.vcxproj.filters create mode 100644 Workspace_msvc/lib_enc.vcxproj create mode 100644 Workspace_msvc/lib_enc.vcxproj.filters create mode 100644 Workspace_msvc/lib_isar.vcxproj create mode 100644 Workspace_msvc/lib_lc3plus.vcxproj create mode 100644 Workspace_msvc/lib_rend.vcxproj create mode 100644 Workspace_msvc/lib_rend.vcxproj.filters create mode 100644 Workspace_msvc/lib_util.vcxproj create mode 100644 Workspace_msvc/renderer.vcxproj diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj new file mode 100644 index 000000000..cbfca4f1f --- /dev/null +++ b/Workspace_msvc/decoder.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + decoder + {E3DCBC31-7FC9-D127-E000-529F8460D5FD} + decoder + 10.0 + + + + Application + v143 + false + MultiByte + + + Application + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + IVAS_dec + + + ..\ + .\Release_$(ProjectName)\ + false + false + IVAS_dec + + + + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + true + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;..\lib_isar;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + libcmtd.lib + + + + + + + + + + {e822ddaf-0f5f-4cd0-a694-38ae69de74d3} + false + + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + + + {2fa8f384-0775-f3b7-f8c3-85209222fc70} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj new file mode 100644 index 000000000..4d7b18be4 --- /dev/null +++ b/Workspace_msvc/encoder.vcxproj @@ -0,0 +1,178 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + encoder + {B3FC9DFC-7268-8660-7C0D-B60BAF02C554} + encoder + 10.0 + + + + Application + v143 + false + MultiByte + + + Application + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + IVAS_cod + + + ..\ + .\Release_$(ProjectName)\ + false + false + IVAS_cod + + + + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_enc;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + false + true + $(IntDir)$(ProjectName).pdb + Console + + false + + MachineX86 + + + + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_enc;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + + + + {824da4cf-06f0-45c9-929a-8792f0e19c3e} + false + + + {2fa8f384-0775-f3b7-f8c3-85209222fc70} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj new file mode 100644 index 000000000..f5bf055e2 --- /dev/null +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -0,0 +1,179 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + isar_post_rend + {12374ADC-0E5C-4FDD-B903-71D572413831} + isar_post_rend + 10.0 + + + + Application + v143 + false + MultiByte + + + Application + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + ISAR_post_rend + + + ..\ + .\Release_$(ProjectName)\ + false + false + ISAR_post_rend + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + false + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + true + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + libcmtd.lib + + + + + + + + + + {54509728-928B-44D9-A118-A6F92F08B34F} + false + + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + + + {2FA8F384-0775-F3B7-F8C3-85209222FC70} + false + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj new file mode 100644 index 000000000..273c31c9d --- /dev/null +++ b/Workspace_msvc/lib_com.vcxproj @@ -0,0 +1,346 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {39EC200D-7795-4FF8-B214-B24EDA5526AE} + common + 10.0 + + + + StaticLibrary + v143 + false + MultiByte + + + StaticLibrary + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + libivascom + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + libivascom + + + + + + + Disabled + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions); + + EnableFastChecks + MultiThreadedDebug + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters new file mode 100644 index 000000000..db5a9bcef --- /dev/null +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj new file mode 100644 index 000000000..853de36c6 --- /dev/null +++ b/Workspace_msvc/lib_debug.vcxproj @@ -0,0 +1,121 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {54509728-928B-44D9-A118-A6F92F08B34F} + debug + 10.0 + + + + StaticLibrary + v143 + MultiByte + + + StaticLibrary + v143 + MultiByte + true + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + libivasdebug + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + libivasdebug + + + + + + + Disabled + ..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;DBG_WAV_WRITER;$(Macros);%(PreprocessorDefinitions) + false + + EnableFastChecks + MultiThreadedDebug + false + $(IntDir)$(ProjectName).pdb + Level4 + OldStyle + Default + %(DisableSpecificWarnings) + + + $(OutDir)$(TargetName).lib + + + + + + + + MaxSpeed + AnySuitable + false + false + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + $(IntDir)$(ProjectName).pdb + Level4 + + Default + %(DisableSpecificWarnings) + + + $(OutDir)$(TargetName).lib + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj new file mode 100644 index 000000000..3b27d2c53 --- /dev/null +++ b/Workspace_msvc/lib_dec.vcxproj @@ -0,0 +1,351 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + lib_dec + {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} + evs_dec + 10.0 + + + StaticLibrary + v143 + false + MultiByte + + + + StaticLibrary + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + false + false + libivasdec + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + false + false + libivasdec + + + + + + + .\Debug\$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + false + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {54509728-928b-44d9-a118-a6f92f08b34f} + false + + + {718DE063-A18B-BB72-9150-62B892E6FFA6} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters new file mode 100644 index 000000000..170eada9a --- /dev/null +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -0,0 +1,566 @@ + + + + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_evs_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_all_c + + + decoder_all_c + + + decoder_ivas_c + + + decoder_all_c + + + decoder_ivas_c + + + decoder_ivas_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + decoder_all_c + + + + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + decoder_h + + + + + {6d564218-e0e5-4a7b-80b3-6b10661ad36c} + + + {33d78f8d-2d43-40f5-a9b1-711097bd6746} + + + {044baa49-b157-45ed-8bec-29b6d7172e82} + + + {adc81a29-2517-49f0-819f-e8cea3d49ae3} + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj new file mode 100644 index 000000000..d2a8ca264 --- /dev/null +++ b/Workspace_msvc/lib_enc.vcxproj @@ -0,0 +1,371 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + lib_enc + {824DA4CF-06F0-45C9-929A-8792F0E19C3E} + evs_enc + 10.0 + + + + StaticLibrary + v143 + false + MultiByte + + + StaticLibrary + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + false + false + libivasenc + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + false + false + libivasenc + + + + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {54509728-928b-44d9-a118-a6f92f08b34f} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj.filters b/Workspace_msvc/lib_enc.vcxproj.filters new file mode 100644 index 000000000..e8f429f49 --- /dev/null +++ b/Workspace_msvc/lib_enc.vcxproj.filters @@ -0,0 +1,638 @@ + + + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_evs_c + + + encoder_ivas_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_all_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_ivas_c + + + encoder_all_c + + + + encoder_all_c + + + + + + encoder_h + + + encoder_h + + + encoder_h + + + encoder_h + + + encoder_h + + + encoder_all_c + + + + + {34137975-e4fd-40f0-938f-02fd46da5e22} + + + {c24a3dcd-cde3-411b-aecf-747c29d87668} + + + {e78e5d72-8d6d-4b00-a6e0-64a62c9cf8f2} + + + {597ebb71-22ba-41e8-b4bf-e8691bda2e5b} + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj new file mode 100644 index 000000000..bec9ea98a --- /dev/null +++ b/Workspace_msvc/lib_isar.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + lib_isar + {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} + isar + 10.0 + + + + StaticLibrary + v143 + false + MultiByte + + + StaticLibrary + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + libisar + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + libisar + + + + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions); + + EnableFastChecks + MultiThreadedDebug + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {54509728-928b-44d9-a118-a6f92f08b34f} + false + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj new file mode 100644 index 000000000..c28f2ad13 --- /dev/null +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -0,0 +1,201 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + Win32Proj + LC3_FL + 10.0 + + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + v143 + + + v143 + + + + + + + + + + + + + + + liblc3plus + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + + + LC3plus + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\Obj\ + + + + + + Level3 + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + Disabled + MultiThreadedDebug + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4305;4244;4996 + OldStyle + false + false + + + Console + true + + + + + Level3 + + + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) + MaxSpeed + MultiThreaded + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4244;4305;4996 + false + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj new file mode 100644 index 000000000..5bdebdb07 --- /dev/null +++ b/Workspace_msvc/lib_rend.vcxproj @@ -0,0 +1,210 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + lib_rend + {718DE063-A18B-BB72-9150-62B892E6FFA6} + evs_dec + 10.0 + + + StaticLibrary + v143 + false + MultiByte + + + + StaticLibrary + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + false + false + libivasrend + + + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + false + false + libivasrend + + + + + + + .\Debug\$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + WS2_32.lib; %(AdditionalDependencies) + $(OutDir)$(TargetName).lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {54509728-928b-44d9-a118-a6f92f08b34f} + false + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + false + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters new file mode 100644 index 000000000..2494e2ee2 --- /dev/null +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -0,0 +1,149 @@ + + + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + rend_c + + + + + + + rend_h + + + rend_h + + + rend_h + + + rend_h + + + rend_h + + + rend_h + + + + + {54449ece-ef29-44b5-9512-ed8f555851a8} + + + {672b0eb6-cce8-425c-8bf2-aba4b45639bb} + + + \ No newline at end of file diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj new file mode 100644 index 000000000..9c987255e --- /dev/null +++ b/Workspace_msvc/lib_util.vcxproj @@ -0,0 +1,161 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {2FA8F384-0775-F3B7-F8C3-85209222FC70} + utility + 10.0 + + + + StaticLibrary + v143 + MultiByte + + + StaticLibrary + v143 + MultiByte + true + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + true + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ + libivasutil + + + false + .\Release_$(ProjectName)\ + .\Release_$(ProjectName)\ + libivasutil + + + + Disabled + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) + false + + EnableFastChecks + MultiThreadedDebug + false + $(IntDir)$(ProjectName).pdb + Level4 + OldStyle + Default + %(DisableSpecificWarnings) + + + $(OutDir)$(TargetName).lib + + + + + MaxSpeed + AnySuitable + false + false + ..\lib_isar;..\lib_lc3plus;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + $(IntDir)$(ProjectName).pdb + Level4 + + Default + %(DisableSpecificWarnings) + + + $(OutDir)$(TargetName).lib + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj new file mode 100644 index 000000000..39bea5cfb --- /dev/null +++ b/Workspace_msvc/renderer.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + renderer + {12B4C8A5-1E06-4E30-B443-D1F916F52B47} + renderer + 10.0 + + + + Application + v143 + false + MultiByte + + + Application + v143 + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.27428.2015 + + + ..\ + .\Debug_$(ProjectName)\ + false + false + IVAS_rend + + + ..\ + .\Release_$(ProjectName)\ + false + false + IVAS_rend + + + + $(IntDir)$(ProjectName).tlb + + + + Disabled + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) + + EnableFastChecks + MultiThreadedDebug + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + OldStyle + Default + %(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + + $(OutDir)$(TargetName).exe + true + + true + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + + + + + $(IntDir)$(ProjectName).tlb + + + + MaxSpeed + AnySuitable + false + Neither + false + false + ..\lib_com;..\lib_debug;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;.%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) + true + + Default + MultiThreaded + true + Precise + false + + + $(IntDir)$(ProjectName).pdb + Level4 + true + + Default + %(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c0c + + + $(OutDir)$(TargetName).exe + true + + false + $(IntDir)$(ProjectName).pdb + Console + false + + MachineX86 + libcmtd.lib + + + + + + + + {54509728-928B-44D9-A118-A6F92F08B34F} + false + + + {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} + false + + + {869a305e-d99e-4c3a-bdb3-aa57abcce619} + + + {2FA8F384-0775-F3B7-F8C3-85209222FC70} + false + + + {39ec200d-7795-4ff8-b214-b24eda5526ae} + false + + + {718DE063-A18B-BB72-9150-62B892E6FFA6} + false + + + + + + + + + + + \ No newline at end of file -- GitLab From a43216ec8ada209be3045d730e3883481ebd4252 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 11:55:33 +0000 Subject: [PATCH 10/80] revert project file changes --- Workspace_msvc/decoder.vcxproj | 8 +- Workspace_msvc/encoder.vcxproj | 6 +- Workspace_msvc/isar_post_rend.vcxproj | 6 +- Workspace_msvc/lib_com.vcxproj | 6 +- Workspace_msvc/lib_com.vcxproj.filters | 846 ++++++++++++++++++------ Workspace_msvc/lib_debug.vcxproj | 6 +- Workspace_msvc/lib_dec.vcxproj | 6 +- Workspace_msvc/lib_enc.vcxproj | 6 +- Workspace_msvc/lib_isar.vcxproj | 6 +- Workspace_msvc/lib_lc3plus.vcxproj | 12 +- Workspace_msvc/lib_rend.vcxproj | 10 +- Workspace_msvc/lib_rend.vcxproj.filters | 3 + Workspace_msvc/lib_util.vcxproj | 10 +- Workspace_msvc/renderer.vcxproj | 8 +- 14 files changed, 682 insertions(+), 257 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index cbfca4f1f..3ab058c29 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -14,18 +14,18 @@ decoder {E3DCBC31-7FC9-D127-E000-529F8460D5FD} decoder - 10.0 + 10.0.17763.0 Application - v143 + v141 false MultiByte Application - v143 + v141 false MultiByte @@ -159,7 +159,7 @@ {869a305e-d99e-4c3a-bdb3-aa57abcce619} - + {2fa8f384-0775-f3b7-f8c3-85209222fc70} false diff --git a/Workspace_msvc/encoder.vcxproj b/Workspace_msvc/encoder.vcxproj index 4d7b18be4..9578e488d 100644 --- a/Workspace_msvc/encoder.vcxproj +++ b/Workspace_msvc/encoder.vcxproj @@ -14,18 +14,18 @@ encoder {B3FC9DFC-7268-8660-7C0D-B60BAF02C554} encoder - 10.0 + 10.0.17763.0 Application - v143 + v141 false MultiByte Application - v143 + v141 false MultiByte diff --git a/Workspace_msvc/isar_post_rend.vcxproj b/Workspace_msvc/isar_post_rend.vcxproj index f5bf055e2..19cb1aff7 100644 --- a/Workspace_msvc/isar_post_rend.vcxproj +++ b/Workspace_msvc/isar_post_rend.vcxproj @@ -14,18 +14,18 @@ isar_post_rend {12374ADC-0E5C-4FDD-B903-71D572413831} isar_post_rend - 10.0 + 10.0.17763.0 Application - v143 + v141 false MultiByte Application - v143 + v141 false MultiByte diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 273c31c9d..8e37844b9 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -13,18 +13,18 @@ {39EC200D-7795-4FF8-B214-B24EDA5526AE} common - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 false MultiByte StaticLibrary - v143 + v141 false MultiByte diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index db5a9bcef..9908f462d 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -1,218 +1,646 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_evs_c + + + common_all_c + + + common_evs_c + + + common_evs_c + + + common_evs_c + + + common_evs_c + + + common_evs_c + + + common_evs_c + + + common_evs_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_ivas_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_ivas_c + + + + common_ivas_c + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + - - - - - - - - - + + common_h + + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + - + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + + + {890c2f45-9385-4fce-859b-6a65469e8dc0} + + + {201ea764-9626-4dca-9cc4-5b4106f8b8b2} + + + {fbb860e2-79d0-45b1-ada1-c3a0a369ce2c} + + + {b95b7bed-a666-4a00-9332-2b528638503e} + \ No newline at end of file diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 853de36c6..929dd72a8 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -13,17 +13,17 @@ {54509728-928B-44D9-A118-A6F92F08B34F} debug - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 MultiByte StaticLibrary - v143 + v141 MultiByte true diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 3b27d2c53..e5998e672 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -14,18 +14,18 @@ lib_dec {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3} evs_dec - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 false MultiByte StaticLibrary - v143 + v141 false MultiByte diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index d2a8ca264..123754142 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -14,18 +14,18 @@ lib_enc {824DA4CF-06F0-45C9-929A-8792F0E19C3E} evs_enc - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 false MultiByte StaticLibrary - v143 + v141 false MultiByte diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index bec9ea98a..cdc0979a0 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -14,18 +14,18 @@ lib_isar {869A305E-D99E-4C3A-BDB3-AA57ABCCE619} isar - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 false MultiByte StaticLibrary - v143 + v141 false MultiByte diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index c28f2ad13..22b5cddd3 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -22,28 +22,22 @@ {95030B82-70CD-4C6B-84D4-61096035BEA2} Win32Proj LC3_FL - 10.0 + 10.0.17763.0 StaticLibrary true - v143 + v141 Unicode StaticLibrary false - v143 + v141 true Unicode - - v143 - - - v143 - diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 5bdebdb07..f93b5f26d 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -14,18 +14,18 @@ lib_rend {718DE063-A18B-BB72-9150-62B892E6FFA6} evs_dec - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 false MultiByte StaticLibrary - v143 + v141 false MultiByte @@ -197,7 +197,7 @@ {95030B82-70CD-4C6B-84D4-61096035BEA2} false - + @@ -207,4 +207,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 2494e2ee2..820a5c044 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -31,6 +31,9 @@ rend_c + + rend_c + rend_c diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 9c987255e..ceb342b21 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -13,17 +13,17 @@ {2FA8F384-0775-F3B7-F8C3-85209222FC70} utility - 10.0 + 10.0.17763.0 StaticLibrary - v143 + v141 MultiByte StaticLibrary - v143 + v141 MultiByte true @@ -121,7 +121,7 @@ - + @@ -148,7 +148,7 @@ - + diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index 39bea5cfb..1bc5b5568 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -14,18 +14,18 @@ renderer {12B4C8A5-1E06-4E30-B443-D1F916F52B47} renderer - 10.0 + 10.0.17763.0 Application - v143 + v141 false MultiByte Application - v143 + v141 false MultiByte @@ -158,7 +158,7 @@ {869a305e-d99e-4c3a-bdb3-aa57abcce619} - + {2FA8F384-0775-F3B7-F8C3-85209222FC70} false -- GitLab From 3c41678fb620d695108386d898cad52323577fc9 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 15:58:43 +0200 Subject: [PATCH 11/80] replaced som more overflow ops --- lib_enc/cod2t32_fx.c | 54 +++++++++++++++++++++++++++++++++++ lib_enc/cod_ace_fx.c | 11 +++++++ lib_enc/cod_tcx_fx.c | 22 +++++++------- lib_enc/core_enc_ol_fx.c | 36 +++++++++++++++++++++-- lib_enc/corr_xh_fx.c | 33 +++++++++++++++++++++ lib_enc/detect_transient_fx.c | 49 ++++++++++++++++++++++++++++++- 6 files changed, 191 insertions(+), 14 deletions(-) diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index dc967e656..9ffc8f1f8 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -47,9 +47,11 @@ void acelp_2t32_fx( Word32 L_tmp; Word16 rrixix[NB_TRACK_FCB_2T][NB_POS_FCB_2T]; Word16 rrixiy[MSIZE]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* * Compute rrixix[][] needed for the codebook search. @@ -63,11 +65,19 @@ void acelp_2t32_fx( L_cor = L_deposit_h( 1 ); 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 ); //??sat +#else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); +#endif ptr_h1++; *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat +#else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); +#endif ptr_h1++; *p0-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ @@ -108,17 +118,28 @@ void acelp_2t32_fx( L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q(12+12+1) 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) //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat + *p0 = round_fx_sat( L_cor ); // Q(9) //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat +#else *p1 = round_fx_o( L_cor, &Overflow ); // Q(25-16) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); *p0 = round_fx_o( L_cor, &Overflow ); // Q(9) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); +#endif move16(); move16(); p1 -= ( NB_POS_FCB_2T + 1 ); p0 -= ( NB_POS_FCB_2T + 1 ); } +#ifdef ISSUE_1867_replace_overflow_libenc + *p1 = round_fx_sat( L_cor ); // Q9 //??sat +#else *p1 = round_fx_o( L_cor, &Overflow ); // Q9 +#endif pos -= NB_POS_FCB_2T; move16(); pos2--; @@ -221,9 +242,15 @@ void acelp_2t32_fx( FOR( i1 = 1; i1 < L_SUBFR; i1 += STEP ) { ps2 = add( ps1, dn_p[i1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat + sq = mult( ps2, ps2 ); + s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat +#else alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); sq = mult( ps2, ps2 ); s = L_msu_o( L_mult( alpk, sq ), psk, alp2, &Overflow ); +#endif IF( s > 0 ) { psk = sq; @@ -317,9 +344,11 @@ void acelp_2t32_ivas_fx( Word32 L_tmp; Word16 rrixix[NB_TRACK_FCB_2T][NB_POS_FCB_2T]; Word16 rrixiy[MSIZE]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* * Compute rrixix[][] needed for the codebook search. @@ -334,11 +363,19 @@ void acelp_2t32_ivas_fx( L_cor = L_deposit_h( 1 ); 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 ); //??sat +#else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); +#endif ptr_h1++; *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat +#else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); +#endif ptr_h1++; *p0-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ @@ -379,17 +416,28 @@ void acelp_2t32_ivas_fx( L_cor = L_mult( *ptr_h1++, *ptr_h2++ ); // Q25 FOR( i = k; i < NB_POS_FCB_2T - 1; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + *p1 = round_fx_sat( L_cor ); // Q9 //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat + *p0 = round_fx_sat( L_cor ); // Q9 //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat +#else *p1 = round_fx_o( L_cor, &Overflow ); // Q9 L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); *p0 = round_fx_o( L_cor, &Overflow ); // Q9 L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); +#endif move16(); move16(); p1 -= ( NB_POS_FCB_2T + 1 ); p0 -= ( NB_POS_FCB_2T + 1 ); } +#ifdef ISSUE_1867_replace_overflow_libenc + *p1 = round_fx_sat( L_cor ); //??sat +#else *p1 = round_fx_o( L_cor, &Overflow ); +#endif pos -= NB_POS_FCB_2T; move16(); pos2 = sub( pos2, 1 ); @@ -493,9 +541,15 @@ void acelp_2t32_ivas_fx( FOR( i1 = 1; i1 < L_SUBFR; i1 += STEP ) { ps2 = add( ps1, dn_p[i1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat + sq = mult( ps2, ps2 ); + s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat +#else alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); sq = mult( ps2, ps2 ); s = L_msu_o( L_mult( alpk, sq ), psk, alp2, &Overflow ); +#endif IF( s > 0 ) { psk = sq; diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index e1914aeb5..9796c0c27 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -75,9 +75,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Word16 dummy = 0; move16(); ACELP_config *acelp_cfg; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif acelp_cfg = &( st->acelp_cfg ); @@ -351,13 +353,22 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); Ltmp = L_shl( Ltmp, Q_new_p5 ); 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 ) ); //??sat +#else exc2[i] = round_fx_sat( L_shl_o( Ltmp, 1, &Overflow ) ); +#endif move16(); Ltmp2 = Mpy_32_16_1( gain_code, code[i] ); Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); Ltmp = L_add_sat( Ltmp, Ltmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ //??sat + exc[i + i_subfr] = round_fx_sat( Ltmp ); //??sat +#else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); +#endif move16(); } /*-----------------------------------------------------------------* diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index c598af538..4c4afac37 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1657,8 +1657,8 @@ void QuantizeSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1796_replace_shl_o - hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); +#ifdef ISSUE_1836_replace_overflow_libcom + hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat #else hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); #endif @@ -1781,8 +1781,8 @@ void QuantizeSpectrum_fx( } /* Limit low sqGain for avoiding saturation of the gain quantizer*/ -#ifdef ISSUE_1796_replace_shl_o - tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); //??sat #else tmp1 = mult_r( shl_o( L_spec, 5, &Overflow ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); #endif @@ -2745,8 +2745,8 @@ void QuantizeSpectrum_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < L_frame; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); +#ifdef ISSUE_1867_replace_overflow_libenc + xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat #else xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); #endif @@ -3256,8 +3256,8 @@ void QuantizeTCXSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1796_replace_shl_o - hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); +#ifdef ISSUE_1836_replace_overflow_libcom + hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat #else hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); #endif @@ -4023,7 +4023,7 @@ void InternalTCXDecoder_fx( Word16 Aq_old_fx[M + 1]; Word32 sns_interpolated_scalefactors_fx[FDNS_NPTS], A_fx32[M + 1]; Word16 *xn_buf16 = (Word16 *) xn_buf32; -#if !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1836_replace_overflow_libcom ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -4677,8 +4677,8 @@ void InternalTCXDecoder_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < L_frame; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); +#ifdef ISSUE_1836_replace_overflow_libcom + xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat #else xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); #endif diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 2f2682b8e..137b3a840 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -82,10 +82,13 @@ void core_encode_openloop_fx( Word16 lsp_old_q_rf[M + 1], lsf_old_q_rf[M + 1]; (void) vad_hover_flag; (void) vad_flag_dtx; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif + TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; RF_ENC_HANDLE hRF = st->hRF; @@ -552,8 +555,8 @@ void core_encode_openloop_fx( /*v_sub(lsf_uq_rf, lsf_q_1st_rf, lsf_q_d_rf, M);*/ FOR( i = 0; i < M; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - lsf_q_d_rf[i] = shl_sat( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5 ); +#ifdef ISSUE_1836_replace_overflow_libcom + lsf_q_d_rf[i] = shl_sat( mult_r( sub_sat( lsf_uq_rf[i], lsf_q_1st_rf[i] ), 25600 ), 5 ); //??sat #else lsf_q_d_rf[i] = shl_o( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5, &Overflow ); #endif @@ -757,9 +760,11 @@ static void closest_centroid_rf( Word16 tmp, tmpL; Word64 werr_64; Word32 L_tmp, best_werr, werr; +#ifdef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif ind_vec[0] = 0; @@ -775,8 +780,13 @@ static void closest_centroid_rf( tmpL = i_mult2( i, length ); FOR( j = 0; j < length; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + tmp = sub_sat( data[j], quantizer[tmpL + j] ); //??sat + L_tmp = L_mult_sat( tmp, tmp ); //??sat +#else tmp = sub_o( data[j], quantizer[tmpL + j], &Overflow ); L_tmp = L_mult_o( tmp, tmp, &Overflow ); +#endif werr_64 = W_mac_32_16( werr_64, L_tmp, weights[j] ); } werr = W_sat_m( werr_64 ); @@ -828,9 +838,11 @@ void core_acelp_tcx20_switching_fx( Word16 snr_tcx, snr_acelp, dsnr; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; +#ifdef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Check minimum pitch for quantization */ @@ -1107,7 +1119,11 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + tmp32 = L_mac0_sat( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat +#else 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_add( tmp32, L_sub( 0x1F0000, L_shl( L_deposit_h( add( Q_new, sub( shift, 1 ) ) ), 1 ) ) ); /* wspeech_enc scaling */ @@ -1125,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) */ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1836_replace_overflow_libcom + snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */ //??sat //??sat +#else snr_tcx = round_fx_o( L_shl_o( tcx_snr, 8, &Overflow ), &Overflow ); /* 7Q8 */ +#endif BASOP_SATURATE_WARNING_ON_EVS /*--------------------------------------------------------------* @@ -1159,11 +1179,19 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + signal = L_mac0_sat( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat + + tmp16 = round_fx_sat( L_shl_sat( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15 ) ); //??sat + tmp16 = sub_sat( st->wspeech_enc[i + j], tmp16 ); //??sat + noise = L_mac0_sat( noise, tmp16, tmp16 ); //??sat +#else 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 = sub_o( st->wspeech_enc[i + j], tmp16, &Overflow ); noise = L_mac0_o( noise, tmp16, tmp16, &Overflow ); +#endif } /* Assume always 4 sub frames. */ /*assert( (st->L_frame / L_SUBFR) == 4);*/ @@ -1216,7 +1244,11 @@ void core_acelp_tcx20_switching_fx( test(); if ( ( GT_16( snr_acelp, snr_tcx ) ) && ( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) && +#ifdef ISSUE_1836_replace_overflow_libcom + ( LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || //??sat +#else ( 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*/ ) ) ) && ( LE_16( st->acelpFramesCount, 6 ) ) ) { diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 56b22c206..7c72e7f55 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -31,9 +31,11 @@ void corr_xh_fx( { Word16 i, j, k; Word32 L_tmp, y32[L_SUBFR], L_maxloc, L_tot; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /* first keep the result on 32 bits and find absolute maximum */ @@ -47,7 +49,11 @@ void corr_xh_fx( L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/ FOR( j = i; j < L_SUBFR - 1; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ +#else L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ +#endif } y32[i] = L_tmp; /*Qx+15*/ @@ -57,8 +63,13 @@ void corr_xh_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); +#ifdef ISSUE_1836_replace_overflow_libcom + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat + L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat +#else 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 */ +#endif } /* Find the number of right shifts to do on y32[] so that */ @@ -82,9 +93,11 @@ void corr_hh_ivas_fx( { Word16 i, j, k; Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /* first keep the result on 32 bits and find absolute maximum */ @@ -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 FOR( j = i; j < L_subfr - 1; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + 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 +#endif } y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1 @@ -108,8 +125,13 @@ void corr_hh_ivas_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); +#ifdef ISSUE_1836_replace_overflow_libcom + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat + L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat +#else 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 */ +#endif } /* Find the number of right shifts to do on y32[] so that */ @@ -139,9 +161,11 @@ void corr_xh_ivas_fx( { Word16 i, j, k; Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /* first keep the result on 32 bits and find absolute maximum */ @@ -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 FOR( j = i; j < L_subfr - 1; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mac_sat( L_tmp, x[j + 1], h[j + 1 - i] ); // Qx+(14 - norm_s(h[0])) + 1 //??sat +#else 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 @@ -165,8 +193,13 @@ void corr_xh_ivas_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); +#ifdef ISSUE_1836_replace_overflow_libcom + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat + L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat +#else 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 */ +#endif } /* Find the number of right shifts to do on y32[] so that */ diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 51f1cb476..b2ac485ea 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -62,22 +62,34 @@ static void hp_filter_fx( { Word16 i; Word32 L_tmp; +#ifdef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */ +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mult( sub_sat( x[0], *oldx ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat +#else 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 */ y[0] = round_fx_sat( L_tmp ); /*Q_new */ FOR( i = 1; i < L; i++ ) { /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mult( sub_sat( x[i], x[i - 1] ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat + L_tmp = L_mac_sat( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ //??sat + y[i] = round_fx_sat( L_tmp ); /*Q_new */ //??sat +#else 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 */ y[i] = round_fx_o( L_tmp, &Overflow ); /*Q_new */ +#endif } *oldx = x[L - 1]; @@ -117,9 +129,11 @@ Word16 detect_transient_fx( Word32 E_low_fx, E_high_fx; Word16 temp16, Thres_fx = 0; Word16 exp; +#ifdef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif shift = 0; @@ -151,7 +165,11 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 4; i++ ) { /*EnergyLT += out_filt[i] * out_filt[i]; */ +#ifdef ISSUE_1836_replace_overflow_libcom + EnergyLT = L_mac0_sat( EnergyLT, out_filt_fx[i], out_filt_fx[i] ); /*2Q_new */ //??sat +#else EnergyLT = L_mac0_o( EnergyLT, out_filt_fx[i], out_filt_fx[i], &Overflow ); /*2Q_new */ +#endif } } ELSE @@ -170,14 +188,27 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 4; i++ ) { temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); +#ifdef ISSUE_1836_replace_overflow_libcom + Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); //??sat +#else Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow ); +#endif temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ +#ifdef ISSUE_1836_replace_overflow_libcom + Energy_in_fx[blk + 1] = L_add_sat( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); /*Q0*/ //??sat +#else Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/ +#endif move32(); } +#ifdef ISSUE_1836_replace_overflow_libcom + E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/ //??sat + E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/ //??sat +#else 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*/ +#endif Thres_fx = 2185; /*1 /15 Q15*/ move16(); @@ -201,13 +232,21 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 8; i++ ) { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mac0_sat( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat +#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 */ +#endif } L_tmp2 = L_deposit_l( 0 ); FOR( ; i < L / 4; i++ ) { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ - L_tmp2 = L_mac0_o( L_tmp2, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp2 = L_mac0_sat( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat +#else + L_tmp2 = L_mac0_o( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ +#endif } Overflow = 0; move16(); @@ -218,10 +257,14 @@ Word16 detect_transient_fx( shift = 1; move16(); } +#ifndef ISSUE_1836_replace_overflow_libcom Overflow = 0; move16(); 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*/ //??sat +#endif test(); IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) { @@ -262,7 +305,11 @@ Word16 detect_transient_fx( } /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ +#ifdef ISSUE_1836_replace_overflow_libcom + 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 */ //??sat +#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 */ +#endif } } st_fx->EnergyLT_fx = EnergyLT; -- GitLab From b1b8a0b86db78b6ecd5be3ef0cbfa9244e34143e Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 16:59:00 +0200 Subject: [PATCH 12/80] some more ovfl replacements --- lib_enc/dtx_fx.c | 34 ++++++++++++++++++++++++++++++++++ lib_enc/enc_acelpx_fx.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 247dcbda3..5dcdb761b 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -74,9 +74,11 @@ void dtx_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word32 total_brate_ref; @@ -461,7 +463,11 @@ void dtx_ivas_fx( speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat +#else L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ +#endif speech++; } 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( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif IF( st_fx->dtx_sce_sba != 0 ) @@ -931,7 +939,11 @@ void dtx_fx( speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat +#else L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ +#endif speech++; } 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( VAD_HANDLE hVAD = st_fx->hVAD; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /* get current frame exc energy in log2 */ @@ -1407,7 +1421,11 @@ void dtx_hangover_control_fx( move16(); FOR( j = 0; j < m; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat +#else 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 */ @@ -1423,10 +1441,18 @@ void dtx_hangover_control_fx( move16(); FOR( j = 0; j < m; j++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat +#else lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ +#endif } +#ifdef ISSUE_1836_replace_overflow_libcom + lsp_est[i] = sub_sat( lsp_est[i], add_sat( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i] ) ); /*Q15 */ //??sat +#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 */ +#endif S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */ lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */ } @@ -1436,7 +1462,11 @@ void dtx_hangover_control_fx( move16(); FOR( i = 0; i < M; i++ ) { +#ifdef ISSUE_1836_replace_overflow_libcom + Dlsp_n2e = add_sat( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ) ); /*Q15 */ //??sat +#else 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 */ } @@ -1449,7 +1479,11 @@ void dtx_hangover_control_fx( FOR( i = 0; i < M; i++ ) { S_tmp = abs_s( sub( hDtxEnc->lspCNG_fx[i], lsp_est[i] ) ); /*Q15 */ +#ifdef ISSUE_1836_replace_overflow_libcom + Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */ //??sat +#else Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ +#endif IF( GT_16( S_tmp, S_max ) ) { S_max = S_tmp; /*Q15 */ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 1a17a0f9c..be807cad0 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -139,9 +139,11 @@ static void E_ACELP_2pulse_searchx_fx( Word32 alp0, alp1, alp2, s; Word16 *pR, sgnx; Word16 sqk[2], alpk[2], ik; +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* eight dn2 max positions per track */ @@ -167,8 +169,11 @@ static void E_ACELP_2pulse_searchx_fx( { sgnx = negate( sgnx ); } +#ifdef ISSUE_1836_replace_overflow_libcom + 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 ) //??sat //??sat //??sat +#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 ) - +#endif { sqk[0] = 1; move16(); @@ -189,7 +194,11 @@ static void E_ACELP_2pulse_searchx_fx( /*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/ ps1 = add_sat( ps0, dn[x] ); /*Qdn*/ /*alp1 = alp0 + 2*sgnx*cor[x]; INDIRECT(1);MULT(1); MAC(1);*/ +#ifdef ISSUE_1836_replace_overflow_libcom + 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 */ +#endif pR = R - x; /*Q9+scale*/ FOR( y = track_y; y < L_SUBFR; y += 4 ) @@ -204,14 +213,26 @@ static void E_ACELP_2pulse_searchx_fx( assert( sgnx != 0 ); alp2_16 = 0; +#ifdef ISSUE_1836_replace_overflow_libcom + alp2 = L_mac_sat( alp1, cor[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat +#else alp2 = L_mac_o( alp1, cor[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ +#endif if ( sgnx > 0 ) { +#ifdef ISSUE_1836_replace_overflow_libcom + 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 */ +#endif } if ( sgnx < 0 ) { +#ifdef ISSUE_1836_replace_overflow_libcom + alp2_16 = msu_r_sat( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat +#else alp2_16 = msu_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ +#endif } alpk[1 - ik] = alp2_16; /* Qalp */ move16(); @@ -223,7 +244,11 @@ static void E_ACELP_2pulse_searchx_fx( /*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/ +#ifdef ISSUE_1836_replace_overflow_libcom + s = L_msu_sat( L_mult( alpk[ik], sq ), sqk[ik], alp2_16 ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ //??sat +#else 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 ) { ik = sub( 1, ik ); @@ -281,9 +306,11 @@ static void E_ACELP_1pulse_searchx_fx( Word16 ntracks, t; Word16 sqk[2], alpk[2], ik; move16(); +#ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* save these to limit memory searches */ /*alp0 = *alp + R[0]; INDIRECT(1);*/ @@ -299,7 +326,11 @@ static void E_ACELP_1pulse_searchx_fx( sqk[0] = -1; ik = 0; move16(); +#ifdef ISSUE_1836_replace_overflow_libcom + if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) //??sat +#else if ( mac_ro( alp0, cor[tracks[0]], sign[tracks[0]], &Overflow ) < 0 ) +#endif { sqk[0] = 1; move16(); @@ -323,7 +354,11 @@ static void E_ACELP_1pulse_searchx_fx( ps1 = add( ps0, dn[x] ); /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(1);*/ assert( sign[x] == sign_val_1 << 1 || sign[x] == -( sign_val_1 << 1 ) ); +#ifdef ISSUE_1836_replace_overflow_libcom + alp1 = mac_r_Sat( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat +#else alp1 = mac_ro( alp0, cor[x], sign[x], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ +#endif alpk[1 - ik] = alp1; /* Qalp */ move16(); @@ -334,7 +369,11 @@ static void E_ACELP_1pulse_searchx_fx( move16(); /*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/ +#ifdef ISSUE_1836_replace_overflow_libcom + s = L_msu_sat( L_mult_sat( alpk[ik], sq ), sqk[ik], alp1 ); /* Q9+Qalp+1 */ //??sat +#else s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */ +#endif if ( s > 0 ) { ik = sub( 1, ik ); -- GitLab From bd4109ff499a5d48c2ed820642790010836586a8 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 12 Aug 2025 17:07:59 +0200 Subject: [PATCH 13/80] clang patch --- lib_enc/cod2t32_fx.c | 28 ++++++++++----------- lib_enc/cod_ace_fx.c | 4 +-- lib_enc/cod_tcx_fx.c | 10 ++++---- lib_enc/core_enc_ol_fx.c | 20 +++++++-------- lib_enc/corr_xh_fx.c | 28 ++++++++++----------- lib_enc/detect_transient_fx.c | 46 +++++++++++++++++------------------ lib_enc/dtx_fx.c | 32 ++++++++++++------------ lib_enc/enc_acelpx_fx.c | 30 +++++++++++------------ 8 files changed, 99 insertions(+), 99 deletions(-) diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index 9ffc8f1f8..faaa52be1 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -66,7 +66,7 @@ void acelp_2t32_fx( 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 ); //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -119,10 +119,10 @@ void acelp_2t32_fx( 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) //??sat + *p1 = round_fx_sat( L_cor ); // Q(25-16) //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat + *p0 = round_fx_sat( L_cor ); // Q(9) //??sat L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat - *p0 = round_fx_sat( L_cor ); // Q(9) //??sat - L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat #else *p1 = round_fx_o( L_cor, &Overflow ); // Q(25-16) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); @@ -243,9 +243,9 @@ void acelp_2t32_fx( { ps2 = add( ps1, dn_p[i1] ); #ifdef ISSUE_1867_replace_overflow_libenc - alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat + alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat sq = mult( ps2, ps2 ); - s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat + s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat #else alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); sq = mult( ps2, ps2 ); @@ -364,7 +364,7 @@ void acelp_2t32_ivas_fx( 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 ); //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -372,7 +372,7 @@ void acelp_2t32_ivas_fx( *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -417,10 +417,10 @@ void acelp_2t32_ivas_fx( FOR( i = k; i < NB_POS_FCB_2T - 1; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - *p1 = round_fx_sat( L_cor ); // Q9 //??sat + *p1 = round_fx_sat( L_cor ); // Q9 //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat + *p0 = round_fx_sat( L_cor ); // Q9 //??sat L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat - *p0 = round_fx_sat( L_cor ); // Q9 //??sat - L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat #else *p1 = round_fx_o( L_cor, &Overflow ); // Q9 L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); @@ -434,7 +434,7 @@ void acelp_2t32_ivas_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - *p1 = round_fx_sat( L_cor ); //??sat + *p1 = round_fx_sat( L_cor ); //??sat #else *p1 = round_fx_o( L_cor, &Overflow ); #endif @@ -542,9 +542,9 @@ void acelp_2t32_ivas_fx( { ps2 = add( ps1, dn_p[i1] ); #ifdef ISSUE_1867_replace_overflow_libenc - alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat + alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat sq = mult( ps2, ps2 ); - s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat + s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat #else alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); sq = mult( ps2, ps2 ); diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 9796c0c27..cfc29cf68 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -363,8 +363,8 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); Ltmp = L_add_sat( Ltmp, Ltmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ //??sat - exc[i + i_subfr] = round_fx_sat( Ltmp ); //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ //??sat + exc[i + i_subfr] = round_fx_sat( Ltmp ); //??sat #else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 4c4afac37..0eb425087 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1658,7 +1658,7 @@ void QuantizeSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1836_replace_overflow_libcom - hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat + hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat #else hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); #endif @@ -1782,7 +1782,7 @@ void QuantizeSpectrum_fx( /* Limit low sqGain for avoiding saturation of the gain quantizer*/ #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); //??sat + tmp1 = mult_r( shl_sat( L_spec, 5 ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); //??sat #else tmp1 = mult_r( shl_o( L_spec, 5, &Overflow ), 26214 /*128.f/NORM_MDCT_FACTOR Q15*/ ); #endif @@ -2746,7 +2746,7 @@ void QuantizeSpectrum_fx( FOR( i = 0; i < L_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat + xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat #else xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); #endif @@ -3257,7 +3257,7 @@ void QuantizeTCXSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1836_replace_overflow_libcom - hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat + hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat #else hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); #endif @@ -4678,7 +4678,7 @@ void InternalTCXDecoder_fx( FOR( i = 0; i < L_frame; i++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat + xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat #else xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); #endif diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 137b3a840..e8ca475af 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -556,7 +556,7 @@ void core_encode_openloop_fx( FOR( i = 0; i < M; i++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - lsf_q_d_rf[i] = shl_sat( mult_r( sub_sat( lsf_uq_rf[i], lsf_q_1st_rf[i] ), 25600 ), 5 ); //??sat + lsf_q_d_rf[i] = shl_sat( mult_r( sub_sat( lsf_uq_rf[i], lsf_q_1st_rf[i] ), 25600 ), 5 ); //??sat #else lsf_q_d_rf[i] = shl_o( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5, &Overflow ); #endif @@ -781,8 +781,8 @@ static void closest_centroid_rf( FOR( j = 0; j < length; j++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - tmp = sub_sat( data[j], quantizer[tmpL + j] ); //??sat - L_tmp = L_mult_sat( tmp, tmp ); //??sat + tmp = sub_sat( data[j], quantizer[tmpL + j] ); //??sat + L_tmp = L_mult_sat( tmp, tmp ); //??sat #else tmp = sub_o( data[j], quantizer[tmpL + j], &Overflow ); L_tmp = L_mult_o( tmp, tmp, &Overflow ); @@ -1120,7 +1120,7 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - tmp32 = L_mac0_sat( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat + tmp32 = L_mac0_sat( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat #else tmp32 = L_mac0_o( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); #endif @@ -1142,7 +1142,7 @@ void core_acelp_tcx20_switching_fx( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1836_replace_overflow_libcom - snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */ //??sat //??sat + snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */ //??sat //??sat #else snr_tcx = round_fx_o( L_shl_o( tcx_snr, 8, &Overflow ), &Overflow ); /* 7Q8 */ #endif @@ -1180,11 +1180,11 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - signal = L_mac0_sat( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat + signal = L_mac0_sat( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat - tmp16 = round_fx_sat( L_shl_sat( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15 ) ); //??sat - tmp16 = sub_sat( st->wspeech_enc[i + j], tmp16 ); //??sat - noise = L_mac0_sat( noise, tmp16, tmp16 ); //??sat + tmp16 = round_fx_sat( L_shl_sat( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15 ) ); //??sat + tmp16 = sub_sat( st->wspeech_enc[i + j], tmp16 ); //??sat + noise = L_mac0_sat( noise, tmp16, tmp16 ); //??sat #else signal = L_mac0_o( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); @@ -1245,7 +1245,7 @@ void core_acelp_tcx20_switching_fx( if ( ( GT_16( snr_acelp, snr_tcx ) ) && ( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) && #ifdef ISSUE_1836_replace_overflow_libcom - ( LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || //??sat + ( LT_16( add_sat( st->prevTempFlatness_fx, currFlatness ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || //??sat #else ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || #endif diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 7c72e7f55..ae084666c 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -52,7 +52,7 @@ void corr_xh_fx( #ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*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 } @@ -64,11 +64,11 @@ void corr_xh_fx( /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); #ifdef ISSUE_1836_replace_overflow_libcom - L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat - L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat + L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat #else - 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_maxloc, &Overflow ); /* +max/4 */ + L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ #endif } @@ -126,11 +126,11 @@ void corr_hh_ivas_fx( /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); #ifdef ISSUE_1836_replace_overflow_libcom - L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat - L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat + L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat #else - 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_maxloc, &Overflow ); /* +max/4 */ + L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ #endif } @@ -182,7 +182,7 @@ void corr_xh_ivas_fx( #ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_mac_sat( L_tmp, x[j + 1], h[j + 1 - i] ); // Qx+(14 - norm_s(h[0])) + 1 //??sat #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 } @@ -194,11 +194,11 @@ void corr_xh_ivas_fx( /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); #ifdef ISSUE_1836_replace_overflow_libcom - L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat - L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat + L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat + L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat #else - 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_maxloc, &Overflow ); /* +max/4 */ + L_tot = L_add_o( L_tot, L_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ #endif } diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index b2ac485ea..86d39ec0c 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -72,19 +72,19 @@ static void hp_filter_fx( /*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */ #ifdef ISSUE_1836_replace_overflow_libcom - L_tmp = L_mult( sub_sat( x[0], *oldx ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat + L_tmp = L_mult( sub_sat( x[0], *oldx ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat #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 */ - y[0] = round_fx_sat( L_tmp ); /*Q_new */ + 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 */ FOR( i = 1; i < L; i++ ) { /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ #ifdef ISSUE_1836_replace_overflow_libcom - L_tmp = L_mult( sub_sat( x[i], x[i - 1] ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat - L_tmp = L_mac_sat( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ //??sat - y[i] = round_fx_sat( L_tmp ); /*Q_new */ //??sat + L_tmp = L_mult( sub_sat( x[i], x[i - 1] ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat + L_tmp = L_mac_sat( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ //??sat + y[i] = round_fx_sat( L_tmp ); /*Q_new */ //??sat #else 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 */ @@ -166,7 +166,7 @@ Word16 detect_transient_fx( { /*EnergyLT += out_filt[i] * out_filt[i]; */ #ifdef ISSUE_1836_replace_overflow_libcom - EnergyLT = L_mac0_sat( EnergyLT, out_filt_fx[i], out_filt_fx[i] ); /*2Q_new */ //??sat + EnergyLT = L_mac0_sat( EnergyLT, out_filt_fx[i], out_filt_fx[i] ); /*2Q_new */ //??sat #else EnergyLT = L_mac0_o( EnergyLT, out_filt_fx[i], out_filt_fx[i], &Overflow ); /*2Q_new */ #endif @@ -189,26 +189,26 @@ Word16 detect_transient_fx( { temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); #ifdef ISSUE_1836_replace_overflow_libcom - Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); //??sat + Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); //??sat #else 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_1836_replace_overflow_libcom - Energy_in_fx[blk + 1] = L_add_sat( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); /*Q0*/ //??sat + Energy_in_fx[blk + 1] = L_add_sat( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); /*Q0*/ //??sat #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(); } #ifdef ISSUE_1836_replace_overflow_libcom - E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/ //??sat - E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/ //??sat + E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/ //??sat + E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/ //??sat #else - 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*/ -#endif + 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*/ +#endif Thres_fx = 2185; /*1 /15 Q15*/ move16(); @@ -233,9 +233,9 @@ Word16 detect_transient_fx( { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ #ifdef ISSUE_1836_replace_overflow_libcom - L_tmp = L_mac0_sat( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat + L_tmp = L_mac0_sat( L_tmp, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat #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 ); @@ -243,9 +243,9 @@ Word16 detect_transient_fx( { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ #ifdef ISSUE_1836_replace_overflow_libcom - L_tmp2 = L_mac0_sat( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat + L_tmp2 = L_mac0_sat( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat #else - L_tmp2 = L_mac0_o( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ + L_tmp2 = L_mac0_o( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )], &Overflow ); /*2Q_new */ #endif } Overflow = 0; @@ -263,7 +263,7 @@ Word16 detect_transient_fx( 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*/ //??sat + Energy = L_add_sat( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) ); /*2Q_new - shift*/ //??sat #endif test(); IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) @@ -306,7 +306,7 @@ Word16 detect_transient_fx( /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ #ifdef ISSUE_1836_replace_overflow_libcom - 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 */ //??sat + 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 */ //??sat #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 */ #endif diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 5dcdb761b..4a1c29f73 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -464,9 +464,9 @@ void dtx_ivas_fx( FOR( i = 1; i < L_FRAME / 16; i++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat + L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat #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++; } @@ -940,9 +940,9 @@ void dtx_fx( FOR( i = 1; i < L_FRAME / 16; i++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat + L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat #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++; } @@ -1422,9 +1422,9 @@ void dtx_hangover_control_fx( FOR( j = 0; j < m; j++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat + lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat #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 } @@ -1442,19 +1442,19 @@ void dtx_hangover_control_fx( FOR( j = 0; j < m; j++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat + lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat #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_1836_replace_overflow_libcom - lsp_est[i] = sub_sat( lsp_est[i], add_sat( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i] ) ); /*Q15 */ //??sat + lsp_est[i] = sub_sat( lsp_est[i], add_sat( tmp[max_idx[0] * M + i], tmp[max_idx[1] * M + i] ) ); /*Q15 */ //??sat #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 */ #endif - S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */ - lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */ + S_tmp = div_s( 1, sub( m, 2 ) ); /*Q15 */ + lsp_est[i] = mult_r( lsp_est[i], S_tmp ); /*Q15 */ } } @@ -1463,11 +1463,11 @@ void dtx_hangover_control_fx( FOR( i = 0; i < M; i++ ) { #ifdef ISSUE_1836_replace_overflow_libcom - Dlsp_n2e = add_sat( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ) ); /*Q15 */ //??sat + Dlsp_n2e = add_sat( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ) ); /*Q15 */ //??sat #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 */ } /* get deviation of CNG parameters between newly estimated and current state memory */ @@ -1480,9 +1480,9 @@ void dtx_hangover_control_fx( { S_tmp = abs_s( sub( hDtxEnc->lspCNG_fx[i], lsp_est[i] ) ); /*Q15 */ #ifdef ISSUE_1836_replace_overflow_libcom - Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */ //??sat + Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */ //??sat #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 ) ) { diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index be807cad0..c7fbdf61d 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -170,7 +170,7 @@ static void E_ACELP_2pulse_searchx_fx( sgnx = negate( sgnx ); } #ifdef ISSUE_1836_replace_overflow_libcom - 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 ) //??sat //??sat //??sat + 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 ) //??sat //??sat //??sat #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 ) #endif @@ -193,13 +193,13 @@ static void E_ACELP_2pulse_searchx_fx( /* dn[x] has only nb_pos_ix positions saved */ /*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/ 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_1836_replace_overflow_libcom 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 ) { @@ -214,24 +214,24 @@ static void E_ACELP_2pulse_searchx_fx( alp2_16 = 0; #ifdef ISSUE_1836_replace_overflow_libcom - alp2 = L_mac_sat( alp1, cor[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat + alp2 = L_mac_sat( alp1, cor[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat #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 ) { #ifdef ISSUE_1836_replace_overflow_libcom 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 ) { #ifdef ISSUE_1836_replace_overflow_libcom - alp2_16 = msu_r_sat( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat + alp2_16 = msu_r_sat( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat #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 */ @@ -245,7 +245,7 @@ static void E_ACELP_2pulse_searchx_fx( /*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/ #ifdef ISSUE_1836_replace_overflow_libcom - s = L_msu_sat( L_mult( alpk[ik], sq ), sqk[ik], alp2_16 ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ //??sat + s = L_msu_sat( L_mult( alpk[ik], sq ), sqk[ik], alp2_16 ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ //??sat #else s = L_msu_o( L_mult( alpk[ik], sq ), sqk[ik], alp2_16, &Overflow ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ #endif @@ -327,7 +327,7 @@ static void E_ACELP_1pulse_searchx_fx( ik = 0; move16(); #ifdef ISSUE_1836_replace_overflow_libcom - if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) //??sat + if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) //??sat #else if ( mac_ro( alp0, cor[tracks[0]], sign[tracks[0]], &Overflow ) < 0 ) #endif @@ -355,11 +355,11 @@ static void E_ACELP_1pulse_searchx_fx( /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(1);*/ assert( sign[x] == sign_val_1 << 1 || sign[x] == -( sign_val_1 << 1 ) ); #ifdef ISSUE_1836_replace_overflow_libcom - alp1 = mac_r_Sat( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat + alp1 = mac_r_Sat( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat #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(); @@ -370,7 +370,7 @@ static void E_ACELP_1pulse_searchx_fx( /*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/ #ifdef ISSUE_1836_replace_overflow_libcom - s = L_msu_sat( L_mult_sat( alpk[ik], sq ), sqk[ik], alp1 ); /* Q9+Qalp+1 */ //??sat + s = L_msu_sat( L_mult_sat( alpk[ik], sq ), sqk[ik], alp1 ); /* Q9+Qalp+1 */ //??sat #else s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */ #endif -- GitLab From ae2e3d95946d10784489b173d0d49710314dd7e4 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 06:56:10 +0200 Subject: [PATCH 14/80] corrected wrong macro - some more fixes --- lib_enc/cod_tcx_fx.c | 8 ++++---- lib_enc/core_enc_ol_fx.c | 18 +++++++++--------- lib_enc/corr_xh_fx.c | 20 ++++++++++---------- lib_enc/detect_transient_fx.c | 28 ++++++++++++++-------------- lib_enc/dtx_fx.c | 20 ++++++++++---------- lib_enc/enc_acelpx_fx.c | 24 ++++++++++++------------ 6 files changed, 59 insertions(+), 59 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 0eb425087..318d03795 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1657,7 +1657,7 @@ void QuantizeSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat #else hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); @@ -3256,7 +3256,7 @@ void QuantizeTCXSpectrum_fx( tmp1 = BASOP_Util_Divide1616_Scale( sqTargetBits, tmp1, &tmp2 ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc hTcxEnc->tcx_target_bits_fac = shl_sat( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2 ); //??sat #else hTcxEnc->tcx_target_bits_fac = shl_o( mult( hTcxEnc->tcx_target_bits_fac, tmp1 ), tmp2, &Overflow ); @@ -4023,7 +4023,7 @@ void InternalTCXDecoder_fx( Word16 Aq_old_fx[M + 1]; Word32 sns_interpolated_scalefactors_fx[FDNS_NPTS], A_fx32[M + 1]; Word16 *xn_buf16 = (Word16 *) xn_buf32; -#if !defined( ISSUE_1836_replace_overflow_libcom ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -4677,7 +4677,7 @@ void InternalTCXDecoder_fx( BASOP_SATURATE_WARNING_OFF_EVS; FOR( i = 0; i < L_frame; i++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc xn_buf16[i] = shl_sat( xn_buf16[i], TCX_IMDCT_HEADROOM ); //??sat #else xn_buf16[i] = shl_o( xn_buf16[i], TCX_IMDCT_HEADROOM, &Overflow ); diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index e8ca475af..69178b693 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -82,7 +82,7 @@ void core_encode_openloop_fx( Word16 lsp_old_q_rf[M + 1], lsf_old_q_rf[M + 1]; (void) vad_hover_flag; (void) vad_flag_dtx; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -555,7 +555,7 @@ void core_encode_openloop_fx( /*v_sub(lsf_uq_rf, lsf_q_1st_rf, lsf_q_d_rf, M);*/ FOR( i = 0; i < M; i++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#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 ); //??sat #else lsf_q_d_rf[i] = shl_o( mult_r( sub_o( lsf_uq_rf[i], lsf_q_1st_rf[i], &Overflow ), 25600 ), 5, &Overflow ); @@ -760,7 +760,7 @@ static void closest_centroid_rf( Word16 tmp, tmpL; Word64 werr_64; Word32 L_tmp, best_werr, werr; -#ifdef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -780,7 +780,7 @@ static void closest_centroid_rf( tmpL = i_mult2( i, length ); FOR( j = 0; j < length; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc tmp = sub_sat( data[j], quantizer[tmpL + j] ); //??sat L_tmp = L_mult_sat( tmp, tmp ); //??sat #else @@ -838,7 +838,7 @@ void core_acelp_tcx20_switching_fx( Word16 snr_tcx, snr_acelp, dsnr; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -1119,7 +1119,7 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc tmp32 = L_mac0_sat( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat #else tmp32 = L_mac0_o( tmp32, st->wspeech_enc[i + j], st->wspeech_enc[i + j], &Overflow ); @@ -1141,7 +1141,7 @@ void core_acelp_tcx20_switching_fx( tcx_snr = L_shl( Mpy_32_16_1( tcx_snr, 0x6054 ), 2 ); /* 0x6054 -> 10/log2(10) (2Q13) */ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */ //??sat //??sat #else snr_tcx = round_fx_o( L_shl_o( tcx_snr, 8, &Overflow ), &Overflow ); /* 7Q8 */ @@ -1179,7 +1179,7 @@ void core_acelp_tcx20_switching_fx( FOR( j = 0; j < L_SUBFR; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc signal = L_mac0_sat( signal, st->wspeech_enc[i + j], st->wspeech_enc[i + j] ); //??sat tmp16 = round_fx_sat( L_shl_sat( Mpy_32_16_r( gain, st->wspeech_enc[i + j - T0] ), 15 ) ); //??sat @@ -1244,7 +1244,7 @@ void core_acelp_tcx20_switching_fx( test(); if ( ( GT_16( snr_acelp, snr_tcx ) ) && ( LT_16( snr_acelp, add( snr_tcx, 512 /*2.0f Q8*/ ) ) ) && -#ifdef ISSUE_1836_replace_overflow_libcom +#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*/ ) || //??sat #else ( LT_16( add_o( st->prevTempFlatness_fx, currFlatness, &Overflow ), 416 /*3.25f Q7*/ ) || EQ_16( stab_fac, 0x7fff /*1 Q15*/ ) || diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index ae084666c..c81a57d2c 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -31,7 +31,7 @@ void corr_xh_fx( { Word16 i, j, k; Word32 L_tmp, y32[L_SUBFR], L_maxloc, L_tot; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -49,8 +49,8 @@ void corr_xh_fx( L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/ FOR( j = i; j < L_SUBFR - 1; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom - L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, x[j + 1], h[j + 1 - i] ); /*Qx+15*/ //??sat #else L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ #endif @@ -63,7 +63,7 @@ void corr_xh_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat #else @@ -93,7 +93,7 @@ void corr_hh_ivas_fx( { Word16 i, j, k; Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -111,7 +111,7 @@ 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 FOR( j = i; j < L_subfr - 1; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#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 @@ -125,7 +125,7 @@ void corr_hh_ivas_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat #else @@ -161,7 +161,7 @@ void corr_xh_ivas_fx( { Word16 i, j, k; Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -179,7 +179,7 @@ void corr_xh_ivas_fx( L_tmp = L_mac( 0, x[i], h[0] ); // Qx+(14 - norm_s(h[0])) + 1 FOR( j = i; j < L_subfr - 1; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#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 //??sat #else L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); // Qx+(14 - norm_s(h[0])) + 1 @@ -193,7 +193,7 @@ void corr_xh_ivas_fx( } /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat #else diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 86d39ec0c..ee3aebf10 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -62,7 +62,7 @@ static void hp_filter_fx( { Word16 i; Word32 L_tmp; -#ifdef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -71,7 +71,7 @@ static void hp_filter_fx( /*y[0] = 0.4931f * *oldy + 0.7466f*(x[0] - *oldx); */ -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mult( sub_sat( x[0], *oldx ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ //??sat #else L_tmp = L_mult( sub_o( x[0], *oldx, &Overflow ), 24465 /*0.7466f in Q15*/ ); /*Q_new+16 */ @@ -81,7 +81,7 @@ static void hp_filter_fx( FOR( i = 1; i < L; i++ ) { /*y[i] = 0.4931f*y[i-1] + 0.7466f*(x[i] - x[i-1]); */ -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ //??sat L_tmp = L_mac_sat( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ //??sat y[i] = round_fx_sat( L_tmp ); /*Q_new */ //??sat @@ -129,7 +129,7 @@ Word16 detect_transient_fx( Word32 E_low_fx, E_high_fx; Word16 temp16, Thres_fx = 0; Word16 exp; -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -165,7 +165,7 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 4; i++ ) { /*EnergyLT += out_filt[i] * out_filt[i]; */ -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc EnergyLT = L_mac0_sat( EnergyLT, out_filt_fx[i], out_filt_fx[i] ); /*2Q_new */ //??sat #else EnergyLT = L_mac0_o( EnergyLT, out_filt_fx[i], out_filt_fx[i], &Overflow ); /*2Q_new */ @@ -188,13 +188,13 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 4; i++ ) { temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); //??sat #else Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow ); #endif temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc Energy_in_fx[blk + 1] = L_add_sat( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); /*Q0*/ //??sat #else Energy_in_fx[blk + 1] = L_add_o( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ), &Overflow ); /*Q0*/ @@ -202,7 +202,7 @@ Word16 detect_transient_fx( move32(); } -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/ //??sat E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/ //??sat #else @@ -232,7 +232,7 @@ Word16 detect_transient_fx( FOR( i = 0; i < L / 8; i++ ) { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ //??sat #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 */ @@ -242,10 +242,10 @@ Word16 detect_transient_fx( FOR( ; i < L / 4; i++ ) { /*Energy += out_filt_fx[i + blk*(L/4)] * out_filt_fx[i + blk*(L/4)]; */ -#ifdef ISSUE_1836_replace_overflow_libcom - L_tmp2 = L_mac0_sat( L_tmp2D, out_filt_fx[i + blk * ( L / 4 )], out_filt_fx[i + blk * ( L / 4 )] ); /*2Q_new */ //??sat +#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 */ //??sat #else - L_tmp2 = L_mac0_o( L_tmp2D, 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; @@ -257,7 +257,7 @@ Word16 detect_transient_fx( shift = 1; move16(); } -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc Overflow = 0; move16(); @@ -305,7 +305,7 @@ Word16 detect_transient_fx( } /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*0.75f*EnergyLT in Q0 //0.25f*Energy in Q0 */ -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ //??sat #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 */ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 4a1c29f73..07c2c78bd 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -74,7 +74,7 @@ void dtx_ivas_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -463,7 +463,7 @@ void dtx_ivas_fx( speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat #else L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ @@ -637,7 +637,7 @@ void dtx_fx( TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; Word16 last_br_cng_flag, last_br_flag, br_dtx_flag; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -939,7 +939,7 @@ void dtx_fx( speech++; FOR( i = 1; i < L_FRAME / 16; i++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac0_sat( L_tmp, *speech, *speech ); /*2*Q_speech*/ //??sat #else L_tmp = L_mac0_o( L_tmp, *speech, *speech, &Overflow ); /*2*Q_speech*/ @@ -1248,7 +1248,7 @@ void dtx_hangover_control_fx( VAD_HANDLE hVAD = st_fx->hVAD; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif @@ -1421,7 +1421,7 @@ void dtx_hangover_control_fx( move16(); FOR( j = 0; j < m; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat #else lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ @@ -1441,14 +1441,14 @@ void dtx_hangover_control_fx( move16(); FOR( j = 0; j < m; j++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc lsp_est[i] = add_sat( lsp_est[i], tmp[j * M + i] ); /*Q15 */ //??sat #else lsp_est[i] = add_o( lsp_est[i], tmp[j * M + i], &Overflow ); /*Q15 */ #endif } -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ //??sat #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 */ @@ -1462,7 +1462,7 @@ void dtx_hangover_control_fx( move16(); FOR( i = 0; i < M; i++ ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc Dlsp_n2e = add_sat( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ) ); /*Q15 */ //??sat #else Dlsp_n2e = add_o( Dlsp_n2e, abs_s( sub( lsp_new_fx[i], lsp_est[i] ) ), &Overflow ); /*Q15 */ @@ -1479,7 +1479,7 @@ void dtx_hangover_control_fx( FOR( i = 0; i < M; i++ ) { S_tmp = abs_s( sub( hDtxEnc->lspCNG_fx[i], lsp_est[i] ) ); /*Q15 */ -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */ //??sat #else Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index c7fbdf61d..d72aaa5d0 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -139,7 +139,7 @@ static void E_ACELP_2pulse_searchx_fx( Word32 alp0, alp1, alp2, s; Word16 *pR, sgnx; Word16 sqk[2], alpk[2], ik; -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -169,7 +169,7 @@ static void E_ACELP_2pulse_searchx_fx( { sgnx = negate( sgnx ); } -#ifdef ISSUE_1836_replace_overflow_libcom +#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 ) //??sat //??sat //??sat #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 ) @@ -194,7 +194,7 @@ static void E_ACELP_2pulse_searchx_fx( /*ps1 = ps0 + dn[x]; INDIRECT(1);ADD(1);*/ ps1 = add_sat( ps0, dn[x] ); /*Qdn*/ /*alp1 = alp0 + 2*sgnx*cor[x]; INDIRECT(1);MULT(1); MAC(1);*/ -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ @@ -213,14 +213,14 @@ static void E_ACELP_2pulse_searchx_fx( assert( sgnx != 0 ); alp2_16 = 0; -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc alp2 = L_mac_sat( alp1, cor[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat #else alp2 = L_mac_o( alp1, cor[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ #endif if ( sgnx > 0 ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ @@ -228,7 +228,7 @@ static void E_ACELP_2pulse_searchx_fx( } if ( sgnx < 0 ) { -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc alp2_16 = msu_r_sat( alp2, pR[y], sign[y] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat #else alp2_16 = msu_ro( alp2, pR[y], sign[y], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ @@ -244,7 +244,7 @@ static void E_ACELP_2pulse_searchx_fx( /*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/ -#ifdef ISSUE_1836_replace_overflow_libcom +#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 */ //??sat #else s = L_msu_o( L_mult( alpk[ik], sq ), sqk[ik], alp2_16, &Overflow ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ @@ -306,7 +306,7 @@ static void E_ACELP_1pulse_searchx_fx( Word16 ntracks, t; Word16 sqk[2], alpk[2], ik; move16(); -#ifndef ISSUE_1836_replace_overflow_libcom +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -326,7 +326,7 @@ static void E_ACELP_1pulse_searchx_fx( sqk[0] = -1; ik = 0; move16(); -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) //??sat #else if ( mac_ro( alp0, cor[tracks[0]], sign[tracks[0]], &Overflow ) < 0 ) @@ -354,8 +354,8 @@ static void E_ACELP_1pulse_searchx_fx( ps1 = add( ps0, dn[x] ); /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(1);*/ assert( sign[x] == sign_val_1 << 1 || sign[x] == -( sign_val_1 << 1 ) ); -#ifdef ISSUE_1836_replace_overflow_libcom - alp1 = mac_r_Sat( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat +#ifdef ISSUE_1867_replace_overflow_libenc + alp1 = mac_r_sat( alp0, cor[x], sign[x] ); /* Qalp = (Q_R=Q_cor)*Q_signval */ //??sat #else alp1 = mac_ro( alp0, cor[x], sign[x], &Overflow ); /* Qalp = (Q_R=Q_cor)*Q_signval */ #endif @@ -369,7 +369,7 @@ static void E_ACELP_1pulse_searchx_fx( move16(); /*s = (alpk[ik] * sq) - (sqk[ik] * alp1); MULT(1);MAC(1);*/ -#ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1867_replace_overflow_libenc s = L_msu_sat( L_mult_sat( alpk[ik], sq ), sqk[ik], alp1 ); /* Q9+Qalp+1 */ //??sat #else s = L_msu_o( L_mult_o( alpk[ik], sq, &Overflow ), sqk[ik], alp1, &Overflow ); /* Q9+Qalp+1 */ -- GitLab From 2f6b40945ab96ec26be986e6bb1a1f451a7ef080 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 07:00:08 +0200 Subject: [PATCH 15/80] clang patch --- lib_enc/corr_xh_fx.c | 2 +- lib_enc/detect_transient_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index c81a57d2c..062707247 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -50,7 +50,7 @@ void corr_xh_fx( 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*/ //??sat + L_tmp = L_mac_sat( L_tmp, x[j + 1], h[j + 1 - i] ); /*Qx+15*/ //??sat #else L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/ #endif diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index ee3aebf10..3a6ba1dcc 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -245,7 +245,7 @@ Word16 detect_transient_fx( #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 */ //??sat #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; -- GitLab From a93d57a6e2c40b31e81e20af7cc4ec18dda2f6e7 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 07:42:41 +0200 Subject: [PATCH 16/80] fix --- lib_enc/core_enc_ol_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 69178b693..21557af59 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -838,7 +838,7 @@ void core_acelp_tcx20_switching_fx( Word16 snr_tcx, snr_acelp, dsnr; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -- GitLab From 02e4cf99b9d11e9f820c8c7c8d1f4ec9947bfb2c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 09:56:21 +0200 Subject: [PATCH 17/80] some more overflow op replacements --- lib_enc/enc_acelp_fx.c | 137 +++++++++++++++++++++++++++++++++- lib_enc/enc_amr_wb_fx.c | 16 ++++ lib_enc/enc_gen_voic_fx.c | 62 +++++++++++++++ lib_enc/enc_gen_voic_rf_fx.c | 24 ++++++ lib_enc/enc_higher_acelp_fx.c | 24 +++++- lib_enc/enc_pit_exc_fx.c | 48 +++++++++++- lib_enc/enc_tran_fx.c | 47 +++++++++++- 7 files changed, 347 insertions(+), 11 deletions(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index f6a8e65b2..889d9da23 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -58,9 +58,11 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac Word16 *dn2; Word16 *p0, *p1, *p2; Word32 L_sum; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif 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 p2 = &vec[dn]; /*Qx*/ 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*/ //??sat +#else 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*/ //??sat +#else corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ +#endif /*cor[dn >> 2] = sign[dn] * s + p0[dn >> 2];*/ j = shr( dn, 2 ); if ( sign[dn] > 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + corr = add_sat( p0[j], corr ); /*Q9*/ //??sat +#else corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ +#endif } if ( sign[dn] < 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + corr = sub_sat( p0[j], corr ); /*Q9*/ //??sat +#else corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ +#endif } cor[j] = corr; /*Q9*/ @@ -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 *p0, *p1, *p2; Word32 L_sum; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif p0 = rrixix[track]; /*Q9*/ @@ -118,12 +138,30 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac p2 = &vec[pos]; /*Qx*/ 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 */ //??sat +#else 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*/ //??sat +#else corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ +#endif /*cor[i] = s * sign[track] + p0[i];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + if ( sign[pos] > 0 ) + { + corr = add_sat( *p0++, corr ); /*Q9*/ //??sat + } + if ( sign[pos] < 0 ) + { + corr = sub_sat( *p0++, corr ); /*Q9*/ //??sat + } +#else if ( sign[pos] > 0 ) { 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 { corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/ } +#endif cor[i] = corr; /*Q9*/ move16(); @@ -174,10 +213,12 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* Word32 xy_save; Word16 check = 0; /* debug code not instrumented */ +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /* 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* sqk[0] = -1; move16(); 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 ) //??sat //??sat //??sat +#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 ) +#endif { sqk[0] = 1; move16(); @@ -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*/ /*alp1 = alp0 + cor_x[x2];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ //??sat +#else alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/ +#endif p1 = cor_y; /*Qx*/ 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* move16(); /*alp2 = alp1 + (*p1++) + (*p2++);*/ +#ifdef ISSUE_1867_replace_overflow_libenc + alp2 = L_mac_sat( alp1, *p1++, _1_ ); /*Qx+12+1*/ //??sat + alp2_16 = mac_r_sat( alp2, *p2++, _1_ ); /*Q6*/ //??sat +#else alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/ alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ +#endif alpk[1 - ik] = alp2_16; /*Q6*/ move16(); @@ -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 xy, yy, exp_xy, exp_yy, gain; Word32 L_off; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif 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' */ /* Compute scalar product t1: */ +#ifdef ISSUE_1867_replace_overflow_libenc + yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/ //??sat +#else yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow ); /*Q15 - exp_yy*/ +#endif /* Compute scalar product t0: */ +#ifdef ISSUE_1867_replace_overflow_libenc + xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/ //??sat +#else 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 */ Q_xn = shl( sub( 15, exp_xn ), 1 ); g_corr->y1y1 = yy; @@ -563,8 +627,8 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn i = add( exp_xy, 1 - 1 ); /* -1 -> gain in Q14 */ i = sub( i, exp_yy ); BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1796_replace_shl_o - gain = shl_sat( gain, i ); /* saturation can occur here */ +#ifdef ISSUE_1867_replace_overflow_libenc + gain = shl_sat( gain, i ); /* saturation can occur here */ //??sat #else gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ #endif @@ -581,7 +645,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn Word16 tmp, exp_tmp, exp_div; /* Compute scalar product */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/ //??sat +#else tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/ +#endif /* gain_p_snr = sqrt(/) */ tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div ); exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div ); @@ -591,7 +659,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Note: shl works as shl or shr. */ exp_tmp = sub( exp_tmp, 1 ); 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*/ //??sat //??sat +#else 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 gain = s_min( gain, tmp ); /*Q14*/ @@ -688,9 +760,11 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, { Word16 i, Q15_flag; Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif assert( gain >= 0 ); @@ -708,9 +782,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*/ if ( Q15_flag == 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/ //??sat +#else 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*/ //??sat +#else x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/ +#endif move16(); } } @@ -744,10 +826,12 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 Word16 signs[3]; Word16 *ptr16; Word16 val, index; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /* calculate energy for normalization of cn[] and dn[] */ @@ -756,7 +840,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ //??sat +#else Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/ +#endif Lcor = L_mac0( Lcor, dn[i], dn[i] ); /*2*Qdn*/ } @@ -773,8 +861,13 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 if ( i > 0 ) Lcor = L_shr( Lcor, i ); +#ifdef ISSUE_1867_replace_overflow_libenc + k_dn = round_fx_sat( Lval ); /*Q15 - e_dn*/ //??sat + k_cn = round_fx_sat( Lcor ); /*Q15 - e_cn*/ //??sat +#else k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/ k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ +#endif k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */ k_dn = mult_r( alp, k_dn ); /* alp in Q13 */ @@ -794,7 +887,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);*/ 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*/ +#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*/ //??sat //??sat +#else 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 ); sign[i] = ptr16[index]; /*Q15*/ @@ -1090,10 +1187,12 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word32 s, L_tmp; Word16 nb_pulse, nb_pulse_m2; Word16 check = 0; /* debug code not instrumented */ +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */ @@ -1132,7 +1231,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const BASOP_SATURATE_WARNING_OFF_EVS 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*/ //??sat +#else L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/ +#endif } val = extract_h( L_tmp ); /*Q9*/ BASOP_SATURATE_WARNING_ON_EVS @@ -1277,7 +1380,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*/ 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*/ //??sat +#else 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*/ @@ -1334,7 +1441,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const FOR( i = 0; i < L_SUBFR; i++ ) { 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. */ +#endif move16(); } } @@ -1384,7 +1495,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const } FOR( i = 0; i < L_SUBFR; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat +#else y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ +#endif move16(); } } @@ -1410,10 +1525,12 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, Word32 s, L_tmp; Word16 nb_pulse, nb_pulse_m2; Word16 check = 0; /* debug code not instrumented */ +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */ @@ -1452,7 +1569,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, BASOP_SATURATE_WARNING_OFF_EVS 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*/ //??sat +#else L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/ +#endif } val = extract_h( L_tmp ); /*Q9*/ BASOP_SATURATE_WARNING_ON_EVS @@ -1602,7 +1723,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/ 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*/ //??sat +#else 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*/ @@ -1659,7 +1784,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, FOR( i = 0; i < L_SUBFR; i++ ) { tmp = add( *p0++, *p1++ ); +#ifdef ISSUE_1867_replace_overflow_libenc + vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */ //??sat +#else vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */ +#endif move16(); } } @@ -1709,7 +1838,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, } FOR( i = 0; i < L_SUBFR; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat +#else y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ +#endif move16(); } } diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 4c5268017..0af2bef74 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -64,9 +64,11 @@ void encod_amr_wb_fx( AMRWB_IO_ENC_HANDLE hAmrwb_IO = st->hAmrwb_IO; BSTR_ENC_HANDLE hBstr = st->hBstr; LPD_state_HANDLE hLPDmem = st->hLPDmem; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*------------------------------------------------------------------* @@ -187,14 +189,23 @@ void encod_amr_wb_fx( &gain_inov, &norm_gain_code, g_corr, clip_gain, hAmrwb_IO->past_qua_en_fx ); gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat +#else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ +#endif hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift ); /*Q15*/ FOR( i = 0; i < L_SUBFR; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ //??sat //??sat +#else exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/ +#endif move16(); } @@ -219,8 +230,13 @@ void encod_amr_wb_fx( L_tmp = L_mult( gcode16, code[i] ); /*Q10*/ L_tmp = L_shl_sat( L_tmp, 5 ); /*Q15*/ L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ //??sat + exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ //??sat +#else L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ +#endif move16(); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 4595dc206..d09c3f71e 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -134,9 +134,11 @@ void encod_gen_voic_fx( Word16 shift_wsp; Word16 harm_flag_acelp; Word16 lp_select, lp_flag, L_frame; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -266,7 +268,11 @@ void encod_gen_voic_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ +#ifdef ISSUE_1867_replace_overflow_libenc + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat +#else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ +#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames @@ -317,8 +323,13 @@ void encod_gen_voic_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat +#else Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ +#endif hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ move16(); @@ -354,20 +365,35 @@ void encod_gen_voic_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* Contribution from AVQ layer */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ //??sat + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ //??sat +#else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/ Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ +#endif /* Compute exc2 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ //??sat + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat +#else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */ exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ +#endif move16(); /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat +#else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ +#endif } } ELSE @@ -380,10 +406,17 @@ void encod_gen_voic_fx( { /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ //??sat + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ //??sat +#else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */ +#endif } } @@ -492,9 +525,11 @@ void encod_gen_voic_ivas_fx( Word16 harm_flag_acelp; Word16 lp_select, lp_flag, L_frame; Word16 q_h1; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -684,8 +719,13 @@ void encod_gen_voic_ivas_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); //??sat +#else Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); +#endif hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */ move16(); @@ -737,20 +777,35 @@ void encod_gen_voic_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* Contribution from AVQ layer */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); //??sat + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); //??sat +#else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); +#endif /* Compute exc2 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); //??sat + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat +#else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); +#endif move16(); /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat +#else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); +#endif move16(); } } @@ -765,10 +820,17 @@ void encod_gen_voic_ivas_fx( /* code in Q9, gain_pit in Q14 */ /*gcode16 in Qnew*/ Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ //??sat + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); //??sat +#else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); +#endif } } /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 0e79baa5f..931a641d9 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -165,9 +165,11 @@ void coder_acelp_rf_fx( Word16 prev_gain_pit; Word16 rf_coder_type; Word16 lp_select; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif RF_ENC_HANDLE hRF = st->hRF; @@ -441,6 +443,15 @@ void coder_acelp_rf_fx( *-----------------------------------------------------------------*/ /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat + Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ //??sat + /* Add Gaussian contribution*/ + Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ //??sat + hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ //??sat //??sat //??sat +#else Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */ /* Add Gaussian contribution*/ @@ -448,6 +459,7 @@ void coder_acelp_rf_fx( Ltmp2 = L_shl_o( Ltmp2, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_xn */ hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */ +#endif move16(); hRF->rf_mem_w0 = shr_sat( hRF->rf_mem_w0, shift ); /*Qnew-1*/ @@ -463,6 +475,17 @@ void coder_acelp_rf_fx( { /* code in Q9, gain_pit in Q14; exc Q_new */ Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ //??sat + exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ //??sat //??sat + move16(); + Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ //??sat + exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat +#else Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */ exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ); /* Q_new */ @@ -472,6 +495,7 @@ void coder_acelp_rf_fx( Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_new */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new*/ exc_rf[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */ +#endif move16(); } tmp2 = L_SUBFR; diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 00b18f79d..443937dae 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -85,7 +85,11 @@ void transf_cdbk_enc_fx( *--------------------------------------------------------------*/ IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat +#else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); +#endif FOR( i = 0; i < L_SUBFR; i++ ) { /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/ @@ -180,7 +184,11 @@ void transf_cdbk_enc_fx( m_corr = div_s( 16384, m_den ); e_corr = sub( 14 + 4, e_den ); Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ +#ifdef ISSUE_1867_replace_overflow_libenc + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat +#else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ +#endif } ELSE { @@ -287,8 +295,8 @@ void transf_cdbk_enc_fx( FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); +#ifdef ISSUE_1867_replace_overflow_libenc + x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); //??sat #else x_tran[i] = shl_o( x_norm[i], Q_AVQ_OUT_DEC, &Overflow ); #endif @@ -439,7 +447,11 @@ void transf_cdbk_enc_ivas_fx( *--------------------------------------------------------------*/ IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat +#else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); +#endif FOR( i = 0; i < L_SUBFR; i++ ) { /*x_tran[i] = xn[i] - *gain_pit * y1[i] - gain_code * y2[i];*/ @@ -533,7 +545,11 @@ void transf_cdbk_enc_ivas_fx( m_corr = div_s( 16384, m_den ); e_corr = sub( 14 + 4, e_den ); Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ +#ifdef ISSUE_1867_replace_overflow_libenc + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat +#else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ +#endif } ELSE { @@ -643,8 +659,8 @@ void transf_cdbk_enc_ivas_fx( FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); +#ifdef ISSUE_1867_replace_overflow_libenc + x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); //??sat #else x_tran[i] = shl_o( x_norm[i], Q_AVQ_OUT_DEC, &Overflow ); #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 5f173cd7f..3a5a4f0d3 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -102,9 +102,11 @@ void enc_pit_exc_fx( BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*------------------------------------------------------------------* @@ -290,7 +292,11 @@ void enc_pit_exc_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ +#ifdef ISSUE_1867_replace_overflow_libenc + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat +#else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ +#endif gpit_tmp = gain_pit; move16(); /*Q14*/ @@ -364,12 +370,21 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ //??sat + Ltmp = L_negate( Ltmp ); + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ //??sat + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit );/* Q_new + Q15 + shift */ //??sat + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ //??sat + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat +#else Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); /* Q_new + Q15 + shift */ Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); /* Q_new + Q15 + shift */ Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); /* Q_new + 15 */ hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ +#endif move16(); } ELSE @@ -391,10 +406,17 @@ void enc_pit_exc_fx( { /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ //??sat + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat +#else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q_new + Q16*/ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */ +#endif move16(); } } @@ -517,8 +539,8 @@ void enc_pit_exc_fx( } } -#ifdef ISSUE_1796_replace_shl_o - cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ +#ifdef ISSUE_1867_replace_overflow_libenc + cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ //??sat #else cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ #endif @@ -581,9 +603,11 @@ void enc_pit_exc_ivas_fx( BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*------------------------------------------------------------------* @@ -841,12 +865,21 @@ void enc_pit_exc_ivas_fx( IF( use_fcb != 0 ) { Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); // Q_new+14+shift //??sat + Ltmp = L_negate( Ltmp ); + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift //??sat + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift //??sat + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 //??sat + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat +#else Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); // Q_new+15 hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ +#endif } ELSE { @@ -866,10 +899,17 @@ void enc_pit_exc_ivas_fx( { /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat +#else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); /* Q_new */ +#endif move16(); } } @@ -993,10 +1033,10 @@ void enc_pit_exc_ivas_fx( } } -#ifdef ISSUE_1796_replace_shl_o +#ifdef ISSUE_1867_replace_overflow_libenc cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ #else - cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ + cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ //??sat #endif *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index fb601aeba..162c611cb 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -93,9 +93,11 @@ Word16 encod_tran_fx( Word16 L_frame_fx; Word16 shift_wsp; Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; @@ -228,8 +230,13 @@ Word16 encod_tran_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); //??sat +#else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); +#endif hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ /*-----------------------------------------------------------------* * Update memory of the weighting filter @@ -278,10 +285,17 @@ Word16 encod_tran_fx( { /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat +#else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */ exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /* Q_new */ +#endif } /*-----------------------------------------------------------------* @@ -294,13 +308,21 @@ Word16 encod_tran_fx( FOR( i = 0; i < L_SUBFR; i++ ) { L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat + tmp_fx = round_fx_sat( L_tmp ); //??sat + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + move16(); + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + move16(); +#else L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); - exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ move16(); exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ move16(); +#endif } } @@ -467,9 +489,11 @@ Word16 encod_tran_ivas_fx( Word16 shift_wsp; Word32 L_tmp; Word16 q_h1; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif BSTR_ENC_HANDLE hBstr = st_fx->hBstr; SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; @@ -610,8 +634,13 @@ Word16 encod_tran_ivas_fx( } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); //??sat +#else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); +#endif hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 /*-----------------------------------------------------------------* * Update memory of the weighting filter @@ -660,10 +689,17 @@ Word16 encod_tran_ivas_fx( { /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat +#else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q16 + Q_new */ exc_fx[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /* Q_new */ +#endif } /*-----------------------------------------------------------------* @@ -676,12 +712,21 @@ Word16 encod_tran_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat + tmp_fx = round_fx_sat( L_tmp ); //??sat + + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + move16(); + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat +#else L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ move16(); exc_fx[i + i_subfr] = add_o( exc_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ +#endif move16(); } } -- GitLab From 93ee2314ca7e4ce3e4375ba081b1961c05ceb461 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 10:26:51 +0200 Subject: [PATCH 18/80] clang patch --- lib_enc/enc_acelp_fx.c | 118 +++++++++++++++++----------------- lib_enc/enc_amr_wb_fx.c | 18 +++--- lib_enc/enc_gen_voic_fx.c | 92 +++++++++++++------------- lib_enc/enc_gen_voic_rf_fx.c | 38 +++++------ lib_enc/enc_higher_acelp_fx.c | 16 ++--- lib_enc/enc_pit_exc_fx.c | 68 ++++++++++---------- lib_enc/enc_tran_fx.c | 52 +++++++-------- 7 files changed, 201 insertions(+), 201 deletions(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 889d9da23..83ac5a2e4 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -78,16 +78,16 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac 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*/ //??sat + L_sum = L_mac_sat( L_sum, *p1++, *p2++ ); /*2*Qx+1*/ //??sat #else 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*/ //??sat + corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ //??sat #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];*/ @@ -95,17 +95,17 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac if ( sign[dn] > 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = add_sat( p0[j], corr ); /*Q9*/ //??sat + corr = add_sat( p0[j], corr ); /*Q9*/ //??sat #else - corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ + corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ #endif } if ( sign[dn] < 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = sub_sat( p0[j], corr ); /*Q9*/ //??sat + corr = sub_sat( p0[j], corr ); /*Q9*/ //??sat #else - corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ + corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ #endif } @@ -139,15 +139,15 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac 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 */ //??sat + L_sum = L_mac_sat( L_sum, *p1++, *p2++ ); /* 2*Qx+1 */ //??sat #else 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*/ //??sat + corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ //??sat #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];*/ @@ -155,11 +155,11 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac #ifdef ISSUE_1867_replace_overflow_libenc if ( sign[pos] > 0 ) { - corr = add_sat( *p0++, corr ); /*Q9*/ //??sat + corr = add_sat( *p0++, corr ); /*Q9*/ //??sat } if ( sign[pos] < 0 ) { - corr = sub_sat( *p0++, corr ); /*Q9*/ //??sat + corr = sub_sat( *p0++, corr ); /*Q9*/ //??sat } #else if ( sign[pos] > 0 ) @@ -237,7 +237,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* move16(); 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 ) //??sat //??sat //??sat + 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 ) //??sat //??sat //??sat #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 ) #endif @@ -261,9 +261,9 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* /*alp1 = alp0 + cor_x[x2];*/ #ifdef ISSUE_1867_replace_overflow_libenc - alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ //??sat + alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ //??sat #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*/ @@ -277,13 +277,13 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* /*alp2 = alp1 + (*p1++) + (*p2++);*/ #ifdef ISSUE_1867_replace_overflow_libenc - alp2 = L_mac_sat( alp1, *p1++, _1_ ); /*Qx+12+1*/ //??sat - alp2_16 = mac_r_sat( alp2, *p2++, _1_ ); /*Q6*/ //??sat + alp2 = L_mac_sat( alp1, *p1++, _1_ ); /*Qx+12+1*/ //??sat + alp2_16 = mac_r_sat( alp2, *p2++, _1_ ); /*Q6*/ //??sat #else - alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/ - alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ + alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow ); /*Qx+12+1*/ + alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ #endif - alpk[1 - ik] = alp2_16; /*Q6*/ + alpk[1 - ik] = alp2_16; /*Q6*/ move16(); /*sq = ps2 * ps2;*/ @@ -589,16 +589,16 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Compute scalar product t1: */ #ifdef ISSUE_1867_replace_overflow_libenc - yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/ //??sat + yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/ //??sat #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: */ #ifdef ISSUE_1867_replace_overflow_libenc - xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/ //??sat + xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/ //??sat #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 */ Q_xn = shl( sub( 15, exp_xn ), 1 ); @@ -628,9 +628,9 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn i = sub( i, exp_yy ); BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - gain = shl_sat( gain, i ); /* saturation can occur here */ //??sat + gain = shl_sat( gain, i ); /* saturation can occur here */ //??sat #else - gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ + gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */ #endif BASOP_SATURATE_WARNING_ON_EVS /* gain = s_max(0, gain); */ /* see above xy < 0. */ @@ -646,9 +646,9 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Compute scalar product */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/ //??sat + tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/ //??sat #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(/) */ tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div ); @@ -660,7 +660,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn exp_tmp = sub( exp_tmp, 1 ); 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*/ //??sat //??sat + tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) ); /*Q14*/ //??sat //??sat #else tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/ #endif @@ -783,15 +783,15 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, if ( Q15_flag == 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/ //??sat + L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/ //??sat #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*/ //??sat + x2[i] = msu_r_sat( L_tmp, y[i], gain ); /*Q_xn*/ //??sat #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(); } @@ -841,11 +841,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ //??sat + Lval = L_mac0_sat( Lval, cn[i], cn[i] ); /*2*Q_xn*/ //??sat #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*/ } e_dn = 31; @@ -862,11 +862,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 Lcor = L_shr( Lcor, i ); #ifdef ISSUE_1867_replace_overflow_libenc - k_dn = round_fx_sat( Lval ); /*Q15 - e_dn*/ //??sat - k_cn = round_fx_sat( Lcor ); /*Q15 - e_cn*/ //??sat + k_dn = round_fx_sat( Lval ); /*Q15 - e_dn*/ //??sat + k_cn = round_fx_sat( Lcor ); /*Q15 - e_cn*/ //??sat #else - k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/ - k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ + k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/ + k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ #endif k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */ @@ -885,12 +885,12 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 FOR( i = 0; i < L_subfr; i++ ) { /*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_mac( Lcor, dn[i], k_dn ); /*Qdn + Q15 - e_dn + 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*/ #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*/ //??sat //??sat + val = round_fx_sat( L_shl_sat( Lcor, 4 ) ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/ //??sat //??sat #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 ); @@ -1232,9 +1232,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const 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*/ //??sat + L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/ //??sat #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*/ @@ -1381,9 +1381,9 @@ 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*/ 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*/ //??sat + L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/ //??sat #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*/ @@ -1444,7 +1444,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #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(); } @@ -1496,9 +1496,9 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat + y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat #else - y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ + y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif move16(); } @@ -1570,9 +1570,9 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, 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*/ //??sat + L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/ //??sat #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*/ @@ -1724,9 +1724,9 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/ 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*/ //??sat + L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/ //??sat #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*/ @@ -1785,9 +1785,9 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, { tmp = add( *p0++, *p1++ ); #ifdef ISSUE_1867_replace_overflow_libenc - vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */ //??sat + vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */ //??sat #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(); } @@ -1839,9 +1839,9 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat + y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat #else - y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ + y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif move16(); } diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 0af2bef74..9db0b11bd 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -190,11 +190,11 @@ void encod_amr_wb_fx( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat #else - Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ + Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ #endif hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift ); /*Q15*/ @@ -202,7 +202,7 @@ void encod_amr_wb_fx( FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ //??sat //??sat + exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ //??sat //??sat #else exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/ #endif @@ -231,11 +231,11 @@ void encod_amr_wb_fx( L_tmp = L_shl_sat( L_tmp, 5 ); /*Q15*/ L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ //??sat - exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ //??sat + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ //??sat + exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ //??sat #else - L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ - exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ + L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ + exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ #endif move16(); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index d09c3f71e..2b15dbe23 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -269,7 +269,7 @@ void encod_gen_voic_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat #else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif @@ -324,11 +324,11 @@ void encod_gen_voic_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat #else - Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ + Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ #endif hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */ @@ -366,33 +366,33 @@ void encod_gen_voic_fx( { /* Contribution from AVQ layer */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ //??sat - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ //??sat + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ //??sat + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ //??sat #else - Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ + Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/ + Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ #endif /* Compute exc2 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ //??sat - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ //??sat + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat #else - Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */ - exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ + Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */ + exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ #endif move16(); /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ - Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ + Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ + Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ + Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ //??sat - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat #else - Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ + Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ #endif } } @@ -405,17 +405,17 @@ void encod_gen_voic_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ + Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ //??sat - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ //??sat + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ //??sat #else - Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */ - Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */ - Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */ + Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */ + Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */ + Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */ #endif } } @@ -720,10 +720,10 @@ void encod_gen_voic_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); //??sat + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); //??sat #else - Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ + Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); #endif @@ -778,8 +778,8 @@ void encod_gen_voic_ivas_fx( { /* Contribution from AVQ layer */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); //??sat - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); //??sat + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); //??sat + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); //??sat #else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); @@ -787,8 +787,8 @@ void encod_gen_voic_ivas_fx( /* Compute exc2 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); //??sat - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); //??sat + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat #else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); @@ -796,12 +796,12 @@ void encod_gen_voic_ivas_fx( move16(); /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ - Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ - Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ + Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ + Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ //??sat - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat #else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); @@ -819,12 +819,12 @@ void encod_gen_voic_ivas_fx( { /* code in Q9, gain_pit in Q14 */ /*gcode16 in Qnew*/ - Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ + Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ //??sat - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ //??sat - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ //??sat + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); //??sat #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/ diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 931a641d9..9a644cd74 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -442,15 +442,15 @@ void coder_acelp_rf_fx( * Update memory of the weighting filter *-----------------------------------------------------------------*/ /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ - Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ + Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat - Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ //??sat + Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat + Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ //??sat /* Add Gaussian contribution*/ - Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ - Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ //??sat - hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ //??sat //??sat //??sat + Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ //??sat + hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ //??sat //??sat //??sat #else Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */ @@ -474,21 +474,21 @@ void coder_acelp_rf_fx( FOR( i = sub( tmp2, shr( L_SUBFR, 1 ) ); i < tmp2; i++ ) { /* code in Q9, gain_pit in Q14; exc Q_new */ - Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ + Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ //??sat - exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ //??sat //??sat + Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ //??sat + exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ //??sat //??sat move16(); - Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ - Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ //??sat - exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat + Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ //??sat + exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat #else - Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */ - Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */ - exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ); /* Q_new */ + Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */ + Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */ + exc2[i] = round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ); /* Q_new */ move16(); Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ Ltmp2 = L_shl_o( Ltmp2, Q_new_p5, &Overflow ); /* Q15 + Q_new */ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 443937dae..cd3a1a25e 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -86,7 +86,7 @@ void transf_cdbk_enc_fx( IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat #else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); #endif @@ -183,9 +183,9 @@ void transf_cdbk_enc_fx( { m_corr = div_s( 16384, m_den ); e_corr = sub( 14 + 4, e_den ); - Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ + Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ #ifdef ISSUE_1867_replace_overflow_libenc - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat #else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ #endif @@ -296,7 +296,7 @@ void transf_cdbk_enc_fx( FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); //??sat + x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); //??sat #else x_tran[i] = shl_o( x_norm[i], Q_AVQ_OUT_DEC, &Overflow ); #endif @@ -448,7 +448,7 @@ void transf_cdbk_enc_ivas_fx( IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat #else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); #endif @@ -544,9 +544,9 @@ void transf_cdbk_enc_ivas_fx( { m_corr = div_s( 16384, m_den ); e_corr = sub( 14 + 4, e_den ); - Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ + Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ #ifdef ISSUE_1867_replace_overflow_libenc - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat #else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ #endif @@ -660,7 +660,7 @@ void transf_cdbk_enc_ivas_fx( FOR( i = 0; i < Nsv * WIDTH_BAND; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); //??sat + x_tran[i] = shl_sat( x_norm[i], Q_AVQ_OUT_DEC ); //??sat #else x_tran[i] = shl_o( x_norm[i], Q_AVQ_OUT_DEC, &Overflow ); #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 3a5a4f0d3..60b875988 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -293,7 +293,7 @@ void enc_pit_exc_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat #else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif @@ -369,21 +369,21 @@ void enc_pit_exc_fx( *-----------------------------------------------------------------*/ IF( use_fcb != 0 ) { - Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ + Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ //??sat + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ //??sat Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ //??sat - Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit );/* Q_new + Q15 + shift */ //??sat - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ //??sat - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ //??sat + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ //??sat + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ //??sat + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat #else - Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */ + Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); /* Q_new + Q15 + shift */ - Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); /* Q_new + Q15 + shift */ - Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); /* Q_new + 15 */ - hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ + Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); /* Q_new + Q15 + shift */ + Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); /* Q_new + Q15 + shift */ + Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); /* Q_new + 15 */ + hLPDmem->mem_w0 = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ #endif move16(); } @@ -405,12 +405,12 @@ void enc_pit_exc_fx( FOR( i = 0; i < L_subfr; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ + Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ //??sat - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ //??sat + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -540,9 +540,9 @@ void enc_pit_exc_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ //??sat + cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ //??sat #else - cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ + cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ #endif *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ } @@ -868,17 +868,17 @@ void enc_pit_exc_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); // Q_new+14+shift //??sat Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift //??sat - Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift //??sat - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 //??sat - hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift //??sat + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift //??sat + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 //??sat + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat #else - Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift + Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift - Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift - Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); // Q_new+15 - hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ + Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift + Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift + Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow ); // Q_new+15 + hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow ); /*Q_new-1 */ #endif } ELSE @@ -898,12 +898,12 @@ void enc_pit_exc_ivas_fx( FOR( i = 0; i < L_subfr; i++ ) { /* code in Q9, gain_pit in Q14 */ - Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ + Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -1036,7 +1036,7 @@ void enc_pit_exc_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ #else - cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ //??sat + cum_gpit = shl_o( cum_gpit, 1, &Overflow ); /*Q15*/ //??sat #endif *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 162c611cb..4688152a7 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -231,8 +231,8 @@ Word16 encod_tran_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); //??sat + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); //??sat #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -284,12 +284,12 @@ Word16 encod_tran_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ + L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat #else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -307,16 +307,16 @@ Word16 encod_tran_fx( tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); FOR( i = 0; i < L_SUBFR; i++ ) { - L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ + L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat - tmp_fx = round_fx_sat( L_tmp ); //??sat - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat + tmp_fx = round_fx_sat( L_tmp ); //??sat + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat move16(); #else - L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ + L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ move16(); @@ -635,8 +635,8 @@ Word16 encod_tran_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); //??sat + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat + gcode16 = round_fx_sat( Lgcode ); //??sat #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -688,12 +688,12 @@ Word16 encod_tran_ivas_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ - L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ + L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat #else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -711,16 +711,16 @@ Word16 encod_tran_ivas_fx( tmp1_fx = add( 16 - ( 2 + Q_AVQ_OUT_DEC + 1 ), Q_new ); FOR( i = 0; i < L_SUBFR; i++ ) { - L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ + L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat - tmp_fx = round_fx_sat( L_tmp ); //??sat + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat + tmp_fx = round_fx_sat( L_tmp ); //??sat - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat #else - L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ + L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); exc2_fx[i + i_subfr] = add_o( exc2_fx[i + i_subfr], tmp_fx, &Overflow ); /* Q_exc */ -- GitLab From f7e89c35b6b7ce61fe4c177ed9cf1433e7a48843 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 12:21:22 +0200 Subject: [PATCH 19/80] some more _o replacements --- lib_enc/energy_fx.c | 6 +- lib_enc/find_tar_fx.c | 22 +++++++ lib_enc/find_tilt_fx.c | 48 ++++++++++++-- lib_enc/find_uv_fx.c | 69 ++++++++++++++++++-- lib_enc/gain_enc_fx.c | 100 +++++++++++++++++++++++++++++ lib_enc/gaus_enc_fx.c | 34 ++++++++++ lib_enc/gp_clip_fx.c | 16 +++++ lib_enc/gs_enc_fx.c | 10 +++ lib_enc/guided_plc_enc_fx.c | 16 +++++ lib_enc/hf_cod_amrwb_fx.c | 10 +++ lib_enc/hq_classifier_enc_fx.c | 12 ++++ lib_enc/hq_lr_enc_fx.c | 112 +++++++++++++++++++++++++++++++++ lib_enc/hvq_enc_fx.c | 36 +++++++---- lib_enc/igf_enc_fx.c | 16 +++++ lib_enc/ivas_tcx_core_enc_fx.c | 6 ++ 15 files changed, 486 insertions(+), 27 deletions(-) diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index cc0001d4a..f69aad8da 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -42,7 +42,7 @@ void est_energy_fx( const Word16 *Nregion_index; Word32 *sb_power = enerBuffer; Word32 Ltmp32 = 0; -#ifndef ISSUE_1799_replace_L_shr_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif @@ -127,8 +127,8 @@ void est_energy_fx( tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */ s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } -#ifdef ISSUE_1799_replace_L_shr_o - frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ +#ifdef ISSUE_1867_replace_overflow_libenc + frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ //??sat #else frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */ #endif diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 989f309d2..59465c919 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -134,7 +134,11 @@ void find_targets_fx( { Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ } +#ifdef ISSUE_1867_replace_overflow_libenc + h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ //??sat +#else h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ +#endif } Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) @@ -250,14 +254,20 @@ void find_targets_ivas_fx( } set32_fx( h1_32, 0, L_subfr ); +#ifndef ISSUE_1867_replace_overflow_libenc Overflow = 0; move16(); +#endif FOR( i = 0; i < M; i++ ) { Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= i; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat +#else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ +#endif } h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ move32(); @@ -266,17 +276,29 @@ void find_targets_ivas_fx( Ltmp64 = W_mult_16_16( Ap[i], s2 ); /* Q27 */ FOR( j = 1; j <= M; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat +#else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ +#endif } h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */ move32(); FOR( i = M + 1; i < L_subfr; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ //??sat +#else Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ +#endif FOR( j = 2; j <= M; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat +#else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ +#endif } h1_32[i] = W_extract_l( Ltmp64 ); /* Q27 */ move32(); diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index d2e946098..307f46ea6 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -44,9 +44,11 @@ void find_tilt_fx( Word16 scaling; move32(); move32(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* * Initializations @@ -108,8 +110,13 @@ void find_tilt_fx( /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); /* Q31 */ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); /* Q31 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ //??sat + mean_voi = round_fx_sat( Ltmp ); /* Q15 */ //??sat +#else Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ +#endif /*f0 = INT_FS_FX / pitch[2];*/ e_tmp = norm_s( pitch[2] ); @@ -155,13 +162,22 @@ void find_tilt_fx( tmp = sub( freq, f2 ); IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ //??sat +#else lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */ +#endif m_cnt = add( m_cnt, 1 ); /* Q0 */ } pt_E++; } +#ifdef ISSUE_1867_replace_overflow_libenc + f1 = add_sat( f1, f0 ); //??sat + f2 = add_sat( f2, f0 ); //??sat +#else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); +#endif } /*lp_E = lp_E / (float)cnt - lp_bckr;*/ e_tmp = sub( norm_l( lp_E ), 1 ); @@ -175,8 +191,8 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_cnt ); /* exp(e_tmp + e_cnt) */ e_tmp = sub( e_tmp, e_cnt ); -#ifdef ISSUE_1799_replace_L_shr_o - lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ +#ifdef ISSUE_1867_replace_overflow_libenc + lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ //??sat //??sat #else lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif @@ -207,8 +223,8 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_hpE ); /* exp(e_tmp + e_hpE) */ e_tmp = sub( e_tmp, e_hpE ); -#ifdef ISSUE_1799_replace_L_shr_o - ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ +#ifdef ISSUE_1867_replace_overflow_libenc + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ //??sat #else ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif @@ -224,7 +240,11 @@ void find_tilt_fx( IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */ { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( ee[i], 3 ); //??sat +#else Ltmp = L_shl_o( ee[i], 3, &Overflow ); +#endif IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ @@ -279,9 +299,11 @@ void find_tilt_ivas_fx( Word64 sum; Word16 inv_bands, q_lp_E; Word32 Le_min_scaled, Ltmp2; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move32(); move32(); @@ -354,8 +376,13 @@ void find_tilt_ivas_fx( /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 //??sat + mean_voi = round_fx_sat( Ltmp ); // Q15 //??sat +#else Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 +#endif /*f0 = INT_FS_FX / pitch[2];*/ e_tmp = norm_s( pitch[2] ); @@ -411,8 +438,13 @@ void find_tilt_ivas_fx( } pt_E++; } +#ifdef ISSUE_1867_replace_overflow_libenc + f1 = add_sat( f1, f0 ); //??sat + f2 = add_sat( f2, f0 ); //??sat +#else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); +#endif } /*lp_E = lp_E / (float)cnt - lp_bckr;*/ e_tmp = sub( W_norm( sum ), 1 ); @@ -474,8 +506,8 @@ void find_tilt_ivas_fx( m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); -#ifdef ISSUE_1799_replace_L_shr_o - ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ +#ifdef ISSUE_1867_replace_overflow_libenc + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ //??sat #else ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif @@ -484,7 +516,11 @@ void find_tilt_ivas_fx( IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ //??sat +#else Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ +#endif IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 792ddf265..782bc62b3 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -115,9 +115,11 @@ Word16 find_uv_fx( /* o : coding type */ Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE; NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 Last_Resort; @@ -178,8 +180,8 @@ Word16 find_uv_fx( /* o : coding type */ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef ISSUE_1799_replace_L_shr_o - fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ +#ifdef ISSUE_1867_replace_overflow_libenc + fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ //??sat #else fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ #endif @@ -202,7 +204,11 @@ Word16 find_uv_fx( /* o : coding type */ *-----------------------------------------------------------------*/ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ +#ifdef ISSUE_1867_replace_overflow_libenc + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat +#else mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ +#endif mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ @@ -228,7 +234,11 @@ Word16 find_uv_fx( /* o : coding type */ { dE2_th = 21 << 10; move32(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat +#else if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ +#endif { nb_cond = 0; move16(); @@ -307,7 +317,11 @@ Word16 find_uv_fx( /* o : coding type */ test(); if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ +#ifdef ISSUE_1867_replace_overflow_libenc + ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ //??sat +#else ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ +#endif { tmp_offset_flag = 0; move16(); @@ -383,8 +397,13 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat +#else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ +#endif ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ @@ -412,7 +431,11 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat +#else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ +#endif ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ @@ -614,9 +637,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ Word16 ee0_th, ee1_th, voi_th, nb_cond, flag_low_relE; NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 Last_Resort; Word16 vadnoise; @@ -674,8 +699,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef ISSUE_1799_replace_L_shr_o - fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ +#ifdef ISSUE_1867_replace_overflow_libenc + fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ //??sat #else fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ #endif @@ -722,7 +747,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ *-----------------------------------------------------------------*/ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ +#ifdef ISSUE_1867_replace_overflow_libenc + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat +#else mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ +#endif mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ @@ -748,7 +777,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ { dE2_th = 21 << 10; move32(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat +#else if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ +#endif { nb_cond = 0; move16(); @@ -827,9 +860,15 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ + ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ + ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ //??sat +#else IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ +#endif { tmp_offset_flag = 0; move16(); @@ -905,6 +944,18 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + flag_low_relE ) +#else IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ @@ -914,7 +965,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ + flag_low_relE ) +#endif + /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); @@ -931,8 +984,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat +#else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ +#endif + /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 5e2a11169..852d5509b 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -64,9 +64,11 @@ void Es_pred_enc_fx( Word16 s0, s1, ener_dB, mean_ener_code16; const Word16 *qua_table; Word32 ener_fx, Lmean_ener_code, Ltmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Lmean_ener_code = L_deposit_l( 0 ); @@ -95,7 +97,11 @@ void Es_pred_enc_fx( FOR( i = 1; i < L_SUBFR; i++ ) { tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ +#ifdef ISSUE_1867_replace_overflow_libenc + ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); //??sat +#else ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow ); +#endif } /* ener = 10 * (float)log10(ener / (float)L_SUBFR) */ @@ -177,7 +183,11 @@ void Es_pred_enc_fx( FOR( i = 1; i < size; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); //??sat +#else tmp16_2 = abs_s( sub_o( mean_ener_code16, qua_table[i], &Overflow ) ); +#endif IF( LT_16( tmp16_2, tmp16 ) ) { tmp16 = tmp16_2; @@ -233,9 +243,11 @@ void gain_enc_mless_fx( Word16 exp1, exp2; Word16 exp_num, exp_den, exp_div, frac_den; Word32 L_frac_num, L_frac_den, L_div; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* @@ -388,7 +400,11 @@ void gain_enc_mless_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat +#else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ +#endif L_tmp1 = L_shr( L_mult( coeff[1], coeff[4] ), 2 ); /*Q31*/ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -413,7 +429,11 @@ void gain_enc_mless_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat +#else *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); +#endif move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_TC192_Q14, s_min( *gain_pit, G_PITCH_MAX_TC192_Q14 ) ); @@ -443,7 +463,11 @@ void gain_enc_mless_fx( index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat +#else *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ +#endif } ELSE { @@ -554,9 +578,11 @@ void gain_enc_mless_ivas_fx( Word16 exp1, exp2; Word16 exp_num, exp_den, exp_div, frac_den; Word32 L_frac_num, L_frac_den, L_div; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* @@ -722,7 +748,11 @@ void gain_enc_mless_ivas_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat +#else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ +#endif L_tmp1 = L_shr( L_mult( coeff[1], coeff[4] ), 2 ); /*Q31*/ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -747,7 +777,11 @@ void gain_enc_mless_ivas_fx( L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat +#else *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); +#endif move32(); /*Q16*/ *gain_pit = s_max( G_PITCH_MIN_TC192_Q14, s_min( *gain_pit, G_PITCH_MAX_TC192_Q14 ) ); @@ -776,7 +810,11 @@ void gain_enc_mless_ivas_fx( index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat +#else *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ +#endif } ELSE { @@ -891,9 +929,11 @@ void gain_enc_SQ_fx( Word16 exp1, exp2; Word16 exp_num, exp_den, exp_div, frac_den; Word32 L_frac_num, L_frac_den, L_div; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* @@ -998,7 +1038,11 @@ void gain_enc_SQ_fx( L_tmp1 = L_mult( coeff[0], coeff[2] ); /*Q31*/ exp1 = add( exp_coeff[0], exp_coeff[2] ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat +#else L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ +#endif exp2 = add( exp_coeff[4], exp_coeff[4] ); IF( GT_16( exp1, exp2 ) ) @@ -1040,12 +1084,20 @@ void gain_enc_SQ_fx( exp_num = exp2; move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat +#else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ +#endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat +#else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ +#endif L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -1065,7 +1117,11 @@ void gain_enc_SQ_fx( exp_num = exp2; move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat +#else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ +#endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); @@ -1165,9 +1221,11 @@ void gain_enc_SQ_ivas_fx( Word16 exp1, exp2; Word16 exp_num, exp_den, exp_div, frac_den; Word32 L_frac_num, L_frac_den, L_div; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* @@ -1272,7 +1330,11 @@ void gain_enc_SQ_ivas_fx( L_tmp1 = L_mult( coeff[0], coeff[2] ); /*Q31*/ exp1 = add( exp_coeff[0], exp_coeff[2] ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat +#else L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ +#endif exp2 = add( exp_coeff[4], exp_coeff[4] ); IF( GT_16( exp1, exp2 ) ) @@ -1314,16 +1376,28 @@ void gain_enc_SQ_ivas_fx( exp_num = exp2; move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat +#else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ +#endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat +#else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ +#endif move16(); // To be checked +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_mult_sat( coeff[1], coeff[4] ); /*Q31*/ //??sat +#else L_tmp1 = L_mult_o( coeff[1], coeff[4], &Overflow ); /*Q31*/ +#endif exp1 = add( exp_coeff[1], exp_coeff[4] ); L_tmp2 = L_mult( coeff[0], coeff[3] ); /*Q31*/ @@ -1341,7 +1415,11 @@ void gain_enc_SQ_ivas_fx( exp_num = exp2; move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat +#else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ +#endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); @@ -1429,9 +1507,11 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Word16 index, exp_gain, frac_gain, wtmp; Word16 enr_q, wenr; Word32 Ltmp, enr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*enr = 20.0 * log10(*gain + 0.001) codebook gain in dB */ exp_gain = norm_l( *gain ); @@ -1463,7 +1543,11 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Ltmp = Pow2( 14, frac_gain ); /* Put 14 as exponent */ exp_gain = sub( exp_gain, 14 ); /* Retreive exponent of wtmp */ +#ifdef ISSUE_1867_replace_overflow_libenc + *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); //??sat +#else *gain = L_shl_o( Ltmp, add( 16, exp_gain ), &Overflow ); +#endif move32(); /*Q16*/ return index; @@ -1865,10 +1949,12 @@ static Word16 Find_Opt_gainQ_fx( Word16 exp_max[5]; Word16 exp_code, e_max; Word32 L_tmp, L_tmp1; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /*----------------------------------------------------------------* @@ -1963,7 +2049,11 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */ L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat +#else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); +#endif if ( L_tmp1 < 0 ) { index = i; @@ -2930,9 +3020,11 @@ void gain_enc_amr_wb_fx( Word16 exp_max[5], tmp, nBits; Word32 L_tmp, dist_min, L_inov, L_tmp1; const Word16 *t_qua_gain, *p; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -3165,7 +3257,11 @@ void gain_enc_amr_wb_fx( L_tmp = L_mac( L_tmp, coeff[3], g_code ); /* 15 - coeff_exp + 13 - 1 */ L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat +#else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); +#endif /* splitting the if cost half the complexity of using IF macro */ if ( L_tmp1 < 0 ) { @@ -3188,7 +3284,11 @@ void gain_enc_amr_wb_fx( move16(); L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ //??sat +#else L_tmp = L_shl_o( L_tmp, add( exp_gcode0, 4 ), &Overflow ); /* Q12 -> Q16 */ +#endif *gain_code = L_tmp; /* gain of code in Q16 */ move16(); diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index b6ef2d84f..9e89752e4 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -63,9 +63,11 @@ Word16 gaus_encode_fx( Word32 Ltmp; Word16 dn[L_SUBFR], exp_code, gcode; /* Correlation between xn and h1 */ Word16 exp, tmp, tmp_idx; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -101,7 +103,11 @@ Word16 gaus_encode_fx( /*----------------------------------------------------------------* * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ +#ifdef ISSUE_1867_replace_overflow_libenc + gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat +#else gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ +#endif FOR( i = 0; i < L_SUBFR; i++ ) { exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */ @@ -161,9 +167,11 @@ Word16 gaus_encode_ivas_fx( Word32 Ltmp; Word16 dn[L_SUBFR], exp_code, gcode; /* Correlation between xn and h1 */ Word16 exp, tmp, tmp_idx; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -199,7 +207,11 @@ Word16 gaus_encode_ivas_fx( /*----------------------------------------------------------------* * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ +#ifdef ISSUE_1867_replace_overflow_libenc + gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat +#else gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ +#endif FOR( i = 0; i < L_SUBFR; i++ ) { exc[i + i_subfr] = round_fx( L_shl( L_mult( gcode, code[i] ), 15 - 9 ) ); /* Q_new */ @@ -292,9 +304,11 @@ void gauss2v_fx( Word16 gxx, gcc, index_delta, delta, m_sign, inv_delta; Word16 hg[190], Gaus_dico2[190]; Word16 shiftP3; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -525,8 +539,13 @@ void gauss2v_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); +#ifdef ISSUE_1867_replace_overflow_libenc + cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat + eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat +#else cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); +#endif difference_norm = sub( add( cor2_norm, enerw_norm ), add( cor2w_norm, eneri_norm ) ); update_best = 0; @@ -695,7 +714,11 @@ void gauss2v_fx( /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ //??sat +#else *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */ +#endif move32(); return; @@ -753,9 +776,11 @@ void gauss2v_ivas_fx( Word16 gxx, gcc, index_delta, delta, m_sign, inv_delta; Word16 hg[190], Gaus_dico2[190]; Word16 shiftP3; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -986,8 +1011,13 @@ void gauss2v_ivas_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); +#ifdef ISSUE_1867_replace_overflow_libenc + cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat + eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat +#else cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); +#endif difference_norm = sub( add( cor2_norm, enerw_norm ), add( cor2w_norm, eneri_norm ) ); update_best = 0; @@ -1156,7 +1186,11 @@ void gauss2v_ivas_fx( /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ +#ifdef ISSUE_1867_replace_overflow_libenc + *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); //??sat +#else *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); +#endif move32(); return; diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index d7614473b..c25d89df4 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -114,9 +114,11 @@ Word16 gp_clip_fx( Word32 ener; Word32 L_tmp; Word16 thres; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif clip = 0; @@ -142,10 +144,18 @@ Word16 gp_clip_fx( } } +#ifdef ISSUE_1867_replace_overflow_libenc + ener = L_mac_sat( 1L, xn[0], xn[0] ); //??sat +#else ener = L_mac_o( 1L, xn[0], xn[0], &Overflow ); +#endif FOR( i = 1; i < L_SUBFR; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + ener = L_mac_sat( ener, xn[i], xn[i] ); //??sat +#else ener = L_mac_o( ener, xn[i], xn[i], &Overflow ); +#endif } /* ener = 10.0f*(float)log10(ener) */ @@ -334,9 +344,11 @@ Word16 Mode2_gp_clip_fx( Word16 clip, tmp, exp_xn; Word16 i; Word32 wener, Ltmp; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move16(); clip = 0; @@ -355,7 +367,11 @@ Word16 Mode2_gp_clip_fx( FOR( i = 0; i < L_subfr; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + wener = L_mac0_sat( wener, xn[i], xn[i] ); //??sat +#else wener = L_mac0_o( wener, xn[i], xn[i], &Overflow ); +#endif } /*wener = 10.0f*(float)log10(wener);*/ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 7bf52970d..3c240ce8a 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1329,9 +1329,11 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ Word32 L_tmp, ener_max, ener_mean; Word16 tmp, exp2, tmp2, tmp1, exp1, exp3; Word16 scale; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif ener_mean = L_shl( 1, shl( Qnew, 1 ) ); /*2*Qnew*/ @@ -1341,7 +1343,11 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ { L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/ ener_max = L_max( ener_max, L_tmp ); +#ifdef ISSUE_1867_replace_overflow_libenc + ener_mean = L_add_sat( ener_mean, L_tmp ); //??sat +#else ener_mean = L_add_o( ener_mean, L_tmp, &Overflow ); +#endif } /*dyn = 10.0f * (ener_max / ener_mean);*/ ener_mean = Mult_32_16( ener_mean, div_s( 1, lvec ) ); /*2*Qnew*/ @@ -1349,7 +1355,11 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ IF( ener_mean > 0 ) { exp1 = norm_l( ener_mean ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); //??sat +#else tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow ); +#endif exp1 = sub( 30, exp1 ); exp2 = norm_l( ener_max ); diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index 81e50d099..a541219ca 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -43,10 +43,12 @@ static void coderLookAheadInnovation( move32(); move16(); move16(); +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /* Debug init (not instrumented) */ @@ -165,7 +167,11 @@ static void coderLookAheadInnovation( ps_e = add( alp_e, ps_e ); BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1867_replace_overflow_libenc + max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); //??sat +#else max_ps_tmp = L_shl_o( max_ps, sub( max_ps_e, ps_e ), &Overflow ); +#endif BASOP_SATURATE_WARNING_ON_EVS @@ -442,10 +448,12 @@ void updateSpecPowDiffuseIdx_fx( { Word16 min_gp; Word16 k; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif move32(); @@ -455,14 +463,22 @@ void updateSpecPowDiffuseIdx_fx( FOR( k = 1; k < 4; k++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); //??sat +#else st->mean_gc[1] = L_add_o( st->mean_gc[1], st->gain_code[k], &Overflow ); +#endif move32(); min_gp = s_min( min_gp, st->bpf_gainT[k] ); } /* Suppress saturation warning in threshold comparison. */ test(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) //??sat +#else if ( LT_32( st->mean_gc[1], L_add_o( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ), &Overflow ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) +#endif { move16(); st->glr_idx[0] = 0; diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index e21a8bd67..e1aa2aabe 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -86,8 +86,10 @@ void hf_cod_fx( Word32 L_tmp; Word16 *pt1; const Word16 *pt2; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /* Original speech signal as reference for high band gain quantisation */ @@ -110,7 +112,11 @@ void hf_cod_fx( scale_fx = div_s( shl( 1, 14 ), ener_exc_fx ); /*Q(29-q1) */ L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ +#ifdef ISSUE_1867_replace_overflow_libenc + scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ //??sat +#else scale_fx = round_fx( Isqrt( L_shl_o( L_tmp, sub( q2, 26 ), &Overflow ) ) ); /*Q13 */ +#endif pt1 = HF_fx; @@ -186,7 +192,11 @@ void hf_cod_fx( HF_calc_gain_fx = div_s( shl( 1, 14 ), ener_input_fx ); /*Q(29-q1) */ L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ +#ifdef ISSUE_1867_replace_overflow_libenc + HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ //??sat +#else HF_calc_gain_fx = round_fx_o( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ), &Overflow ); /*Q10 */ +#endif /* set energy of HF synthesis to energy of original HF: diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index aa2c319f1..d82246b30 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -652,9 +652,11 @@ void hvq_classifier_ivas_fx( Word16 num_peak_cands, high, low; Word16 sharp[HVQ_NSUB_32k]; Word16 peak_cand_idx[HVQ_THRES_BIN_32k], avail_peaks[HVQ_NSUB_32k]; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif Word16 temp_e = 0; move16(); @@ -808,7 +810,11 @@ void hvq_classifier_ivas_fx( sharp[i] = extract_h( L_shl( L_tmp, shift ) ); /* 30-s+s-8-16 -> Q6 */ move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ +#ifdef ISSUE_1867_replace_overflow_libenc + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ //??sat +#else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); /* Q6 */ +#endif if ( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) ) { num_sharp_bands = add( num_sharp_bands, 1 ); @@ -1085,9 +1091,11 @@ void hvq_classifier_fx( Word16 num_peak_cands, high, low; Word16 sharp[HVQ_NSUB_32k]; Word16 peak_cand_idx[HVQ_THRES_BIN_32k], avail_peaks[HVQ_NSUB_32k]; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif L_input_max = L_deposit_l( 0 ); set32_fx( L_thr, 0, L_FRAME16k ); @@ -1240,7 +1248,11 @@ void hvq_classifier_fx( move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ +#ifdef ISSUE_1867_replace_overflow_libenc + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); //??sat +#else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); +#endif IF( GT_16( sharp[i], HVQ_SHARP_THRES_FX ) ) { num_sharp_bands = add( num_sharp_bands, 1 ); diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index af2780682..efddc1e7f 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -272,10 +272,12 @@ void hq_lr_enc_fx( Word16 beta_fx; /*Q14 1.05f; */ HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif set32_fx( L_y2, 0x0L, L_FRAME48k ); @@ -607,7 +609,11 @@ void hq_lr_enc_fx( move16(); } L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ //??sat +#else L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( 12, exp ), &Overflow ); /*Q(13+exp-15 +12-exp +4 = 14) */ +#endif tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ IF( tmp2 != 0 ) { @@ -624,7 +630,11 @@ void hq_lr_enc_fx( move16(); } L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ //??sat +#else L_tmp2 = L_shl_o( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ), &Overflow ); /*Q(13+exp-15 +13-exp +3 = 14) */ +#endif L_tmp = L_min( L_tmp, L_tmp2 ); /*Q14 */ tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ alpha_fx = add( 16384, tmp ); @@ -647,7 +657,11 @@ void hq_lr_enc_fx( exp = 0; move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat +#else L_tmp = L_shl_o( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ +#endif L_tmp = L_max( L_tmp, 16384 ); /*Q14 */ tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ @@ -670,7 +684,11 @@ void hq_lr_enc_fx( exp = 0; move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ //??sat +#else L_tmp = L_shl_o( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ), &Overflow ); /*Q(13+exp-15 +19-exp +3 = 20) */ +#endif L_tmp = Mult_32_16( L_tmp, shl( sub( bands_fx, lowband ), 9 ) ); /*20 +9 -15 =Q14 */ L_tmp = L_max( L_tmp, 13926 ); /*Q14 */ tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ @@ -749,7 +767,11 @@ void hq_lr_enc_fx( bit_budget_fx = sub( bit_budget_fx, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not Q0*/ FOR( i = 0; i < bands_fx; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat +#else Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ +#endif move32(); } IF( EQ_32( st_fx->core_brate, ACELP_13k20 ) ) @@ -781,7 +803,11 @@ void hq_lr_enc_fx( IF( GE_16( i, lowband ) && add( sub( i, bands_fx ), p2a_bands_fx ) < 0 ) { Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif } IF( GE_16( i, highband ) ) @@ -850,7 +876,11 @@ void hq_lr_enc_fx( { tmp = sub( tmp, lowband ); L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat +#else tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ +#endif IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -911,11 +941,19 @@ void hq_lr_enc_fx( { IF( GE_16( i, lowband ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { Ep_peak_fx = L_add( Ep_tmp_fx[i], 0 ); /*Q15 */ @@ -1179,8 +1217,10 @@ void hq_lr_enc_ivas_fx( Word32 L_band_energy_tmp[BANDS_MAX]; UWord16 lo; Word16 Q_band_energy; +#ifndef ISSUE_1867_replace_overflow_libenc Flag Overflow; move32(); +#endif BSTR_ENC_HANDLE hBstr = st->hBstr; HQ_ENC_HANDLE hHQ_core = st->hHQ_core; @@ -1448,7 +1488,11 @@ void hq_lr_enc_ivas_fx( } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { Ep_peak_fx = Ep_tmp_fx[i]; /*Q15 */ @@ -1572,7 +1616,11 @@ void hq_lr_enc_ivas_fx( move16(); } Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat +#else L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ +#endif L_tmp = L_max( L_tmp, 16384 ); /*14 */ tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ @@ -1619,7 +1667,11 @@ void hq_lr_enc_ivas_fx( { IF( sub( i, lowband ) >= 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif } ELSE { @@ -1661,7 +1713,11 @@ void hq_lr_enc_ivas_fx( Mpy_32_16_ss( Ep_peak_fx, tmp, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ //??sat +#else L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ +#endif tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo ); L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ @@ -1685,7 +1741,11 @@ void hq_lr_enc_ivas_fx( bit_budget = sub( bit_budget, 2 ); /* bits in high bands to indicate the last 2 subbands is allocated bits or not */ FOR( i = 0; i < bands; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat +#else Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ +#endif move32(); } IF( EQ_32( st->core_brate, ACELP_13k20 ) ) @@ -1721,7 +1781,11 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 && add( sub( i, bands ), p2a_bands ) < 0 ) { Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif } IF( sub( i, highband ) >= 0 ) @@ -1754,7 +1818,11 @@ void hq_lr_enc_ivas_fx( tmp = sub( bands, p2a_bands ); tmp = sub( tmp, lowband ); /*Q0 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat +#else tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ +#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -1793,7 +1861,11 @@ void hq_lr_enc_ivas_fx( { tmp = sub( tmp, lowband ); Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat +#else tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ +#endif IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -1818,7 +1890,11 @@ void hq_lr_enc_ivas_fx( { tmp = sub( tmp, lowband ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat +#else tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ +#endif IF( tmp1 != 0 ) { exp = norm_s( tmp1 ); @@ -1857,11 +1933,19 @@ void hq_lr_enc_ivas_fx( { IF( sub( i, lowband ) >= 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat +#else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ +#endif IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { Ep_peak_fx = Ep_tmp_fx[i]; /* Q15 */ @@ -1886,7 +1970,11 @@ void hq_lr_enc_ivas_fx( move16(); FOR( i = 0; i < lowband; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ //??sat +#else tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ +#endif IF( tmp != 0 ) { exp = norm_s( tmp ); @@ -3394,9 +3482,11 @@ static Word16 p2a_threshold_quant_fx( Word32 L_p2a; Word16 p2a_fx; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif exp_safe = 4; /* never happen overflow. */ @@ -3464,7 +3554,11 @@ static Word16 p2a_threshold_quant_fx( /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */ L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ +#ifdef ISSUE_1867_replace_overflow_libenc + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat +#else p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ +#endif } IF( LE_16( p2a_fx, p2a_th_fx ) ) @@ -3514,9 +3608,11 @@ static Word16 p2a_threshold_quant_ivas_fx( Word32 L_p2a; Word16 p2a_fx; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif exp_safe = 4; /* never happen overflow. */ @@ -3583,7 +3679,11 @@ static Word16 p2a_threshold_quant_ivas_fx( /* 10/( log(10)/log(2) ) = 3.01029995663981195211 24660(Q13) */ L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ +#ifdef ISSUE_1867_replace_overflow_libenc + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat +#else p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ +#endif } IF( LE_16( p2a_fx, p2a_th_fx ) ) @@ -3650,9 +3750,11 @@ static void mdct_spectrum_fine_gain_enc_fx( Word16 d_fx; Word16 dmin_fx; Word16 imin_fx; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Fine gain quantization on only the most significant energy bands */ @@ -3723,7 +3825,11 @@ static void mdct_spectrum_fine_gain_enc_fx( exp_normn = norm_l( L_Exy ); exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); +#ifdef ISSUE_1867_replace_overflow_libenc + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat +#else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ +#endif Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ @@ -3812,9 +3918,11 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( Word16 d_fx; Word16 dmin_fx; Word16 imin_fx; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Fine gain quantization on only the most significant energy bands */ @@ -3885,7 +3993,11 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( exp_normn = norm_l( L_Exy ); exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); +#ifdef ISSUE_1867_replace_overflow_libenc + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat +#else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ +#endif Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index f6c45dab2..225fc3964 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -49,9 +49,11 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits Word16 expPeMean, expNfMean, expNfpe, expNfpe3, expo, expo3; Word16 manPeMean, manNfMean, manNfpe, man; Word16 tmp16, adjust; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif bits_used = 0; move16(); @@ -118,7 +120,11 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits nf_cnt = add( nf_cnt, 1 ); /* Q0 */ } +#ifdef ISSUE_1867_replace_overflow_libenc + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat +#else pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ +#endif } IF( pe_mean > 0 ) @@ -146,8 +152,8 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o - noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -181,8 +187,8 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o - lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -191,8 +197,8 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits lb_nfpe = 16384; move16(); } -#ifdef ISSUE_1796_replace_shl_o - Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ //??sat #else Mpy_32_16_ss( nf_gains[i], shl_o( lb_nfpe, 1, &Overflow ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ #endif @@ -238,9 +244,11 @@ Word16 hvq_enc_fx( /*o : Consumed bits Word16 expPeMean, expNfMean, expNfpe, expNfpe3, expo, expo3; Word16 manPeMean, manNfMean, manNfpe, man; Word16 tmp16, adjust; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif bits_used = 0; move16(); @@ -307,7 +315,11 @@ Word16 hvq_enc_fx( /*o : Consumed bits nf_cnt = add( nf_cnt, 1 ); /* Q0 */ } +#ifdef ISSUE_1867_replace_overflow_libenc + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat +#else pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ +#endif } IF( pe_mean > 0 ) @@ -335,8 +347,8 @@ Word16 hvq_enc_fx( /*o : Consumed bits expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o - noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -370,8 +382,8 @@ Word16 hvq_enc_fx( /*o : Consumed bits expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ -#ifdef ISSUE_1799_replace_L_shr_o - lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -380,8 +392,8 @@ Word16 hvq_enc_fx( /*o : Consumed bits lb_nfpe = 16384; move16(); } -#ifdef ISSUE_1796_replace_shl_o - Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ //??sat #else Mpy_32_16_ss( nf_gains[i], shl_o( lb_nfpe, 1, &Overflow ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index e0562467a..c7a2053fd 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -93,9 +93,11 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< Word16 tmp_exp; Word32 L_tmp; Word16 shift; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* initialize variables */ @@ -218,8 +220,13 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); //??sat + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); //??sat //??sat +#else BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyTileR[sfb], &Overflow ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyC[sfb], &Overflow ), sfbEnergyC_exp[sfb], round_fx_o( sfbEnergyTileC[sfb], &Overflow ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); +#endif L_tmp = L_mult( gain, tmp ); gain_exp = add( gain_exp, tmp_exp ); } @@ -247,7 +254,11 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< L_tmp = BASOP_Util_Log2( L_tmp ); L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); +#ifdef ISSUE_1867_replace_overflow_libenc + gain = round_fx_sat( L_shl( L_tmp, shift ) ); //??sat +#else gain = round_fx_o( L_shl_o( L_tmp, shift, &Overflow ), &Overflow ); +#endif gain_exp = sub( 7, shift ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 32767 /*16 Q11*/, 4, &gain ); gain_exp = BASOP_Util_Add_MantExp( gain, gain_exp, 0x4000, 0, &gain ); @@ -442,8 +453,13 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou /* May overflow - just for threshold comparison */ /* negate because the negated may be 1 larger in abs, */ /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */ +#ifdef ISSUE_1867_replace_overflow_libenc + highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); //??sat + L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); //??sat +#else highPassEner_Ovfl = L_shl_o( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ), &Overflow ); L_tmp = L_add_o( pPowerSpectrum[i - 1], highPassEner_Ovfl, &Overflow ); +#endif if ( L_tmp >= 0 ) { diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index da141f473..44ff00575 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -753,7 +753,9 @@ Word16 ivas_acelp_tcx20_switching_fx( Word32 offset_tcx, target; Word32 y_fx[N_MAX]; Word32 tcx_snr; +#ifndef ISSUE_1867_replace_overflow_libenc Flag Overflow; +#endif Word32 gain, noise; Word16 noise_e = 0; move16(); @@ -1241,7 +1243,11 @@ Word16 ivas_acelp_tcx20_switching_fx( test(); if ( ( GT_32( snr_acelp, tcx_snr ) ) && ( LT_32( snr_acelp, L_add( tcx_snr, 131072 /*2.0f Q16*/ ) ) ) && +#ifdef ISSUE_1867_replace_overflow_libenc + ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || //??sat +#else ( LT_32( L_add_o( st->prevTempFlatness_32fx, currFlatness, &Overflow ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || +#endif ( !flag_16k_smc && ( st->sp_aud_decision0 > 0 ) && LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 41943040 /*20.f Q21*/ ) ) ) && ( LE_16( st->Nb_ACELP_frames, 6 ) ) ) { -- GitLab From 6022f72d9f906dd58f7b598c3cad1ad9613671de Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 12:27:55 +0200 Subject: [PATCH 20/80] clang patch --- lib_enc/energy_fx.c | 2 +- lib_enc/find_tar_fx.c | 16 ++-- lib_enc/find_tilt_fx.c | 48 ++++++------ lib_enc/find_uv_fx.c | 133 +++++++++++++++---------------- lib_enc/gain_enc_fx.c | 66 ++++++++-------- lib_enc/gaus_enc_fx.c | 16 ++-- lib_enc/gp_clip_fx.c | 6 +- lib_enc/gs_enc_fx.c | 4 +- lib_enc/guided_plc_enc_fx.c | 6 +- lib_enc/hf_cod_amrwb_fx.c | 18 ++--- lib_enc/hq_classifier_enc_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 138 ++++++++++++++++----------------- lib_enc/hvq_enc_fx.c | 22 +++--- lib_enc/igf_enc_fx.c | 10 +-- lib_enc/ivas_tcx_core_enc_fx.c | 2 +- 15 files changed, 246 insertions(+), 245 deletions(-) diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index f69aad8da..07df641e2 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -128,7 +128,7 @@ void est_energy_fx( s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } #ifdef ISSUE_1867_replace_overflow_libenc - frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ //??sat + frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ //??sat #else frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */ #endif diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 59465c919..f7071f5ae 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -135,9 +135,9 @@ void find_targets_fx( Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ } #ifdef ISSUE_1867_replace_overflow_libenc - h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ //??sat + h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ //??sat #else - h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ + h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ #endif } Ltmp = L_mult( Ap[i], s2 ); /* Q27 */ @@ -264,7 +264,7 @@ void find_targets_ivas_fx( FOR( j = 1; j <= i; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif @@ -277,9 +277,9 @@ void find_targets_ivas_fx( FOR( j = 1; j <= M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat #else - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif } h1_32[M] = W_extract_l( Ltmp64 ); /* Q27 */ @@ -288,14 +288,14 @@ void find_targets_ivas_fx( FOR( i = M + 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ //??sat #else - Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ #endif FOR( j = 2; j <= M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 307f46ea6..6d4790b6b 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -111,11 +111,11 @@ void find_tilt_fx( Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); /* Q31 */ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); /* Q31 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ //??sat - mean_voi = round_fx_sat( Ltmp ); /* Q15 */ //??sat + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ //??sat + mean_voi = round_fx_sat( Ltmp ); /* Q15 */ //??sat #else - Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ - mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ + Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ + mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ #endif /*f0 = INT_FS_FX / pitch[2];*/ @@ -163,17 +163,17 @@ void find_tilt_fx( IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ //??sat + lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ //??sat #else lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */ #endif - m_cnt = add( m_cnt, 1 ); /* Q0 */ + m_cnt = add( m_cnt, 1 ); /* Q0 */ } pt_E++; } #ifdef ISSUE_1867_replace_overflow_libenc - f1 = add_sat( f1, f0 ); //??sat - f2 = add_sat( f2, f0 ); //??sat + f1 = add_sat( f1, f0 ); //??sat + f2 = add_sat( f2, f0 ); //??sat #else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); @@ -192,9 +192,9 @@ void find_tilt_fx( e_tmp = sub( e_tmp, e_cnt ); #ifdef ISSUE_1867_replace_overflow_libenc - lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ //??sat //??sat + lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ //??sat //??sat #else - lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ + lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ @@ -224,9 +224,9 @@ void find_tilt_fx( e_tmp = sub( e_tmp, e_hpE ); #ifdef ISSUE_1867_replace_overflow_libenc - ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ //??sat + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ //??sat #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif } ELSE IF( lp_E == 0 ) @@ -241,7 +241,7 @@ void find_tilt_fx( IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( ee[i], 3 ); //??sat + Ltmp = L_shl_sat( ee[i], 3 ); //??sat #else Ltmp = L_shl_o( ee[i], 3, &Overflow ); #endif @@ -374,14 +374,14 @@ void find_tilt_ivas_fx( hp_bckr = L_add_sat( L_shl_sat( hp_bckr, 1 ), hp_bckr ); /* Q_new */ } /*mean_voi = 0.5f * (voicing[1] + voicing[2]) + corr_shift;*/ - Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 - Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 + Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 #ifdef ISSUE_1867_replace_overflow_libenc Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 //??sat mean_voi = round_fx_sat( Ltmp ); // Q15 //??sat #else - Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 - mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 + Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 + mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 #endif /*f0 = INT_FS_FX / pitch[2];*/ @@ -439,8 +439,8 @@ void find_tilt_ivas_fx( pt_E++; } #ifdef ISSUE_1867_replace_overflow_libenc - f1 = add_sat( f1, f0 ); //??sat - f2 = add_sat( f2, f0 ); //??sat + f1 = add_sat( f1, f0 ); //??sat + f2 = add_sat( f2, f0 ); //??sat #else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); @@ -507,9 +507,9 @@ void find_tilt_ivas_fx( m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); #ifdef ISSUE_1867_replace_overflow_libenc - ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ //??sat + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ //??sat #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif move32(); } @@ -517,11 +517,11 @@ void find_tilt_ivas_fx( IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ //??sat + Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ //??sat #else - Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ + Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ #endif - IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ + IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { Ltmp = Mult_32_16( ee[i], 24576 /* 0.75 in Q15 */ ); /* 6/8 Q6*/ ee[i] = L_shl_sat( Ltmp, 3 ); /* Q6 */ diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 782bc62b3..b35cf439d 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -181,9 +181,9 @@ Word16 find_uv_fx( /* o : coding type */ wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); #ifdef ISSUE_1867_replace_overflow_libenc - fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ //??sat + fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ //??sat #else - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ + fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ #endif if ( GT_32( fac_32, dE1 ) ) @@ -203,13 +203,13 @@ Word16 find_uv_fx( /* o : coding type */ * Average voicing (normalized correlation) *-----------------------------------------------------------------*/ - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ + /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef ISSUE_1867_replace_overflow_libenc - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat #else - mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ + mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ #endif - mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/ + mean_ee = Mult_32_16( mean_ee, 10923 /* 1/3 in Q15 */ ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ @@ -235,9 +235,9 @@ Word16 find_uv_fx( /* o : coding type */ dE2_th = 21 << 10; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat #else - if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif { nb_cond = 0; @@ -318,9 +318,9 @@ Word16 find_uv_fx( /* o : coding type */ if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ #ifdef ISSUE_1867_replace_overflow_libenc - ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ //??sat #else - ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ + ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ #endif { tmp_offset_flag = 0; @@ -398,20 +398,20 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat #else - if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ #endif - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); @@ -432,19 +432,19 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #endif - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); @@ -700,9 +700,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); #ifdef ISSUE_1867_replace_overflow_libenc - fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ //??sat + fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ //??sat #else - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ + fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ #endif if ( GT_32( fac_32, dE1 ) ) @@ -746,13 +746,13 @@ Word16 find_uv_ivas_fx( /* o : coding typ * Average voicing (normalized correlation) *-----------------------------------------------------------------*/ - /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ + /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef ISSUE_1867_replace_overflow_libenc - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat #else - mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ + mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ #endif - mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ + mean_ee = Mult_32_16( mean_ee, 10923 ); /*Q6*/ /* mean_voi3 = 1.0f/3.0f * (voicing[0] + voicing[1] + voicing[2]);*/ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ @@ -778,9 +778,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ dE2_th = 21 << 10; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat #else - if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif { nb_cond = 0; @@ -863,11 +863,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ #ifdef ISSUE_1867_replace_overflow_libenc IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) + /* normalized correlation is low */ //??sat #else - IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ - ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ - ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ + IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ + ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ + ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ #endif { tmp_offset_flag = 0; @@ -945,8 +946,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat + IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ @@ -956,18 +957,18 @@ Word16 find_uv_ivas_fx( /* o : coding typ ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ flag_low_relE ) #else - IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ flag_low_relE ) #endif - /* low relative frame energy (only for SC-VBR) */ + /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); @@ -985,19 +986,19 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #endif - /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 852d5509b..e3dea0546 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -98,7 +98,7 @@ void Es_pred_enc_fx( { tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ #ifdef ISSUE_1867_replace_overflow_libenc - ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); //??sat + ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); //??sat #else ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow ); #endif @@ -184,7 +184,7 @@ void Es_pred_enc_fx( FOR( i = 1; i < size; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); //??sat + tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); //??sat #else tmp16_2 = abs_s( sub_o( mean_ener_code16, qua_table[i], &Overflow ) ); #endif @@ -401,7 +401,7 @@ void gain_enc_mless_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -430,7 +430,7 @@ void gain_enc_mless_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat + *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat #else *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); #endif @@ -462,11 +462,11 @@ void gain_enc_mless_fx( index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); - L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ + L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat #else - *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ + *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ #endif } ELSE @@ -749,7 +749,7 @@ void gain_enc_mless_ivas_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -778,7 +778,7 @@ void gain_enc_mless_ivas_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat + *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat #else *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); #endif @@ -809,11 +809,11 @@ void gain_enc_mless_ivas_fx( index = gain_quant_fx( gain_code, &gain_code16, LG10_G_CODE_MIN_TC192_Q14, LG10_G_CODE_MAX_TC192_Q13, nBits2, &expg ); push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); - L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ + L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat #else - *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ + *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ #endif } ELSE @@ -1039,9 +1039,9 @@ void gain_enc_SQ_fx( exp1 = add( exp_coeff[0], exp_coeff[2] ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat + L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat #else - L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ + L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ #endif exp2 = add( exp_coeff[4], exp_coeff[4] ); @@ -1085,16 +1085,16 @@ void gain_enc_SQ_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat #else - L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ + L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -1118,9 +1118,9 @@ void gain_enc_SQ_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat #else - L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ + L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ @@ -1331,9 +1331,9 @@ void gain_enc_SQ_ivas_fx( exp1 = add( exp_coeff[0], exp_coeff[2] ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat + L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat #else - L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ + L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ #endif exp2 = add( exp_coeff[4], exp_coeff[4] ); @@ -1377,16 +1377,16 @@ void gain_enc_SQ_ivas_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat #else - L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ + L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -1394,9 +1394,9 @@ void gain_enc_SQ_ivas_fx( // To be checked #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_mult_sat( coeff[1], coeff[4] ); /*Q31*/ //??sat + L_tmp1 = L_mult_sat( coeff[1], coeff[4] ); /*Q31*/ //??sat #else - L_tmp1 = L_mult_o( coeff[1], coeff[4], &Overflow ); /*Q31*/ + L_tmp1 = L_mult_o( coeff[1], coeff[4], &Overflow ); /*Q31*/ #endif exp1 = add( exp_coeff[1], exp_coeff[4] ); @@ -1416,9 +1416,9 @@ void gain_enc_SQ_ivas_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat #else - L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ + L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif L_div = Mult_32_16( L_frac_num, tmp ); /*Q(30-exp)*/ @@ -1544,7 +1544,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Ltmp = Pow2( 14, frac_gain ); /* Put 14 as exponent */ exp_gain = sub( exp_gain, 14 ); /* Retreive exponent of wtmp */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); //??sat + *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); //??sat #else *gain = L_shl_o( Ltmp, add( 16, exp_gain ), &Overflow ); #endif @@ -2050,7 +2050,7 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat + L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -3258,7 +3258,7 @@ void gain_enc_amr_wb_fx( L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat + L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -3283,9 +3283,9 @@ void gain_enc_amr_wb_fx( g_code = *p++; /* selected code gain in Q11 */ move16(); - L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ + L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ //??sat + L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ //??sat #else L_tmp = L_shl_o( L_tmp, add( exp_gcode0, 4 ), &Overflow ); /* Q12 -> Q16 */ #endif diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 9e89752e4..d0a5f20e2 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -104,7 +104,7 @@ Word16 gaus_encode_fx( * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ #ifdef ISSUE_1867_replace_overflow_libenc - gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat + gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat #else gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ #endif @@ -208,7 +208,7 @@ Word16 gaus_encode_ivas_fx( * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ #ifdef ISSUE_1867_replace_overflow_libenc - gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat + gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat #else gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ #endif @@ -540,8 +540,8 @@ void gauss2v_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); #ifdef ISSUE_1867_replace_overflow_libenc - cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat - eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat + cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat + eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat #else cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); @@ -715,7 +715,7 @@ void gauss2v_fx( /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ //??sat + *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ //??sat #else *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */ #endif @@ -1012,8 +1012,8 @@ void gauss2v_ivas_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); #ifdef ISSUE_1867_replace_overflow_libenc - cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat - eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat + cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat + eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat #else cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); @@ -1187,7 +1187,7 @@ void gauss2v_ivas_fx( /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); //??sat + *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); //??sat #else *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); #endif diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index c25d89df4..903080aac 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -145,14 +145,14 @@ Word16 gp_clip_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - ener = L_mac_sat( 1L, xn[0], xn[0] ); //??sat + ener = L_mac_sat( 1L, xn[0], xn[0] ); //??sat #else ener = L_mac_o( 1L, xn[0], xn[0], &Overflow ); #endif FOR( i = 1; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - ener = L_mac_sat( ener, xn[i], xn[i] ); //??sat + ener = L_mac_sat( ener, xn[i], xn[i] ); //??sat #else ener = L_mac_o( ener, xn[i], xn[i], &Overflow ); #endif @@ -368,7 +368,7 @@ Word16 Mode2_gp_clip_fx( FOR( i = 0; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - wener = L_mac0_sat( wener, xn[i], xn[i] ); //??sat + wener = L_mac0_sat( wener, xn[i], xn[i] ); //??sat #else wener = L_mac0_o( wener, xn[i], xn[i], &Overflow ); #endif diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 3c240ce8a..678a8b296 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1344,7 +1344,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/ ener_max = L_max( ener_max, L_tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - ener_mean = L_add_sat( ener_mean, L_tmp ); //??sat + ener_mean = L_add_sat( ener_mean, L_tmp ); //??sat #else ener_mean = L_add_o( ener_mean, L_tmp, &Overflow ); #endif @@ -1356,7 +1356,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ { exp1 = norm_l( ener_mean ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); //??sat #else tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow ); #endif diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index a541219ca..6eb9f43fd 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -168,7 +168,7 @@ static void coderLookAheadInnovation( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); //??sat + max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); //??sat #else max_ps_tmp = L_shl_o( max_ps, sub( max_ps_e, ps_e ), &Overflow ); #endif @@ -464,7 +464,7 @@ void updateSpecPowDiffuseIdx_fx( FOR( k = 1; k < 4; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); //??sat + st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); //??sat #else st->mean_gc[1] = L_add_o( st->mean_gc[1], st->gain_code[k], &Overflow ); #endif @@ -475,7 +475,7 @@ void updateSpecPowDiffuseIdx_fx( /* Suppress saturation warning in threshold comparison. */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) //??sat + if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) //??sat #else if ( LT_32( st->mean_gc[1], L_add_o( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ), &Overflow ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) #endif diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index e1aa2aabe..f01d3f18a 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -109,13 +109,13 @@ void hf_cod_fx( ener_exc_fx = dot_prod_satcontr( exc_fx, exc_fx, Q_exc, Q_exc, &q1, L_SUBFR ); ener_hf_fx = dot_prod_satcontr( HF_fx, HF_fx, -3, -3, &q2, L_SUBFR16k ); - scale_fx = div_s( shl( 1, 14 ), ener_exc_fx ); /*Q(29-q1) */ - L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ - q2 = sub( q1, q2 ); /*30-q2 */ + scale_fx = div_s( shl( 1, 14 ), ener_exc_fx ); /*Q(29-q1) */ + L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ + q2 = sub( q1, q2 ); /*30-q2 */ #ifdef ISSUE_1867_replace_overflow_libenc - scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ //??sat + scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ //??sat #else - scale_fx = round_fx( Isqrt( L_shl_o( L_tmp, sub( q2, 26 ), &Overflow ) ) ); /*Q13 */ + scale_fx = round_fx( Isqrt( L_shl_o( L_tmp, sub( q2, 26 ), &Overflow ) ) ); /*Q13 */ #endif @@ -189,11 +189,11 @@ void hf_cod_fx( ener_hf_fx = dot_prod_satcontr( HF_syn_fx, HF_syn_fx, 0, 0, &q2, L_SUBFR16k ); ener_input_fx = dot_prod_satcontr( HF_SP_fx, HF_SP_fx, 0, 0, &q1, L_SUBFR16k ); - HF_calc_gain_fx = div_s( shl( 1, 14 ), ener_input_fx ); /*Q(29-q1) */ - L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ - q2 = sub( q1, q2 ); /*30-q2 */ + HF_calc_gain_fx = div_s( shl( 1, 14 ), ener_input_fx ); /*Q(29-q1) */ + L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ + q2 = sub( q1, q2 ); /*30-q2 */ #ifdef ISSUE_1867_replace_overflow_libenc - HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ //??sat + HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ //??sat #else HF_calc_gain_fx = round_fx_o( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ), &Overflow ); /*Q10 */ #endif diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index d82246b30..5a6990161 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -811,7 +811,7 @@ void hvq_classifier_ivas_fx( move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ //??sat + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ //??sat #else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); /* Q6 */ #endif @@ -1249,7 +1249,7 @@ void hvq_classifier_fx( /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); //??sat + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); //??sat #else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); #endif diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index efddc1e7f..889cc5221 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -608,13 +608,13 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ + L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ //??sat + L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ //??sat #else - L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( 12, exp ), &Overflow ); /*Q(13+exp-15 +12-exp +4 = 14) */ + L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( 12, exp ), &Overflow ); /*Q(13+exp-15 +12-exp +4 = 14) */ #endif - tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ + tmp2 = extract_h( Ep_avrg_fx ); /*Q13-16=-3 */ IF( tmp2 != 0 ) { exp = norm_s( tmp2 ); @@ -629,14 +629,14 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ + L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ //??sat + L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ //??sat #else - L_tmp2 = L_shl_o( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ), &Overflow ); /*Q(13+exp-15 +13-exp +3 = 14) */ + L_tmp2 = L_shl_o( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ), &Overflow ); /*Q(13+exp-15 +13-exp +3 = 14) */ #endif - L_tmp = L_min( L_tmp, L_tmp2 ); /*Q14 */ - tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ + L_tmp = L_min( L_tmp, L_tmp2 ); /*Q14 */ + tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ alpha_fx = add( 16384, tmp ); } IF( EQ_16( hHQ_core->last_bitalloc_max_band[j++], 1 ) ) @@ -658,13 +658,13 @@ void hq_lr_enc_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat + L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat #else - L_tmp = L_shl_o( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ + L_tmp = L_shl_o( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ #endif - L_tmp = L_max( L_tmp, 16384 ); /*Q14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ + L_tmp = L_max( L_tmp, 16384 ); /*Q14 */ + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ } ELSE { @@ -685,14 +685,14 @@ void hq_lr_enc_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ //??sat + L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ //??sat #else - L_tmp = L_shl_o( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ), &Overflow ); /*Q(13+exp-15 +19-exp +3 = 20) */ + L_tmp = L_shl_o( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ), &Overflow ); /*Q(13+exp-15 +19-exp +3 = 20) */ #endif - L_tmp = Mult_32_16( L_tmp, shl( sub( bands_fx, lowband ), 9 ) ); /*20 +9 -15 =Q14 */ - L_tmp = L_max( L_tmp, 13926 ); /*Q14 */ - tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ - alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =Q14 */ + L_tmp = Mult_32_16( L_tmp, shl( sub( bands_fx, lowband ), 9 ) ); /*20 +9 -15 =Q14 */ + L_tmp = L_max( L_tmp, 13926 ); /*Q14 */ + tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ + alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =Q14 */ } L_band_energy_tmp[i] = L_shl( Mult_32_16( L_band_energy_tmp[i], alpha_fx ), 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */ move32(); @@ -768,9 +768,9 @@ void hq_lr_enc_fx( FOR( i = 0; i < bands_fx; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat #else - Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ + Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ #endif move32(); } @@ -804,9 +804,9 @@ void hq_lr_enc_fx( { Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif } @@ -875,11 +875,11 @@ void hq_lr_enc_fx( IF( EQ_16( hHQ_core->last_bitalloc_max_band[sub( i, add( tmp, 1 ) )], 1 ) ) { tmp = sub( tmp, lowband ); - L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ + L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat #else - tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ + tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ #endif IF( tmp != 0 ) { @@ -942,17 +942,17 @@ void hq_lr_enc_fx( IF( GE_16( i, lowband ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif IF( GT_32( Ep_tmp_fx[i], Ep_peak_fx ) ) { @@ -1489,9 +1489,9 @@ void hq_lr_enc_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { @@ -1617,13 +1617,13 @@ void hq_lr_enc_ivas_fx( } Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat + L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat #else - L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ + L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ #endif - L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ + L_tmp = L_max( L_tmp, 16384 ); /*14 */ + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ } ELSE { @@ -1668,9 +1668,9 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif } ELSE @@ -1714,11 +1714,11 @@ void hq_lr_enc_ivas_fx( Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ //??sat + L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ //??sat #else - L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ + L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ #endif - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ + tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*14 */ Mpy_32_16_ss( L_band_energy_tmp[i], tmp2, &L_tmp, &lo ); L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ move32(); @@ -1742,9 +1742,9 @@ void hq_lr_enc_ivas_fx( FOR( i = 0; i < bands; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat #else - Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ + Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ #endif move32(); } @@ -1782,9 +1782,9 @@ void hq_lr_enc_ivas_fx( { Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif } @@ -1819,9 +1819,9 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); /*Q0 */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat #else - tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ + tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ #endif IF( tmp1 != 0 ) { @@ -1862,9 +1862,9 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat #else - tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ + tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ #endif IF( tmp != 0 ) { @@ -1891,9 +1891,9 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat #else - tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ + tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ #endif IF( tmp1 != 0 ) { @@ -1934,17 +1934,17 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat #else - Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ + Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif IF( L_sub( Ep_tmp_fx[i], Ep_peak_fx ) > 0 ) { @@ -1971,9 +1971,9 @@ void hq_lr_enc_ivas_fx( FOR( i = 0; i < lowband; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ //??sat + tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ //??sat #else - tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ + tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ #endif IF( tmp != 0 ) { @@ -3555,9 +3555,9 @@ static Word16 p2a_threshold_quant_fx( L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ #ifdef ISSUE_1867_replace_overflow_libenc - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat #else - p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ + p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ #endif } @@ -3680,9 +3680,9 @@ static Word16 p2a_threshold_quant_ivas_fx( L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ #ifdef ISSUE_1867_replace_overflow_libenc - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat #else - p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ + p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ #endif } @@ -3826,12 +3826,12 @@ static void mdct_spectrum_fine_gain_enc_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); #ifdef ISSUE_1867_replace_overflow_libenc - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat #else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ #endif - Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ - gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ + Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ + gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ dmin_fx = 32767; move16(); @@ -3994,12 +3994,12 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); #ifdef ISSUE_1867_replace_overflow_libenc - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat #else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ #endif - Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ - gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ + Qgamma = add( sub( exp_normn, exp_normd ), 15 ); /* exp_normn - (exp_normd-16) - 1; */ + gamma_fx = shl( gamma_fx, sub( 14, Qgamma ) ); /* Qgamma -> Q14 */ dmin_fx = 32767; move16(); diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 225fc3964..1ae824ade 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -121,9 +121,9 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits } #ifdef ISSUE_1867_replace_overflow_libenc - pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat #else - pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ + pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif } @@ -153,7 +153,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc - noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -188,7 +188,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc - lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat + lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -198,7 +198,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ //??sat + Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ //??sat #else Mpy_32_16_ss( nf_gains[i], shl_o( lb_nfpe, 1, &Overflow ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ #endif @@ -316,9 +316,9 @@ Word16 hvq_enc_fx( /*o : Consumed bits } #ifdef ISSUE_1867_replace_overflow_libenc - pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat #else - pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ + pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif } @@ -348,7 +348,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc - noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -383,7 +383,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc - lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat + lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif @@ -392,8 +392,8 @@ Word16 hvq_enc_fx( /*o : Consumed bits lb_nfpe = 16384; move16(); } -#ifdef ISSUE_1867_replace_overflow_libenc - Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ //??sat +#ifdef ISSUE_1867_replace_overflow_libenc + Mpy_32_16_ss( nf_gains[i], shl_sat( lb_nfpe, 1 ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ //??sat #else Mpy_32_16_ss( nf_gains[i], shl_o( lb_nfpe, 1, &Overflow ), &nf_gains[i], &dontCare ); /* nf_gains[] in Q12 */ #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index c7a2053fd..26d7e17ea 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -221,8 +221,8 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< } #ifdef ISSUE_1867_replace_overflow_libenc - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); //??sat - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); //??sat //??sat + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); //??sat + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); //??sat //??sat #else BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyTileR[sfb], &Overflow ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyC[sfb], &Overflow ), sfbEnergyC_exp[sfb], round_fx_o( sfbEnergyTileC[sfb], &Overflow ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); @@ -255,7 +255,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - gain = round_fx_sat( L_shl( L_tmp, shift ) ); //??sat + gain = round_fx_sat( L_shl( L_tmp, shift ) ); //??sat #else gain = round_fx_o( L_shl_o( L_tmp, shift, &Overflow ), &Overflow ); #endif @@ -454,8 +454,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou /* negate because the negated may be 1 larger in abs, */ /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */ #ifdef ISSUE_1867_replace_overflow_libenc - highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); //??sat - L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); //??sat + highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); //??sat + L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); //??sat #else highPassEner_Ovfl = L_shl_o( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ), &Overflow ); L_tmp = L_add_o( pPowerSpectrum[i - 1], highPassEner_Ovfl, &Overflow ); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 44ff00575..773985f02 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -1244,7 +1244,7 @@ Word16 ivas_acelp_tcx20_switching_fx( if ( ( GT_32( snr_acelp, tcx_snr ) ) && ( LT_32( snr_acelp, L_add( tcx_snr, 131072 /*2.0f Q16*/ ) ) ) && #ifdef ISSUE_1867_replace_overflow_libenc - ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || //??sat + ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || //??sat #else ( LT_32( L_add_o( st->prevTempFlatness_32fx, currFlatness, &Overflow ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || #endif -- GitLab From 2093b5fde58bf3bac9487e61fcc189af2410f456 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 13:42:40 +0200 Subject: [PATCH 21/80] fix many warnings --- lib_enc/find_tar_fx.c | 2 +- lib_enc/gp_clip_fx.c | 2 +- lib_enc/gs_enc_fx.c | 2 +- lib_enc/guided_plc_enc_fx.c | 4 +- lib_enc/hf_cod_amrwb_fx.c | 2 +- lib_enc/hq_classifier_enc_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 10 ++-- lib_enc/hvq_enc_fx.c | 4 +- lib_enc/igf_enc_fx.c | 2 +- lib_enc/lsf_enc_fx.c | 84 +++++++++++++++++++++------------- lib_enc/lsf_msvq_ma_enc_fx.c | 13 ++++-- lib_enc/mdct_classifier_fx.c | 20 ++++++++ lib_enc/multi_harm_fx.c | 24 ++++++++++ 13 files changed, 123 insertions(+), 50 deletions(-) diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index f7071f5ae..2b7f3910b 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -185,7 +185,7 @@ void find_targets_ivas_fx( Word32 h1_32[6 * L_SUBFR]; Word16 sf; Word64 Ltmp64; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index 903080aac..b5a3ac956 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -344,7 +344,7 @@ Word16 Mode2_gp_clip_fx( Word16 clip, tmp, exp_xn; Word16 i; Word32 wener, Ltmp; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 678a8b296..ea73820e8 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1329,7 +1329,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ Word32 L_tmp, ener_max, ener_mean; Word16 tmp, exp2, tmp2, tmp1, exp1, exp3; Word16 scale; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index 6eb9f43fd..c46f6f070 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -43,7 +43,7 @@ static void coderLookAheadInnovation( move32(); move16(); move16(); -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -448,7 +448,7 @@ void updateSpecPowDiffuseIdx_fx( { Word16 min_gp; Word16 k; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index f01d3f18a..7d2f7afcf 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -86,7 +86,7 @@ void hf_cod_fx( Word32 L_tmp; Word16 *pt1; const Word16 *pt2; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 5a6990161..1185bb75e 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -652,7 +652,7 @@ void hvq_classifier_ivas_fx( Word16 num_peak_cands, high, low; Word16 sharp[HVQ_NSUB_32k]; Word16 peak_cand_idx[HVQ_THRES_BIN_32k], avail_peaks[HVQ_NSUB_32k]; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -1091,7 +1091,7 @@ void hvq_classifier_fx( Word16 num_peak_cands, high, low; Word16 sharp[HVQ_NSUB_32k]; Word16 peak_cand_idx[HVQ_THRES_BIN_32k], avail_peaks[HVQ_NSUB_32k]; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 889cc5221..b0d9bbba8 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -272,7 +272,7 @@ void hq_lr_enc_fx( Word16 beta_fx; /*Q14 1.05f; */ HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -3482,7 +3482,7 @@ static Word16 p2a_threshold_quant_fx( Word32 L_p2a; Word16 p2a_fx; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -3608,7 +3608,7 @@ static Word16 p2a_threshold_quant_ivas_fx( Word32 L_p2a; Word16 p2a_fx; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -3750,7 +3750,7 @@ static void mdct_spectrum_fine_gain_enc_fx( Word16 d_fx; Word16 dmin_fx; Word16 imin_fx; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -3918,7 +3918,7 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( Word16 d_fx; Word16 dmin_fx; Word16 imin_fx; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 1ae824ade..66e7092b5 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -49,7 +49,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits Word16 expPeMean, expNfMean, expNfpe, expNfpe3, expo, expo3; Word16 manPeMean, manNfMean, manNfpe, man; Word16 tmp16, adjust; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -244,7 +244,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits Word16 expPeMean, expNfMean, expNfpe, expNfpe3, expo, expo3; Word16 manPeMean, manNfMean, manNfpe, man; Word16 tmp16, adjust; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 26d7e17ea..f109e08d8 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -93,7 +93,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< Word16 tmp_exp; Word32 L_tmp; Word16 shift; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 8db83c2b9..50decb95f 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -766,8 +766,10 @@ static Word16 qlsf_Mode_Select_fx( Word32 temp32, En = 0; Word16 safety_net; Word16 i, cs, cl; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /* calculate the prediction residual */ @@ -784,8 +786,8 @@ static Word16 qlsf_Mode_Select_fx( { pred_pow2[i] = shl( pred1[i], cs ); move16(); -#ifdef ISSUE_1796_replace_shl_o - En = L_mac_o( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i], &Overflow ); /* 2.56*2.56 at Q-4 */ +#ifdef ISSUE_1867_replace_overflow_libenc + En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ //??sat //??sat #else En = L_mac_o( En, mult( pred_pow2[i], shl_o( w[i], 2, &Overflow ) ), pred_pow2[i], &Overflow ); /* 2.56*2.56 at Q-4 */ #endif @@ -1968,8 +1970,10 @@ static void first_VQstages( Word16 *pTmp_short, idx_buf[2 * LSFMBEST * MAX_VQ_STAGES], parents[LSFMBEST], counter = 0, j, m, s, c, c2, p_max, *indices[2]; Word16 maxC = LSFMBEST; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /*float dd[16];*/ @@ -1996,7 +2000,11 @@ static void first_VQstages( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat +#else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ +#endif L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } @@ -2158,8 +2166,10 @@ static void first_VQstages_ivas_fx( Word16 *pTmp_short, idx_buf[2 * LSFMBEST * MAX_VQ_STAGES], parents[LSFMBEST], counter = 0, j, m, s, c, c2, p_max, *indices[2]; Word16 maxC = LSFMBEST; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /*float dd[16];*/ @@ -2186,7 +2196,11 @@ static void first_VQstages_ivas_fx( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat +#else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ +#endif L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } @@ -2369,7 +2383,7 @@ static Word32 vq_lvq_lsf_enc( Word16 quant[LSFMBEST][M], diff[M], dd[M]; Word16 lat_cv[LSFMBEST][M]; Word16 idx_lead[LSFMBEST][2], idx_scale[LSFMBEST][2]; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif @@ -2424,22 +2438,22 @@ static Word32 vq_lvq_lsf_enc( Vr_subt( cand[i], lsf, diff, M ); FOR( j = 0; j < M; j++ ) { -#ifdef ISSUE_1796_replace_shl_o - diff[j] = shl_sat( diff[j], 4 ); +#ifdef ISSUE_1867_replace_overflow_libenc + diff[j] = shl_sat( diff[j], 4 ); //??sat #else diff[j] = shl_o( diff[j], 4, &Overflow ); #endif move16(); } -#ifdef ISSUE_1796_replace_shl_o - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif FOR( j = 1; j < M; j++ ) { -#ifdef ISSUE_1796_replace_shl_o - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif @@ -2489,7 +2503,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 quant[LSFMBEST][M], diff[M], dd[M]; Word16 lat_cv[LSFMBEST][M]; Word16 idx_lead[LSFMBEST][2], idx_scale[LSFMBEST][2]; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif @@ -2561,22 +2575,22 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( Vr_subt( cand[i], lsf, diff, M ); FOR( j = 0; j < M; j++ ) { -#ifdef ISSUE_1796_replace_shl_o - diff[j] = shl_sat( diff[j], 4 ); +#ifdef ISSUE_1867_replace_overflow_libenc + diff[j] = shl_sat( diff[j], 4 ); //??sat #else diff[j] = shl_o( diff[j], 4, &Overflow ); #endif move16(); } -#ifdef ISSUE_1796_replace_shl_o - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif FOR( j = 1; j < M; j++ ) { -#ifdef ISSUE_1796_replace_shl_o - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif @@ -3354,8 +3368,10 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( Word16 error_svq_fx[M], error_svq_q_fx[M]; Word16 cl, cs; Word32 temp_l; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif IF( EQ_16( safety_net, 1 ) ) { @@ -3428,8 +3444,8 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( { yy_fx[i] = shl( yy_fx[i], cs ); move16(); -#ifdef ISSUE_1796_replace_shl_o - temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i], &Overflow ); +#ifdef ISSUE_1867_replace_overflow_libenc + temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); //??sat //??sat #else temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_o( w_fx[i], 2, &Overflow ) ), yy_fx[i], &Overflow ); #endif @@ -3451,14 +3467,20 @@ static void FFT_Mid_Interpol_16k_fx( ) { Word16 i; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif FOR( i = 0; i < L_FFT / 2; i++ ) { /* Interpolation */ +#ifdef ISSUE_1867_replace_overflow_libenc + Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); //??sat +#else Bin_Ener_mid[i] = L_shr( L_add_o( Bin_Ener_old[i], Bin_Ener[i], &Overflow ), 1 ); +#endif /* Memory update */ Bin_Ener_old[i] = Bin_Ener[i]; @@ -3523,8 +3545,10 @@ static void lsf_mid_enc_fx( Word32 L_tmp; Word16 tmp, k1; const Word16 *ratio = NULL; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /* convert LSPs to LSFs */ @@ -3636,15 +3660,13 @@ static void lsf_mid_enc_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ -#ifdef ISSUE_1796_replace_shl_o - tmp = shl_sat( tmp, 4 ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = shl_sat( tmp, 4 ); //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat #else tmp = shl_o( tmp, 4, &Overflow ); -#endif tmp = mult_ro( tmp, tmp, &Overflow ); -#ifdef ISSUE_1796_replace_shl_o - err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); -#else err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); #endif } @@ -3708,8 +3730,10 @@ static void lsf_mid_enc_ivas_fx( Word32 L_tmp; Word16 tmp, k1; const Word16 *ratio = NULL; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /* convert LSPs to LSFs */ @@ -3830,16 +3854,14 @@ static void lsf_mid_enc_ivas_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ -#ifdef ISSUE_1796_replace_shl_o - tmp = shl_sat( tmp, 4 ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = shl_sat( tmp, 4 ); //??sat + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat #else tmp = shl_o( tmp, 4, &Overflow ); -#endif - tmp = mult_ro( tmp, tmp, &Overflow ); -#ifdef ISSUE_1796_replace_shl_o - err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); -#else err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); + tmp = mult_ro( tmp, tmp, &Overflow ); #endif } /* err = L_shl(err,Wscale); */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 981c7e51c..35a5b47e7 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1578,8 +1578,10 @@ void midlsf_enc_fx( Word32 err, err_min, L_tmp; Word16 k, k1, j, tmp, size, qlsf[M], wghts[M]; const Word16 *ratio; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif IF( EQ_16( coder_type, UNVOICED ) ) @@ -1630,15 +1632,20 @@ void midlsf_enc_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ -#ifdef ISSUE_1796_replace_shl_o - tmp = shl_sat( tmp, 4 ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = shl_sat( tmp, 4 ); //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat #else tmp = shl_o( tmp, 4, &Overflow ); -#endif tmp = mult_ro( tmp, tmp, &Overflow ); +#endif err = L_mac( err, tmp, wghts[j] ); } +#ifdef ISSUE_1867_replace_overflow_libenc + err = L_shl_sat( err, 2 ); //??sat +#else err = L_shl_o( err, 2, &Overflow ); +#endif /* err = L_shl(err,Wscale); */ err = Mult_32_16( err, LSF_1_OVER_256SQ ); diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index ea06878c1..f32442eaf 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -118,8 +118,10 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision Word16 exp, exp1, exp2, exp3; Word32 L_tmp, L_tmp1; TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif test(); { @@ -356,7 +358,11 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) //??sat +#else IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) +#endif { condition3 = 1; move16(); @@ -450,7 +456,11 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat +#else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) +#endif { clas_final = hTcxEnc->clas_final_old; move16(); @@ -543,8 +553,10 @@ Word16 mdct_classifier_ivas_fx( Word16 exp, exp1, exp2, exp3; Word32 gain1_tmp = 0, gain2_tmp = 0; Word32 L_tmp, L_tmp1; +#ifndef ISSUE_1867_replace_overflow_libenc Flag Overflow = 0; move16(); +#endif move16(); move16(); @@ -888,7 +900,11 @@ Word16 mdct_classifier_ivas_fx( test(); test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) +#else IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) +#endif { condition3 = 1; move16(); @@ -989,7 +1005,11 @@ Word16 mdct_classifier_ivas_fx( test(); test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat +#else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) +#endif { clas_final = hTcxEnc->clas_final_old; move16(); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 665ee5edf..9b8d3c98a 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -41,9 +41,11 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; Word16 mean_dyn; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*------------------------------------------------------------------* @@ -212,7 +214,11 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity IF( EQ_16( i, ind_mins[k] ) ) { /* include the last peak point (new minimum) to the corr. sum */ +#ifdef ISSUE_1867_replace_overflow_libenc + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat +#else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); +#endif /* calculation of the norm. peak correlation */ test(); @@ -263,9 +269,15 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity k++; } +#ifdef ISSUE_1867_replace_overflow_libenc + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat +#else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); Lcorxy = L_mac_o( Lcorxy, S[i], old_S[i], &Overflow ); +#endif } Copy( S, old_S, ind_mins[0] ); @@ -384,9 +396,11 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; Word16 mean_dyn; +#ifdef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*------------------------------------------------------------------* @@ -549,7 +563,11 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni IF( EQ_16( i, ind_mins[k] ) ) { /* include the last peak point (new minimum) to the corr. sum */ +#ifdef ISSUE_1867_replace_overflow_libenc + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat +#else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); +#endif /* calculation of the norm. peak correlation */ test(); @@ -600,9 +618,15 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni k++; } +#ifdef ISSUE_1867_replace_overflow_libenc + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat +#else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); Lcorxy = L_mac_o( Lcorxy, S[i], old_S[i], &Overflow ); +#endif } Copy( S, old_S, ind_mins[0] ); -- GitLab From d9831640865d41db9159247681e4a3dc3e928c66 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 14:01:14 +0200 Subject: [PATCH 22/80] some more _o replacements --- lib_enc/nelp_enc_fx.c | 44 ++++++++++++++ lib_enc/nois_est_fx.c | 115 +++++++++++++++++++++++++++++++----- lib_enc/normalizecoefs_fx.c | 6 ++ lib_enc/pit_enc_fx.c | 24 ++++++++ lib_enc/pitch_ol2_fx.c | 67 +++++++++++++++++---- lib_enc/pitch_ol_fx.c | 44 ++++++++++++-- 6 files changed, 268 insertions(+), 32 deletions(-) diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 391191175..bb90ec4dd 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -354,9 +354,11 @@ void nelp_encoder_fx( move32(); Word16 BP1_ORDER; Word16 rf_flag; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -422,7 +424,11 @@ void nelp_encoder_fx( E1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat +#else E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ +#endif } qE1 = shl( qE1, 1 ); @@ -438,7 +444,11 @@ void nelp_encoder_fx( EL1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat +#else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ +#endif } qEL1 = shl( qEL1, 1 ); @@ -454,7 +464,11 @@ void nelp_encoder_fx( EH1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat +#else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ +#endif } qEH1 = 2 * qEH1; move16(); @@ -470,7 +484,11 @@ void nelp_encoder_fx( Ltemp = L_deposit_l( 0 ); FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat +#else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ +#endif } /*Gains[i] = (float) sqrt(Gains[i]/lag); */ @@ -494,7 +512,11 @@ void nelp_encoder_fx( Ltemp = L_deposit_l( 0 ); FOR( j = (Word16) ( i * lag ); j < L_FRAME; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat +#else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ +#endif } /*Gains[i] = (float) sqrt(Gains[i]/(L_FRAME-(lag*i))); */ @@ -1099,9 +1121,11 @@ void nelp_encoder_ivas_fx( move32(); Word16 BP1_ORDER; Word16 rf_flag; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -1169,7 +1193,11 @@ void nelp_encoder_ivas_fx( E1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat +#else E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ +#endif } qE1 = shl( qE1, 1 ); @@ -1184,7 +1212,11 @@ void nelp_encoder_ivas_fx( EL1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat +#else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ +#endif } qEL1 = shl( qEL1, 1 ); @@ -1200,7 +1232,11 @@ void nelp_encoder_ivas_fx( EH1_fx = L_deposit_l( 0 ); FOR( i = 0; i < L_FRAME; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat +#else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ +#endif } qEH1 = shl( qEH1, 1 ); move16(); @@ -1215,7 +1251,11 @@ void nelp_encoder_ivas_fx( Ltemp = L_deposit_l( 0 ); FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat +#else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ +#endif } /*Gains[i] = (float) sqrt(Gains[i]/lag); */ @@ -1239,7 +1279,11 @@ void nelp_encoder_ivas_fx( Ltemp = L_deposit_l( 0 ); FOR( j = i_mult( i, lag ); j < L_FRAME; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat +#else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ +#endif } /*Gains[i] = (float) sqrt(Gains[i]/(L_FRAME-(lag*i))); */ diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 224e4dddb..3c91e9e93 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -102,12 +102,18 @@ static Word16 noise_est_ln_q8_fx( { Word16 e_ener, f_ener; Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ //??sat +#else L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */ +#endif if ( flag_add1p0 == 0 ) { L_tmp = L_add( L_enr, 0 ); /* +0 , no offset */ @@ -664,8 +670,10 @@ void noise_est_down_fx( Word16 scale; Word32 totalNoise_temp; Word32 L_Etot, L_Etot_last, L_Etot_v_h2, L_Etot_v; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif L_Etot = L_shl( Etot, 16 ); /*Q24 for later AR1 computations*/ @@ -681,7 +689,11 @@ void noise_est_down_fx( totalNoise_temp = L_deposit_l( 0 ); FOR( i = min_band; i <= max_band; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ //??sat +#else totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ +#endif } totalNoise_temp = L_max( totalNoise_temp, L_shl( e_min, 4 ) ); @@ -705,7 +717,11 @@ void noise_est_down_fx( FOR( i = 0; i < NB_BANDS; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); //??sat +#else Ltmp = L_add_o( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ), &Overflow ); +#endif /*Ltmp = L_shr_r(L_add(*pt1,*pt2),1);*/ enr[i] = Ltmp; move32(); /*Q_new+QSCALE*/ @@ -1003,9 +1019,11 @@ void noise_est_fx( } GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*-----------------------------------------------------------------* @@ -1101,8 +1119,13 @@ void noise_est_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat +#else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); +#endif tmp_pc = pc; move16(); @@ -1155,7 +1178,11 @@ void noise_est_fx( FOR( i = 10; i <= st_fx->max_band; i++ ) { Lnum = L_max( *pt1, *pt2 ); /* Don't need if anymore */ +#ifdef ISSUE_1867_replace_overflow_libenc + Lsum_den = L_add_sat( Lsum_den, Lnum ); //??sat +#else Lsum_den = L_add_o( Lsum_den, Lnum, &Overflow ); +#endif Ltmpden = L_min( *pt1, *pt2 ); if ( Ltmpden == 0 ) { @@ -1211,8 +1238,8 @@ void noise_est_fx( /* calculation of energy in the rest of bands */ Ltmp2 = sum32_fx( &fr_bands[10], sub( st_fx->max_band, 9 ) ); -#ifdef ISSUE_1796_replace_shl_o - wtmp = shl_sat( 1, sub( add( Q_new, QSCALE ), 1 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + wtmp = shl_sat( 1, sub( add( Q_new, QSCALE ), 1 ) ); //??sat #else wtmp = shl_o( 1, sub( add( Q_new, QSCALE ), 1 ), &Overflow ); #endif @@ -1232,8 +1259,8 @@ void noise_est_fx( ExpDen = norm_l( Ltmp ); den = extract_h( L_shl( Ltmp, ExpDen ) ); num = div_s( num, den ); -#ifdef ISSUE_1799_replace_L_shr_o - noise_chartmp = extract_h( L_shr_sat( num, add( sub( ExpNum, ExpDen ), 4 - 16 ) ) ); /* Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + noise_chartmp = extract_h( L_shr_sat( num, add( sub( ExpNum, ExpDen ), 4 - 16 ) ) ); /* Q11 */ //??sat #else noise_chartmp = extract_h( L_shr_o( num, add( sub( ExpNum, ExpDen ), 4 - 16 ), &Overflow ) ); /* Q11 */ #endif @@ -1279,7 +1306,11 @@ void noise_est_fx( /* alpha = 0.064f * ftemp + 0.75f; */ Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ +#ifdef ISSUE_1867_replace_overflow_libenc + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat +#else alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ +#endif /*if( alpha > 0.999f { alpha = 0.999f;} */ alpha = s_min( alpha, 32735 ); /*.999 in Q15*/ @@ -1315,8 +1346,13 @@ void noise_est_fx( /* tmp_enr = enr[i] + 1.0f; */ tmp_Q = add( Q_new, Q_SCALE ); Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat + L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat +#else L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ +#endif IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */ { @@ -1335,8 +1371,8 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp = Mult_32_16( non_sta, num ); -#ifdef ISSUE_1799_replace_L_shr_o - non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif @@ -1361,7 +1397,11 @@ void noise_est_fx( /* ave_enr2:: calculation of another non-stationarity measure (following attacks) */ Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat +#else L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ +#endif IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ { Lnum = L_max( L_tmp_enr, L_tmp_ave_enr2 ); @@ -1374,8 +1414,8 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp1 = Mult_32_16( Lnon_sta2, num ); -#ifdef ISSUE_1799_replace_L_shr_o - Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif @@ -1397,7 +1437,11 @@ void noise_est_fx( /* log_enr = (float)ln_fx(enr[i]); */ log_enr16 = noise_est_ln_q8_fx( enr[i], 0, tmp_Q ); wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + *non_staX = add_sat( *non_staX, wtmp ); //??sat +#else *non_staX = add_o( *non_staX, wtmp, &Overflow ); +#endif move16(); /* Q8 */ hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] = log_enr16; move16(); @@ -1413,7 +1457,11 @@ void noise_est_fx( tmp_floor = LN_E_MIN_PLUS_ONE_FX; move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( hNoiseEst->bckr_fx[i], 1, tmp_Q ); +#ifdef ISSUE_1867_replace_overflow_libenc + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat +#else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ +#endif } ELSE /*ini_frame < 100*/ { @@ -1422,7 +1470,11 @@ void noise_est_fx( tmp_floor = LN_E_MIN_PLUS_ONE_FX; move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( E_MIN_FX, 1, tmp_Q ); +#ifdef ISSUE_1867_replace_overflow_libenc + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat +#else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ +#endif } } @@ -1534,7 +1586,11 @@ void noise_est_fx( Ltmp = eps_quota_fx( epsP_h[0], epsP_l[0], epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ +#ifdef ISSUE_1867_replace_overflow_libenc + epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat +#else epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ +#endif BASOP_SATURATE_WARNING_ON_EVS epsP_0_2 = s_max( 0, epsP_0_2 ); /* min value is 0 , Q12 */ @@ -1573,8 +1629,12 @@ void noise_est_fx( Ltmp = eps_quota_fx( epsP_h[2], epsP_l[2], epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ - epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , - NB saturation in Q12 sets max value to 7,999 */ +#ifdef ISSUE_1867_replace_overflow_libenc + epsP_2_16 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 ,*/ +#else + epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ +#endif + /* NB saturation in Q12 sets max value to 7, 999 */ BASOP_SATURATE_WARNING_ON_EVS epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */ @@ -1696,7 +1756,11 @@ void noise_est_fx( *-----------------------------------------------------------------*/ Ltmp = L_mult( st_fx->voicing_fx[0], 16384 ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 ); +#ifdef ISSUE_1867_replace_overflow_libenc + cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); //??sat +#else cor_tmp = mac_ro( Ltmp, corr_shift, MAX_16, &Overflow ); +#endif LepsP = eps_quota_fx( epsP_h[2], epsP_l[2], epsP_h[16], epsP_l[16], 11 ); /* L_epsP in Q11 */ @@ -2299,9 +2363,11 @@ void noise_est_ivas_fx( Le_min_scaled = L_shl( E_MIN_FXQ31, sub( q_fr_bands, Q31 ) ); // q_fr_bands GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Check if LR-VAD */ @@ -2418,8 +2484,13 @@ void noise_est_ivas_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat +#else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); +#endif tmp_pc = pc; move16(); @@ -2565,8 +2636,8 @@ void noise_est_ivas_fx( { /* ftemp2 /= ftemp */ num = div_s( extract_h( Ltmp2 ), extract_h( Ltmp ) ); // 15+exp2-exp -#ifdef ISSUE_1796_replace_shl_o - noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 +#ifdef ISSUE_1867_replace_overflow_libenc + noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 //??sat #else noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif @@ -2635,7 +2706,11 @@ void noise_est_ivas_fx( /* alpha = 0.064f * ftemp + 0.75f; */ Ltmp = Madd_32_16( 12582912 /* 0.75 in Q24*/, 137438953, tmp ); // Q24 +#ifdef ISSUE_1867_replace_overflow_libenc + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat +#else alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ +#endif /*if( alpha > 0.999f { alpha = 0.999f;} */ alpha = s_min( alpha, 32735 ); /*.999 in Q15*/ @@ -2699,8 +2774,8 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 -#ifdef ISSUE_1799_replace_L_shr_o - non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif @@ -2742,8 +2817,8 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 -#ifdef ISSUE_1799_replace_L_shr_o - Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif @@ -2796,7 +2871,11 @@ void noise_est_ivas_fx( IF( LT_16( ini_frame, 100 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ //??sat +#else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ), &Overflow ); /* Q8 */ +#endif } ELSE /*ini_frame < 100*/ { @@ -2818,7 +2897,11 @@ void noise_est_ivas_fx( Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15 tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ } +#ifdef ISSUE_1867_replace_overflow_libenc + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat +#else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ +#endif } } diff --git a/lib_enc/normalizecoefs_fx.c b/lib_enc/normalizecoefs_fx.c index ea394f54b..0222ae284 100644 --- a/lib_enc/normalizecoefs_fx.c +++ b/lib_enc/normalizecoefs_fx.c @@ -29,9 +29,11 @@ void normalizecoefs_fx( Word16 *pcoefs16; Word32 *pcoefs; Word16 subvec_start, subvec_end, num_coefs; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif pcoefs = coefs; pcoefs16 = coefs_norm; @@ -55,7 +57,11 @@ void normalizecoefs_fx( *pcoefs = Mpy_32_16_1( *pcoefs, INV2POWHALF ); move32(); } +#ifdef ISSUE_1867_replace_overflow_libenc + *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ //??sat //??sat +#else *pcoefs16++ = round_fx_o( L_shl_o( *pcoefs++, 16 - k, &Overflow ), &Overflow ); /* Q12 */ +#endif move16(); } } diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 8eea1b3d5..26bcb8960 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -1518,9 +1518,11 @@ void norm_corr_ivas_fx( Word16 h_e, e_max; Word32 L_tmp; Word64 W_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif k = negate( t_min ); @@ -1542,7 +1544,11 @@ void norm_corr_ivas_fx( L_tmp = L_mac( 0, xn[0], excf[0] ); FOR( i = 1; i < L_subfr; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); // (Q_new - 1) + (Q_new - h_e) + 1 //??sat +#else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); // (Q_new - 1) + (Q_new - h_e) + 1 +#endif } exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); @@ -1613,9 +1619,11 @@ void norm_corr_fx( Word16 corr, exp_corr, norm, exp_norm, exp, scale; Word16 excf[L_FRAME16k]; Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif k = negate( t_min ); @@ -1627,10 +1635,18 @@ void norm_corr_fx( conv_fx( &exc[k], h, excf, L_subfr ); /* Compute rounded down 1/sqrt(energy of xn[]) */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( 1, xn[0], xn[0] ); //??sat +#else L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); +#endif FOR( i = 1; i < L_subfr; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); //??sat +#else L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); +#endif } exp = norm_l( L_tmp ); exp = sub( 30, exp ); @@ -1649,7 +1665,11 @@ void norm_corr_fx( L_tmp = L_mac( 1, xn[0], excf[0] ); FOR( i = 1; i < L_subfr; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); //??sat +#else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); +#endif } exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp ); @@ -1660,7 +1680,11 @@ void norm_corr_fx( L_tmp = L_mac( 1, excf[0], excf[0] ); FOR( i = 1; i < L_subfr; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); //??sat +#else L_tmp = L_mac_o( L_tmp, excf[i], excf[i], &Overflow ); +#endif } exp = norm_l( L_tmp ); diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index de47d85af..97ceec317 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -50,9 +50,11 @@ void pitch_ol2_fx( Word32 R1, R2; Word16 R0, exp_R0, exp_R1, exp_R2, j; Word16 pit_max; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* initialization */ @@ -82,8 +84,13 @@ void pitch_ol2_fx( pt_cor_fx = cor_fx; FOR( t = t_min; t <= t_max; t++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + t0 = L_shl_sat( *pt_cor_32++, exp3 ); //??sat + *pt_cor_fx++ = round_fx_sat( t0 ); //??sat +#else t0 = L_shl_o( *pt_cor_32++, exp3, &Overflow ); *pt_cor_fx++ = round_fx_o( t0, &Overflow ); +#endif move16(); } @@ -189,7 +196,11 @@ void pitch_ol2_fx( exp_R2 = norm_l( R2 ); R2 = L_shl( R2, exp_R2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); //??sat //??sat //??sat +#else R1 = L_mult_o( round_fx_o( R1, &Overflow ), round_fx_o( R2, &Overflow ), &Overflow ); +#endif i = norm_l( R1 ); R1 = L_shl( R1, i ); @@ -199,11 +210,19 @@ void pitch_ol2_fx( R1 = Isqrt_lc( R1, &exp_R1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + R1 = L_mult( R0, round_fx_sat( R1 ) ); //??sat +#else R1 = L_mult( R0, round_fx_o( R1, &Overflow ) ); +#endif exp_R0 = sub( 31, exp_R0 ); exp_R0 = sub( add( exp_R0, exp_R1 ), exp3 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ //??sat //??sat +#else *voicing_fr_fx = round_fx_o( L_shl_o( R1, exp_R0, &Overflow ), &Overflow ); /*Q15*/ +#endif move16(); } ELSE @@ -243,9 +262,11 @@ void StableHighPitchDetect_fx( Word16 tmp, tmp1, exp, diff16, cor_max16, exp1, exp2, pit_min_up; Word32 L_tmp, L_tmp1; Word16 Top; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*voicing = (voicing[0] + voicing[1] + voicing[2] )/3;*/ @@ -294,30 +315,36 @@ void StableHighPitchDetect_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); + diff16 = round_fx_o( diff, &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_o( diff, &Overflow ); } ELSE { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); + diff16 = round_fx_o( diff, &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_o( diff, &Overflow ); } } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat +#else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); +#endif } test(); test(); @@ -394,7 +421,11 @@ void StableHighPitchDetect_fx( L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; +#ifdef ISSUE_1867_replace_overflow_libenc + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat +#else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ +#endif /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); move16(); @@ -459,9 +490,11 @@ void StableHighPitchDetect_ivas_fx( Word16 tmp, tmp1, exp, diff16, cor_max16, exp1, exp2, pit_min_up; Word32 L_tmp, L_tmp1; Word16 Top; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*voicing = (voicing[0] + voicing[1] + voicing[2] )/3;*/ @@ -517,30 +550,36 @@ void StableHighPitchDetect_ivas_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); + diff16 = round_fx_o( diff, &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_o( diff, &Overflow ); } ELSE { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1799_replace_L_shr_o - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); + diff16 = round_fx_o( diff, &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_o( diff, &Overflow ); } } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat +#else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); +#endif } test(); test(); @@ -626,7 +665,11 @@ void StableHighPitchDetect_ivas_fx( L_tmp1 = Isqrt_lc( L_tmp1, &exp ); /*Q(31-exp)*/ cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); +#ifdef ISSUE_1867_replace_overflow_libenc + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat +#else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ +#endif /**voicing0_sm = add(mult_r(24576 ,(*voicing0_sm)) , mult_r(8192 , cor_max16));*/ *voicing0_sm = round_fx( L_mac( L_mult( 24576 /*.75f Q15*/, *voicing0_sm ), 8192 /*.25f Q15*/, cor_max16 ) ); move16(); diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index d4e3284da..39af1235e 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -183,8 +183,10 @@ void pitch_ol_fx( const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1; Word16 pit_min_coding; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif /*--------------------------------------------------------------* @@ -737,7 +739,11 @@ void pitch_ol_fx( enr1_exp = 0; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); //??sat +#else enr1 = add_o( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1, &Overflow ); +#endif enr2 = L_mult( enr0[j], enr1 ); enr2_exp = norm_l( enr2 ); @@ -751,8 +757,8 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) ); -#ifdef ISSUE_1799_replace_L_shr_o - corX[i][j] = extract_h( L_shr_sat( Ltmp, sub( qCorX, 31 ) ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + corX[i][j] = extract_h( L_shr_sat( Ltmp, sub( qCorX, 31 ) ) ); //??sat #else corX[i][j] = extract_h( L_shr_o( Ltmp, sub( qCorX, 31 ), &Overflow ) ); #endif @@ -777,7 +783,11 @@ void pitch_ol_fx( move16(); /* selected moving vector */ enr1_exp = 0; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); //??sat +#else enr1 = add_o( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1, &Overflow ); +#endif enr2 = L_mult( enr0_1[j], enr1 ); enr2_exp = norm_l( enr2 ); @@ -792,8 +802,8 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind1 + len_x], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) ); -#ifdef ISSUE_1799_replace_L_shr_o - corX[i][j + NSECT] = extract_h( L_shr_sat( Ltmp, qCorX - 31 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + corX[i][j + NSECT] = extract_h( L_shr_sat( Ltmp, qCorX - 31 ) ); //??sat #else corX[i][j + NSECT] = extract_h( L_shr_o( Ltmp, qCorX - 31, &Overflow ) ); #endif @@ -876,7 +886,11 @@ void pitch_ol_fx( move16(); pitch_tmp[i] = pitchX[i][ind]; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat +#else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); +#endif move16(); /* Higher is the neighbour's correlation, higher is the weighting */ @@ -890,7 +904,11 @@ void pitch_ol_fx( move16(); pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat +#else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); +#endif move16(); /* Higher is the neighbour's correlation, higher is the weighting */ @@ -1111,8 +1129,10 @@ void pitch_ol_ivas_fx( const Word16 *len, *len1, *sublen, *sublen1, *pit_max, *sec_length, *sec_length1; Word16 pit_min_coding; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif Word16 new_q; new_q = sub( 63, shl( qwsp, 1 ) ); @@ -1715,7 +1735,11 @@ void pitch_ol_ivas_fx( enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr2_exp*/ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind] ); +#ifdef ISSUE_1867_replace_overflow_libenc + corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 //??sat +#else corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 +#endif move16(); Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind] ); @@ -1758,7 +1782,11 @@ void pitch_ol_ivas_fx( enr1 = ISqrt32( enr1, &enr1_exp ); /* 1/sqrt(energy) */ /*31-enr1_exp*/ Ltmp = Mpy_32_16_1( enr1, cor_buf[ind1 + len_x] ); +#ifdef ISSUE_1867_replace_overflow_libenc + corX[i][j + NSECT] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ) ) ); // Q15 //??sat +#else corX[i][j + NSECT] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ), &Overflow ) ); // Q15 +#endif move16(); Ltmp = Mpy_32_16_1( enr1, pt_cor0[ind1 + ( DELTA_COH - 1 ) + len_x] ); @@ -1835,7 +1863,11 @@ void pitch_ol_ivas_fx( move16(); pitch_tmp[i] = pitchX[i][ind]; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat +#else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); +#endif move16(); /* Higher is the neighbour's correlation, higher is the weighting */ @@ -1849,7 +1881,11 @@ void pitch_ol_ivas_fx( move16(); pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat +#else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); +#endif move16(); /* Higher is the neighbour's correlation, higher is the weighting */ -- GitLab From ec14dd41b90c7e516cb1c30b006cd220fa9a6f5c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 14:07:37 +0200 Subject: [PATCH 23/80] clang patch --- lib_enc/lsf_enc_fx.c | 44 ++++++++--------- lib_enc/lsf_msvq_ma_enc_fx.c | 6 +-- lib_enc/mdct_classifier_fx.c | 6 +-- lib_enc/multi_harm_fx.c | 16 +++--- lib_enc/nelp_enc_fx.c | 32 ++++++------ lib_enc/nois_est_fx.c | 95 ++++++++++++++++++------------------ lib_enc/normalizecoefs_fx.c | 2 +- lib_enc/pit_enc_fx.c | 8 +-- lib_enc/pitch_ol2_fx.c | 34 ++++++------- lib_enc/pitch_ol_fx.c | 18 +++---- 10 files changed, 131 insertions(+), 130 deletions(-) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 50decb95f..a6b4ba56a 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -2001,12 +2001,12 @@ static void first_VQstages( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_tmp, maxC ); @@ -2197,12 +2197,12 @@ static void first_VQstages_ivas_fx( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_shr( L_tmp, 1 ), maxC ); /*Q-1 + x2.56 +x2.56 */ @@ -2439,21 +2439,21 @@ static Word32 vq_lvq_lsf_enc( FOR( j = 0; j < M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - diff[j] = shl_sat( diff[j], 4 ); //??sat + diff[j] = shl_sat( diff[j], 4 ); //??sat #else diff[j] = shl_o( diff[j], 4, &Overflow ); #endif move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif FOR( j = 1; j < M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif @@ -2576,21 +2576,21 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( FOR( j = 0; j < M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - diff[j] = shl_sat( diff[j], 4 ); //??sat + diff[j] = shl_sat( diff[j], 4 ); //??sat #else diff[j] = shl_o( diff[j], 4, &Overflow ); #endif move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif FOR( j = 1; j < M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat #else L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif @@ -3445,7 +3445,7 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( yy_fx[i] = shl( yy_fx[i], cs ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); //??sat //??sat + temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); //??sat //??sat #else temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_o( w_fx[i], 2, &Overflow ) ), yy_fx[i], &Overflow ); #endif @@ -3477,7 +3477,7 @@ static void FFT_Mid_Interpol_16k_fx( { /* Interpolation */ #ifdef ISSUE_1867_replace_overflow_libenc - Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); //??sat + Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); //??sat #else Bin_Ener_mid[i] = L_shr( L_add_o( Bin_Ener_old[i], Bin_Ener[i], &Overflow ), 1 ); #endif @@ -3661,9 +3661,9 @@ static void lsf_mid_enc_fx( /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = shl_sat( tmp, 4 ); //??sat - tmp = mult_r_sat( tmp, tmp ); //??sat - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat + tmp = shl_sat( tmp, 4 ); //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat #else tmp = shl_o( tmp, 4, &Overflow ); tmp = mult_ro( tmp, tmp, &Overflow ); @@ -3855,9 +3855,9 @@ static void lsf_mid_enc_ivas_fx( /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = shl_sat( tmp, 4 ); //??sat - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat - tmp = mult_r_sat( tmp, tmp ); //??sat + tmp = shl_sat( tmp, 4 ); //??sat + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat #else tmp = shl_o( tmp, 4, &Overflow ); err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 35a5b47e7..e502b9062 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1633,8 +1633,8 @@ void midlsf_enc_fx( /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = shl_sat( tmp, 4 ); //??sat - tmp = mult_r_sat( tmp, tmp ); //??sat + tmp = shl_sat( tmp, 4 ); //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat #else tmp = shl_o( tmp, 4, &Overflow ); tmp = mult_ro( tmp, tmp, &Overflow ); @@ -1642,7 +1642,7 @@ void midlsf_enc_fx( err = L_mac( err, tmp, wghts[j] ); } #ifdef ISSUE_1867_replace_overflow_libenc - err = L_shl_sat( err, 2 ); //??sat + err = L_shl_sat( err, 2 ); //??sat #else err = L_shl_o( err, 2, &Overflow ); #endif diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index f32442eaf..16a3c60c1 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -359,7 +359,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) //??sat + IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) //??sat #else IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) #endif @@ -457,7 +457,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat #else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) #endif @@ -1006,7 +1006,7 @@ Word16 mdct_classifier_ivas_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat #else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) #endif diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 9b8d3c98a..3628d896e 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -215,7 +215,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity { /* include the last peak point (new minimum) to the corr. sum */ #ifdef ISSUE_1867_replace_overflow_libenc - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat #else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); #endif @@ -270,9 +270,9 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity k++; } #ifdef ISSUE_1867_replace_overflow_libenc - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat #else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); @@ -564,7 +564,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni { /* include the last peak point (new minimum) to the corr. sum */ #ifdef ISSUE_1867_replace_overflow_libenc - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat #else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); #endif @@ -619,9 +619,9 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni k++; } #ifdef ISSUE_1867_replace_overflow_libenc - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat #else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index bb90ec4dd..2d4ea5cd0 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -425,9 +425,9 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat #else - E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif } @@ -445,7 +445,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat #else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ #endif @@ -465,7 +465,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat #else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ #endif @@ -485,9 +485,9 @@ void nelp_encoder_fx( FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -513,9 +513,9 @@ void nelp_encoder_fx( FOR( j = (Word16) ( i * lag ); j < L_FRAME; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -1194,9 +1194,9 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat #else - E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif } @@ -1213,7 +1213,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat #else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ #endif @@ -1233,7 +1233,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat #else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ #endif @@ -1252,9 +1252,9 @@ void nelp_encoder_ivas_fx( FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -1280,9 +1280,9 @@ void nelp_encoder_ivas_fx( FOR( j = i_mult( i, lag ); j < L_FRAME; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 3c91e9e93..9ff5d4e5f 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -110,7 +110,7 @@ static Word16 noise_est_ln_q8_fx( #endif #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ //??sat + L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ //??sat #else L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */ #endif @@ -690,9 +690,9 @@ void noise_est_down_fx( FOR( i = min_band; i <= max_band; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ //??sat + totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ //??sat #else - totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ + totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ #endif } totalNoise_temp = L_max( totalNoise_temp, L_shl( e_min, 4 ) ); @@ -718,7 +718,7 @@ void noise_est_down_fx( FOR( i = 0; i < NB_BANDS; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); //??sat + Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); //??sat #else Ltmp = L_add_o( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ), &Overflow ); #endif @@ -1120,8 +1120,8 @@ void noise_est_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat - wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat #else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); @@ -1179,7 +1179,7 @@ void noise_est_fx( { Lnum = L_max( *pt1, *pt2 ); /* Don't need if anymore */ #ifdef ISSUE_1867_replace_overflow_libenc - Lsum_den = L_add_sat( Lsum_den, Lnum ); //??sat + Lsum_den = L_add_sat( Lsum_den, Lnum ); //??sat #else Lsum_den = L_add_o( Lsum_den, Lnum, &Overflow ); #endif @@ -1239,7 +1239,7 @@ void noise_est_fx( Ltmp2 = sum32_fx( &fr_bands[10], sub( st_fx->max_band, 9 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - wtmp = shl_sat( 1, sub( add( Q_new, QSCALE ), 1 ) ); //??sat + wtmp = shl_sat( 1, sub( add( Q_new, QSCALE ), 1 ) ); //??sat #else wtmp = shl_o( 1, sub( add( Q_new, QSCALE ), 1 ), &Overflow ); #endif @@ -1304,12 +1304,12 @@ void noise_est_fx( tmp = s_max( relE, 0 ); /* Q8 */ /* alpha = 0.064f * ftemp + 0.75f; */ - Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ - Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ + Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ + Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ #ifdef ISSUE_1867_replace_overflow_libenc - alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -1345,13 +1345,13 @@ void noise_est_fx( /* + 1.0f added to reduce sensitivity to non stationarity in low energies */ /* tmp_enr = enr[i] + 1.0f; */ tmp_Q = add( Q_new, Q_SCALE ); - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat - L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat + L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat + L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else - L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ - L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ + L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ + L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */ @@ -1372,7 +1372,7 @@ void noise_est_fx( num = div_s( num, den ); Ltmp = Mult_32_16( non_sta, num ); #ifdef ISSUE_1867_replace_overflow_libenc - non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat + non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif @@ -1395,14 +1395,14 @@ void noise_est_fx( } */ /* ave_enr2:: calculation of another non-stationarity measure (following attacks) */ - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ - /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat + L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else - L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ + L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif - IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ + IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ { Lnum = L_max( L_tmp_enr, L_tmp_ave_enr2 ); Lden = L_min( L_tmp_enr, L_tmp_ave_enr2 ); @@ -1415,7 +1415,7 @@ void noise_est_fx( num = div_s( num, den ); Ltmp1 = Mult_32_16( Lnon_sta2, num ); #ifdef ISSUE_1867_replace_overflow_libenc - Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat + Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif @@ -1438,7 +1438,7 @@ void noise_est_fx( log_enr16 = noise_est_ln_q8_fx( enr[i], 0, tmp_Q ); wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); #ifdef ISSUE_1867_replace_overflow_libenc - *non_staX = add_sat( *non_staX, wtmp ); //??sat + *non_staX = add_sat( *non_staX, wtmp ); //??sat #else *non_staX = add_o( *non_staX, wtmp, &Overflow ); #endif @@ -1458,7 +1458,7 @@ void noise_est_fx( move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( hNoiseEst->bckr_fx[i], 1, tmp_Q ); #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif @@ -1471,7 +1471,7 @@ void noise_est_fx( move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( E_MIN_FX, 1, tmp_Q ); #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif @@ -1584,12 +1584,13 @@ void noise_est_fx( /*epsP_0_2 = max(0 , min(8, epsP[0] / epsP[2])); */ Ltmp = eps_quota_fx( epsP_h[0], epsP_l[0], - epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ + epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc - epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat + epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); + /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat #else - epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ + epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #endif BASOP_SATURATE_WARNING_ON_EVS @@ -1627,12 +1628,12 @@ void noise_est_fx( /* epsP_2_16 = max(0 , min(8, epsP[2] / epsP[16])); */ Ltmp = eps_quota_fx( epsP_h[2], epsP_l[2], - epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ + epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_2_16 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 ,*/ #else - epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ + epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ #endif /* NB saturation in Q12 sets max value to 7, 999 */ BASOP_SATURATE_WARNING_ON_EVS @@ -1757,7 +1758,7 @@ void noise_est_fx( Ltmp = L_mult( st_fx->voicing_fx[0], 16384 ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 ); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); //??sat + cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); //??sat #else cor_tmp = mac_ro( Ltmp, corr_shift, MAX_16, &Overflow ); #endif @@ -2485,8 +2486,8 @@ void noise_est_ivas_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat - wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat #else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); @@ -2639,7 +2640,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 //??sat #else - noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 + noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif } @@ -2707,9 +2708,9 @@ void noise_est_ivas_fx( /* alpha = 0.064f * ftemp + 0.75f; */ Ltmp = Madd_32_16( 12582912 /* 0.75 in Q24*/, 137438953, tmp ); // Q24 #ifdef ISSUE_1867_replace_overflow_libenc - alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -2775,9 +2776,9 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1867_replace_overflow_libenc - non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat + non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else - non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2818,9 +2819,9 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1867_replace_overflow_libenc - Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat + Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ //??sat #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2872,7 +2873,7 @@ void noise_est_ivas_fx( IF( LT_16( ini_frame, 100 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ //??sat #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ), &Overflow ); /* Q8 */ #endif @@ -2898,9 +2899,9 @@ void noise_est_ivas_fx( tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ } #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat #else - non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ + non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif } } diff --git a/lib_enc/normalizecoefs_fx.c b/lib_enc/normalizecoefs_fx.c index 0222ae284..4e9783f67 100644 --- a/lib_enc/normalizecoefs_fx.c +++ b/lib_enc/normalizecoefs_fx.c @@ -58,7 +58,7 @@ void normalizecoefs_fx( move32(); } #ifdef ISSUE_1867_replace_overflow_libenc - *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ //??sat //??sat + *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ //??sat //??sat #else *pcoefs16++ = round_fx_o( L_shl_o( *pcoefs++, 16 - k, &Overflow ), &Overflow ); /* Q12 */ #endif diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 26bcb8960..5870b8e91 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -1636,14 +1636,14 @@ void norm_corr_fx( /* Compute rounded down 1/sqrt(energy of xn[]) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( 1, xn[0], xn[0] ); //??sat + L_tmp = L_mac_sat( 1, xn[0], xn[0] ); //??sat #else L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); #endif FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); //??sat + L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); //??sat #else L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); #endif @@ -1666,7 +1666,7 @@ void norm_corr_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); //??sat + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); //??sat #else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); #endif @@ -1681,7 +1681,7 @@ void norm_corr_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); //??sat + L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); //??sat #else L_tmp = L_mac_o( L_tmp, excf[i], excf[i], &Overflow ); #endif diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 97ceec317..857844f75 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -85,8 +85,8 @@ void pitch_ol2_fx( FOR( t = t_min; t <= t_max; t++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - t0 = L_shl_sat( *pt_cor_32++, exp3 ); //??sat - *pt_cor_fx++ = round_fx_sat( t0 ); //??sat + t0 = L_shl_sat( *pt_cor_32++, exp3 ); //??sat + *pt_cor_fx++ = round_fx_sat( t0 ); //??sat #else t0 = L_shl_o( *pt_cor_32++, exp3, &Overflow ); *pt_cor_fx++ = round_fx_o( t0, &Overflow ); @@ -197,7 +197,7 @@ void pitch_ol2_fx( R2 = L_shl( R2, exp_R2 ); #ifdef ISSUE_1867_replace_overflow_libenc - R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); //??sat //??sat //??sat + R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); //??sat //??sat //??sat #else R1 = L_mult_o( round_fx_o( R1, &Overflow ), round_fx_o( R2, &Overflow ), &Overflow ); #endif @@ -211,7 +211,7 @@ void pitch_ol2_fx( R1 = Isqrt_lc( R1, &exp_R1 ); #ifdef ISSUE_1867_replace_overflow_libenc - R1 = L_mult( R0, round_fx_sat( R1 ) ); //??sat + R1 = L_mult( R0, round_fx_sat( R1 ) ); //??sat #else R1 = L_mult( R0, round_fx_o( R1, &Overflow ) ); #endif @@ -219,7 +219,7 @@ void pitch_ol2_fx( exp_R0 = sub( add( exp_R0, exp_R1 ), exp3 ); #ifdef ISSUE_1867_replace_overflow_libenc - *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ //??sat //??sat + *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ //??sat //??sat #else *voicing_fr_fx = round_fx_o( L_shl_o( R1, exp_R0, &Overflow ), &Overflow ); /*Q15*/ #endif @@ -316,8 +316,8 @@ void StableHighPitchDetect_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat - diff16 = round_fx_sat( diff ); //??sat + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); diff16 = round_fx_o( diff, &Overflow ); @@ -329,8 +329,8 @@ void StableHighPitchDetect_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat - diff16 = round_fx_sat( diff ); //??sat + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); diff16 = round_fx_o( diff, &Overflow ); @@ -341,7 +341,7 @@ void StableHighPitchDetect_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat #else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); #endif @@ -422,7 +422,7 @@ void StableHighPitchDetect_fx( cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; #ifdef ISSUE_1867_replace_overflow_libenc - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat #else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ #endif @@ -551,8 +551,8 @@ void StableHighPitchDetect_ivas_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat - diff16 = round_fx_sat( diff ); //??sat + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); diff16 = round_fx_o( diff, &Overflow ); @@ -564,8 +564,8 @@ void StableHighPitchDetect_ivas_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat - diff16 = round_fx_sat( diff ); //??sat + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); diff16 = round_fx_o( diff, &Overflow ); @@ -576,7 +576,7 @@ void StableHighPitchDetect_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat #else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); #endif @@ -666,7 +666,7 @@ void StableHighPitchDetect_ivas_fx( cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); #ifdef ISSUE_1867_replace_overflow_libenc - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat #else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ #endif diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 39af1235e..15db444b3 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -740,7 +740,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); //??sat + enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); //??sat #else enr1 = add_o( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1, &Overflow ); #endif @@ -758,7 +758,7 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) ); #ifdef ISSUE_1867_replace_overflow_libenc - corX[i][j] = extract_h( L_shr_sat( Ltmp, sub( qCorX, 31 ) ) ); //??sat + corX[i][j] = extract_h( L_shr_sat( Ltmp, sub( qCorX, 31 ) ) ); //??sat #else corX[i][j] = extract_h( L_shr_o( Ltmp, sub( qCorX, 31 ), &Overflow ) ); #endif @@ -784,7 +784,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); //??sat + enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); //??sat #else enr1 = add_o( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1, &Overflow ); #endif @@ -803,7 +803,7 @@ void pitch_ol_fx( qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) ); #ifdef ISSUE_1867_replace_overflow_libenc - corX[i][j + NSECT] = extract_h( L_shr_sat( Ltmp, qCorX - 31 ) ); //??sat + corX[i][j + NSECT] = extract_h( L_shr_sat( Ltmp, qCorX - 31 ) ); //??sat #else corX[i][j + NSECT] = extract_h( L_shr_o( Ltmp, qCorX - 31, &Overflow ) ); #endif @@ -887,7 +887,7 @@ void pitch_ol_fx( pitch_tmp[i] = pitchX[i][ind]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat #else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); #endif @@ -905,7 +905,7 @@ void pitch_ol_fx( pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat #else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); #endif @@ -1738,7 +1738,7 @@ void pitch_ol_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 //??sat #else - corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 + corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 #endif move16(); @@ -1864,7 +1864,7 @@ void pitch_ol_ivas_fx( pitch_tmp[i] = pitchX[i][ind]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat #else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); #endif @@ -1882,7 +1882,7 @@ void pitch_ol_ivas_fx( pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat #else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); #endif -- GitLab From 57b2122a8d15d5615722f7b4752c8fc6aa2e527c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 14:17:20 +0200 Subject: [PATCH 24/80] clang patch --- lib_enc/nois_est_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 9ff5d4e5f..9b5bff692 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1588,7 +1588,7 @@ void noise_est_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); - /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat + /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat #else epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #endif -- GitLab From 296c090f1ac69085706d937092b60152d7301c44 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 15:14:59 +0200 Subject: [PATCH 25/80] fix some warnings --- lib_enc/mdct_classifier_fx.c | 2 +- lib_enc/multi_harm_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 16a3c60c1..e9e130ca1 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -118,7 +118,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision Word16 exp, exp1, exp2, exp3; Word32 L_tmp, L_tmp1; TCX_ENC_HANDLE hTcxEnc = st_fx->hTcxEnc; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 3628d896e..81a788c05 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -41,7 +41,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; Word16 mean_dyn; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -396,7 +396,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni Word32 L_acc; Word32 Lcorx2, Lcory2, Lcorxy, Lcor_map_LT_sum; Word16 mean_dyn; -#ifdef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -- GitLab From 069d14ba1309c97aa5721a82aa1df9fcaecd39ce Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 15:48:07 +0200 Subject: [PATCH 26/80] some more _o replacements --- lib_enc/ppp_enc_fx.c | 46 ++++++++++ lib_enc/pre_proc_fx.c | 6 +- lib_enc/pvq_core_enc_fx.c | 24 ++--- lib_enc/pvq_encode_fx.c | 25 ++++-- lib_enc/q_gain2p_fx.c | 28 ++++++ lib_enc/qlpc_stoch_fx.c | 10 +++ lib_enc/scale_enc_fx.c | 28 +++++- lib_enc/set_impulse_fx.c | 32 ++++++- lib_enc/sig_clas_fx.c | 12 +++ lib_enc/speech_music_classif_fx.c | 70 +++++++++++++-- lib_enc/stat_noise_uv_enc_fx.c | 20 +++++ lib_enc/swb_bwe_enc_fx.c | 140 +++++++++++++++++++++++++++++- 12 files changed, 402 insertions(+), 39 deletions(-) diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index d6dc8b6d6..fa48dc51c 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -622,9 +622,11 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X Word16 n, fshift_fx, HalfLag, ab1[MAXLAG_WI], ab2[MAXLAG_WI]; Word32 corr_fx; Word32 maxcorr_fx, wcorr_fx, diff_corr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif IF( LT_16( X1_fx.lag_fx, X2_fx.lag_fx ) ) { @@ -663,9 +665,15 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat + corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat + temp = add_sat( temp, temp1 ); //??sat +#else corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); temp = add_o( temp, temp1, &Overflow ); +#endif } temp = sub( 32767, extract_l( L_shr( L_mult( 82, abs_s( n ) ), 1 ) ) ); /* Q15 */ Qcorr = norm_l( corr_fx ); @@ -675,23 +683,40 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat + wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat +#else temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ +#endif IF( GE_16( Qmaxcorr, Qcorr ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ //??sat //??sat +#else diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ +#endif } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ //??sat //??sat +#else diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ +#endif } if ( diff_corr > 0 ) { fshift_fx = n; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat +#else maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ +#endif Qmaxcorr = Qcorr; move16(); } @@ -739,9 +764,11 @@ static void LPCPowSpect_fx( Word32 Ltemp, Lw; Word32 Lacc; Word16 tmp, exp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FOR( k = 0; k < Nf; k++ ) { @@ -773,9 +800,15 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ //??sat + Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat + Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat +#else Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ +#endif w = extract_h( Ltemp ); /* w is equivalent cos index */ dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); @@ -797,8 +830,13 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat + Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat +#else Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ +#endif } /* If necessary, we can block-normalize Re and Im to improve precision */ dh = extract_h( Re ); @@ -813,7 +851,11 @@ static void LPCPowSpect_fx( ELSE Lacc = L_mult0( dh, dl ); +#ifdef ISSUE_1867_replace_overflow_libenc + Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat +#else Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ +#endif dh = extract_h( Im ); dl = extract_l( Im ); @@ -844,7 +886,11 @@ static void LPCPowSpect_fx( move16(); } Ltemp = L_deposit_h( tmp ); +#ifdef ISSUE_1867_replace_overflow_libenc + out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); //??sat //??sat +#else out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); +#endif move16(); /* out[k] = shl(tmp,-exp-8); in Q7 */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 8a3cf1a00..c206dbc07 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -127,10 +127,12 @@ void pre_proc_fx( FD_BWE_ENC_HANDLE hBWE_FD = st->hBWE_FD; #ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif +#endif #endif /*------------------------------------------------------------------* @@ -1048,8 +1050,8 @@ void pre_proc_fx( test(); IF( ( ( st->tcxonly == 0 ) || ( EQ_16( st->codec_mode, MODE1 ) ) ) && GT_32( st->input_Fs, 8000 ) ) { -#ifdef ISSUE_1796_replace_shl_o - st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); //??sat #else st->mem_preemph_enc = shl_o( new_inp_16k[sub( L_frame_tmp, 1 )], 1, &Overflow ); #endif diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index a5e193461..952f16d85 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -267,7 +267,7 @@ void pvq_encode_frame_ivas_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -333,8 +333,8 @@ void pvq_encode_frame_ivas_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); -#ifdef ISSUE_1796_replace_shl_o - gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif @@ -397,7 +397,7 @@ void pvq_encode_frame_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -463,8 +463,8 @@ void pvq_encode_frame_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); -#ifdef ISSUE_1796_replace_shl_o - gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif @@ -943,7 +943,7 @@ static void densityIndexSymbolEncode_ivas_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -955,8 +955,8 @@ static void densityIndexSymbolEncode_ivas_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); -#ifdef ISSUE_1796_replace_shl_o - angle = shl_sat( angle, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif @@ -1026,7 +1026,7 @@ static void densityIndexSymbolEncode_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -1038,8 +1038,8 @@ static void densityIndexSymbolEncode_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); -#ifdef ISSUE_1796_replace_shl_o - angle = shl_sat( angle, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index d08b8a902..7d603161b 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -60,9 +60,11 @@ static Word16 one_pulse_search( UWord32 UL_left_l, UL_right_l, UL_dummy; Word32 L_tmp; UWord16 u_sgn; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif en_tmp = en_dn_shift; /* dummy assignment to avoid compiler warning for unused parameter */ @@ -85,8 +87,13 @@ static Word16 one_pulse_search( FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ //??sat //??sat + corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ //??sat +#else L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ +#endif corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ @@ -202,9 +209,11 @@ void pvq_encode_ivas_fx( Word16 neg_gain_norm, shift_tot; Word16 high_pulse_density_flag; PvqEntry entry; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif L_proj_fac = 4096; @@ -359,12 +368,13 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ -#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ +#endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); @@ -414,9 +424,11 @@ void pvq_encode_fx( Word16 neg_gain_norm, shift_tot; Word16 high_pulse_density_flag; PvqEntry entry; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif L_proj_fac = 4096; @@ -571,12 +583,13 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ -#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ +#endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); diff --git a/lib_enc/q_gain2p_fx.c b/lib_enc/q_gain2p_fx.c index 4618483d2..b409a250f 100644 --- a/lib_enc/q_gain2p_fx.c +++ b/lib_enc/q_gain2p_fx.c @@ -145,10 +145,12 @@ static Word16 gain_enc( /* o : quantization pitch index const Word16 *p; const Word16 *t_qua_gain; Word32 L_tmp, dist_min, L_tmp1; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif +#endif assert( ( func_type != FUNC_GAIN_ENC_UV ) && ( func_type != FUNC_GAIN_ENC_GACELP_UV ) ); @@ -165,7 +167,11 @@ static Word16 gain_enc( /* o : quantization pitch index /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ //??sat //??sat +#else *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ +#endif move16(); /*----------------------------------------------------------------* * calculate the predicted gain code @@ -377,7 +383,11 @@ static Word16 gain_enc( /* o : quantization pitch index /* Here, we use L_mult0 to compensate the factor 0.5 applied to coeff[1..4] before */ L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat +#else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); +#endif BASOP_SATURATE_WARNING_ON_EVS if ( L_tmp1 < 0 ) { @@ -397,13 +407,21 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ //??sat +#else L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ +#endif *gain_code = L_tmp; move32(); /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); //??sat +#else *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); +#endif move16(); return index; @@ -436,9 +454,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind Word16 index2; const Word16 log2_scale = 16; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif pred_nrg_frame = 0; /* to suppress compilation warnings */ g_code2 = 0; /* to suppress compilation warnings */ @@ -595,7 +615,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind } s1 = norm_l( *gain_code ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat +#else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); +#endif s1 = sub( 15, s1 ); tmp1 = mult_r( mult_r( tmp1, tmp1 ), g_coeff->y2y2 ); @@ -608,7 +632,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind L_tmp1 = L_add( L_tmp, 0 ); s1 = norm_l( *gain_code ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat +#else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); +#endif s1 = sub( 15, s1 ); c_index2 = 0x7FFF; diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index d6f0b504f..267d05169 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -399,9 +399,11 @@ void Unified_weighting_fx( Word16 nf_fx; Word32 Bin_Ener_160_fx[160]; const Word32 *Freq_w_Table_fx, *Bin_Ener_fx; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*Config. weighting*/ @@ -441,7 +443,11 @@ void Unified_weighting_fx( L_tmp = L_deposit_l( 0 ); FOR( i = 95; i < 127; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ //??sat +#else L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ +#endif } L_tmp = L_shr( L_tmp, 5 ); @@ -522,7 +528,11 @@ void Unified_weighting_fx( } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ //??sat //??sat +#else L_tmp = L_shl_o( L_deposit_l( sub_o( w_fft_fx[i], min_fx, &Overflow ) ), 13, &Overflow ); /* Q21 */ +#endif exp = norm_l( L_tmp ); frac = round_fx( L_shl( L_tmp, exp ) ); exp = sub( add( exp, 21 ), 30 ); diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 32633c89d..84104758c 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,9 +86,11 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*---------------------------------------------------------------* @@ -97,10 +99,11 @@ void Preemph_scaled( *---------------------------------------------------------------*/ BASOP_SATURATE_WARNING_OFF_EVS - Overflow = 0; -#ifdef ISSUE_1796_replace_shl_o - QVal = shl_sat( 1, sub( 15, bits ) ); + +#ifdef ISSUE_1867_replace_overflow_libenc + QVal = shl_sat( 1, sub( 15, bits ) ); //?sat #else + Overflow = 0; QVal = shl_o( 1, sub( 15, bits ), &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS @@ -119,7 +122,11 @@ void Preemph_scaled( /* Equivalent to tmp = max((abs(x[i] - mu*x[i-1]),tmp) * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat +#else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); +#endif L_tmp = L_abs( L_tmp ); L_maxloc = L_max( L_tmp, L_maxloc ); } @@ -169,7 +176,11 @@ void Preemph_scaled( FOR( i = sub( Lframe, 1 ); i > 0; i-- ) { L_tmp = L_mult( new_speech[i], QVal ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat +#else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); +#endif L_tmp = L_shl( L_tmp, *Q_new ); new_speech[i] = round_fx_sat( L_tmp ); // Q_new } @@ -202,8 +213,10 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled { Word16 i; Word32 e_min_scaled; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif e_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( *Q_new, QSCALE ) ) ), 1 ), 1 ); @@ -233,12 +246,21 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled /* Do scaling and valide minimum energy value */ FOR( i = 0; i < NB_BANDS; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); //??sat + bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); //??sat + ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); //??sat + ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); //??sat + st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); //??sat + st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); //??sat +#else enrO[i] = L_max( L_shl_o( enrO[i], Q_exp, &Overflow ), e_min_scaled ); bckr[i] = L_max( L_shl_o( bckr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr[i] = L_max( L_shl_o( ave_enr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr2[i] = L_max( L_shl_o( ave_enr2[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands1[i] = L_max( L_shl_o( st_fr_bands1[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands2[i] = L_max( L_shl_o( st_fr_bands2[i], Q_exp, &Overflow ), e_min_scaled ); +#endif move32(); move32(); move32(); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 7a2224611..962098065 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -65,9 +65,11 @@ void set_impulse_fx( Word16 krit_fx, krit_max_fx, gain16; Word32 Lrr, Ldd, Ltmp, Ltmp1; const Word16 *pt_Glt; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif krit_max_fx = -32768; move16(); @@ -119,12 +121,21 @@ void set_impulse_fx( /* nominator & DEnominator row <0> */ FOR( i = 0; i < L_SUBFR; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat + Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat +#else Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 +#endif } rr_fx[start1] = Lrr; move32(); +#ifdef ISSUE_1867_replace_overflow_libenc + dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat +#else dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 +#endif rr_fx[start1] = L_max( rr_fx[start1], 1 ); FOR( i = add( start1, 1 ); i < L_IMPULSE2; i++ ) @@ -138,14 +149,24 @@ void set_impulse_fx( gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ), Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat + Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat +#else Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 +#endif } gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat + Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat +#else Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 +#endif dd_fx[i] = round_fx_sat( Ldd ); // Q11 rr_fx[i] = L_max( Lrr, 1 ); move32(); @@ -179,8 +200,11 @@ void set_impulse_fx( FOR( i = L_SUBFR - 2; i >= start2; i-- ) { /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ - rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], - gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 +#ifdef ISSUE_1867_replace_overflow_libenc + rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 //??sat +#else + rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 +#endif move32(); } /* nominator rows */ @@ -202,8 +226,8 @@ void set_impulse_fx( num = div_s( num, den ); -#ifdef ISSUE_1796_replace_shl_o - krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ +#ifdef ISSUE_1867_replace_overflow_libenc + krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat #else krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ #endif diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index beb97514a..2235302ff 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -56,9 +56,11 @@ Word16 signal_clas_fx( /* o : classification for current Word16 i, clas, pc, zc, lo, lo2, hi, hi2, exp_ee, frac_ee; Word16 tmp16, tmpS; const Word16 *pt1; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -153,7 +155,11 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = L_mac( Ltmp, relEn, 10923 ); Ltmp = L_mac( Ltmp, pcn, 10923 ); +#ifdef ISSUE_1867_replace_overflow_libenc + fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat +#else fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ +#endif /*-----------------------------------------------------------------* * FEC classification @@ -287,9 +293,11 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur Word16 tmp16, tmpS; const Word16 *pt1; Word64 tmp64; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*----------------------------------------------------------------* @@ -385,7 +393,11 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur Ltmp = L_mac( Ltmp, relEn, 10923 ); Ltmp = L_mac( Ltmp, pcn, 10923 ); +#ifdef ISSUE_1867_replace_overflow_libenc + fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat +#else fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ +#endif /*-----------------------------------------------------------------* * FEC classification diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 0c4a4ec23..ab6e554b8 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -662,9 +662,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis Word16 tmp1, tmp2, exp2, scale, exp3; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*------------------------------------------------------------------* @@ -794,10 +796,18 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis sum_PS = L_deposit_l( 0 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sum_PS = L_add_sat( sum_PS, PS[i] ); //??sat +#else sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); +#endif } exp1 = norm_l( sum_PS ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); //??sat +#else tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); +#endif exp1 = sub( 30, exp1 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) @@ -805,7 +815,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*PS_norm[i] = PS[i] / sum_PS;*/ /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); //??sat +#else tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); +#endif exp2 = sub( 30, exp2 ); scale = shr( sub( tmp1, tmp2 ), 15 ); @@ -866,7 +880,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis ELSE { exp1 = norm_l( L_add( dPS[i], 336 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); //??sat //??sat +#else tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); +#endif exp1 = sub( 30, exp1 ); exp2 = norm_l( mx ); @@ -923,7 +941,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = 0; i < N_FEATURES; i++ ) { /**pFV = pSF[0] * *pFV + pSF[1];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); //??sat //??sat +#else *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); +#endif move16(); pFV++; } @@ -954,7 +976,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); //??sat +#else xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); +#endif move16(); /*Q15 */ } @@ -970,7 +996,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); //??sat +#else xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); +#endif move16(); /*Q15 */ } @@ -985,7 +1015,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); //??sat +#else xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); +#endif move16(); /*Q15 */ } @@ -999,7 +1033,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ +#ifdef ISSUE_1867_replace_overflow_libenc + lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat +#else lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ +#endif lps = s_max( lps, -10832 ); lpm = extract_h( L_shl( L_sub( max_m, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ @@ -1007,7 +1045,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ +#ifdef ISSUE_1867_replace_overflow_libenc + lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat +#else lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ +#endif lpn = s_max( lpn, -10832 ); *high_lpn_flag_ptr = 0; @@ -1459,9 +1501,11 @@ static Word16 attack_det_fx( /* o : attack flag Word16 i, j, tmp, tmp1, attack, exp1; Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG]; Word16 att_3lsub_pos; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -1479,7 +1523,11 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat +#else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ +#endif } finc[i] = L_tmp; @@ -1500,16 +1548,16 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ //??sat #else L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < att_3lsub_pos; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat #else L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ #endif @@ -1521,15 +1569,15 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( tmp1 ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */ -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ //??sat #else L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < tmp1; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat #else L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ #endif @@ -2631,9 +2679,11 @@ static Word16 attack_det_ivas_fx( /* o : attack flag Word64 W_tmp; Word16 q_diff; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -2651,7 +2701,11 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat +#else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ +#endif } finc[i] = L_tmp; diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 598745ebd..225f26d3b 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -50,9 +50,11 @@ void stat_noise_uv_enc_fx( Word16 noisiness = 0; move16(); Word16 num, den, expn, expd; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif test(); test(); @@ -65,9 +67,17 @@ void stat_noise_uv_enc_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ +#else num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ +#endif expd = norm_l( LepsP[1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ +#else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ +#endif num = div_s( num, den ); /*expn-expd+15*/ num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ num = sub( num, 1024 ); /*num - 1*/ @@ -123,9 +133,11 @@ void stat_noise_uv_enc_ivas_fx( Word16 noisiness = 0; move16(); Word16 num, den, expn, expd; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif test(); test(); @@ -138,9 +150,17 @@ void stat_noise_uv_enc_ivas_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ +#else num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ +#endif expd = norm_l( LepsP[1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ +#else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ +#endif num = div_s( num, den ); /*expn-expd+15*/ num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ num = sub( num, 1024 ); /*num - 1*/ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 40fefd684..168b1e155 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -303,9 +303,11 @@ void swb_bwe_enc_ivas_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 fb_band_begin; Word16 q_new_input_hp; @@ -408,7 +410,11 @@ void swb_bwe_enc_ivas_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat +#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); +#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -543,7 +549,11 @@ void swb_bwe_enc_ivas_fx( L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat +#else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE { @@ -623,9 +633,11 @@ void swb_bwe_enc_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -683,7 +695,11 @@ void swb_bwe_enc_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat +#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); +#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -806,7 +822,11 @@ void swb_bwe_enc_fx( // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat +#else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE { @@ -1007,9 +1027,11 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class Word16 sharplimit; Word16 numsharp, num, den; Word16 numharmonic, tmp, expn, expd, scale; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1046,21 +1068,33 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class { IF( hBWE_FD->prev_global_gain_fx == 0 ) { +#ifdef ISSUE_1867_replace_overflow_libenc + gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat +#else gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { expn = norm_l( fGain ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( fGain, expn ) ); +#else num = extract_h( L_shl_o( fGain, expn, &Overflow ) ); +#endif expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) ); expd = norm_l( hBWE_FD->prev_global_gain_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) ); +#else den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) ); +#endif expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); -#ifdef ISSUE_1796_replace_shl_o - num = shl_sat( num, scale ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = shl_sat( num, scale ); //??sat #else num = shl_o( num, scale, &Overflow ); #endif @@ -1068,8 +1102,8 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class tmp = div_s( num, den ); expn = sub( expn, expd ); -#ifdef ISSUE_1796_replace_shl_o - gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ +#ifdef ISSUE_1867_replace_overflow_libenc + gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ //??sat #else gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif @@ -1163,7 +1197,11 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class expd = norm_s( den ); tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ +#ifdef ISSUE_1867_replace_overflow_libenc + sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat +#else sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ +#endif } ELSE { @@ -1363,9 +1401,11 @@ static void vqWithCand_w_fx( const Word16 *p_E_ROM_dico; Word16 dist, temp1; Word32 L_dist, L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif IF( flag ) { @@ -1382,14 +1422,22 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat +#else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ +#endif L_dist = L_mult( dist, w[0] ); /*Q22 */ L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat +#else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); +#endif L_tmp = L_mult( temp1, w[j] ); /*Q22 */ L_tmp = Mult_32_16( L_tmp, temp1 ); /*Q15 */ L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */ @@ -1664,9 +1712,11 @@ static void msvq_interpol_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2], tmp; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Extract target vector */ @@ -1707,13 +1757,21 @@ static void msvq_interpol_fx( /* Extract vector for odd position */ FOR( n_band = 0; n_band < DIM11; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat +#else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); +#endif move16(); } FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat +#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ +#endif tmp = shr( tmp, 1 ); quant_tmp2[n_band] = sub( env_temp12[n_band], tmp ); move16(); /*Q8 */ @@ -1736,7 +1794,11 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat +#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); +#endif tmp = shr( tmp, 1 ); quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] ); move16(); /*Q8 */ @@ -1796,9 +1858,11 @@ static void msvq_interpol_2_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2]; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Extract target vector */ FOR( n_band = 0; n_band < DIM11 - 1; n_band++ ) @@ -1856,9 +1920,17 @@ static void msvq_interpol_2_fx( move16(); FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat +#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); +#endif tmp_q = shr( tmp_q, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat +#else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); +#endif move16(); } @@ -1879,9 +1951,17 @@ static void msvq_interpol_2_fx( move16(); /*Q8 */ FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat +#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); +#endif tmp_q = shr( tmp_q, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat +#else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); +#endif } L_dist = L_deposit_l( 0 ); @@ -1943,9 +2023,11 @@ static void calculate_Tonality_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2051,7 +2133,11 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2072,7 +2158,11 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2101,9 +2191,11 @@ static void calculate_Tonality_ivas_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2209,7 +2301,11 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2230,7 +2326,11 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2618,9 +2718,11 @@ static Word16 SWB_BWE_encoding_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -2663,7 +2765,11 @@ static Word16 SWB_BWE_encoding_fx( } /* tilt returned in Q24 go to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat +#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); +#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -2767,7 +2873,11 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { @@ -2779,7 +2889,11 @@ static Word16 SWB_BWE_encoding_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -3063,9 +3177,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 inner_frame; Word16 q_shift; @@ -3126,7 +3242,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( } /* tilt returned in Q24 go to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat +#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); +#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -3231,7 +3351,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); expd = norm_l( WB_tenv_syn_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat +#else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); +#endif expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); @@ -3244,7 +3368,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { @@ -3255,7 +3383,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { -- GitLab From f2c7b481b3a28ace95c9ccc6a6f145f2bb48f089 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 16:07:01 +0200 Subject: [PATCH 27/80] clang patch --- lib_enc/ppp_enc_fx.c | 52 ++++++++++---------- lib_enc/pre_proc_fx.c | 2 +- lib_enc/pvq_core_enc_fx.c | 6 +-- lib_enc/pvq_encode_fx.c | 22 ++++----- lib_enc/q_gain2p_fx.c | 12 ++--- lib_enc/qlpc_stoch_fx.c | 6 +-- lib_enc/scale_enc_fx.c | 14 +++--- lib_enc/set_impulse_fx.c | 18 +++---- lib_enc/sig_clas_fx.c | 4 +- lib_enc/speech_music_classif_fx.c | 44 ++++++++--------- lib_enc/stat_noise_uv_enc_fx.c | 12 ++--- lib_enc/swb_bwe_enc_fx.c | 80 +++++++++++++++---------------- 12 files changed, 136 insertions(+), 136 deletions(-) diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index fa48dc51c..a662ee328 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -666,9 +666,9 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat - corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat - temp = add_sat( temp, temp1 ); //??sat + corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat + corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat + temp = add_sat( temp, temp1 ); //??sat #else corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); @@ -684,17 +684,17 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X } #ifdef ISSUE_1867_replace_overflow_libenc - temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat - wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat + temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat + wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat #else - temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ - wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ + temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ + wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #endif IF( GE_16( Qmaxcorr, Qcorr ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ //??sat //??sat + diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ //??sat //??sat #else diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ #endif @@ -702,7 +702,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ //??sat //??sat + diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ //??sat //??sat #else diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ #endif @@ -713,9 +713,9 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X fshift_fx = n; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat + maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat #else - maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ + maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif Qmaxcorr = Qcorr; move16(); @@ -801,16 +801,16 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc - Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ //??sat - Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat - Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat + Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ //??sat + Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat + Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat #else - Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ - Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ - Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ + Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ + Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ + Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ #endif - w = extract_h( Ltemp ); /* w is equivalent cos index */ - dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ + w = extract_h( Ltemp ); /* w is equivalent cos index */ + dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); t1 = cos_table[w]; /*t2=cos_table[s_and(add(w,1),511)]; */ @@ -831,11 +831,11 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc - Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat - Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat + Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat + Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat #else - Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ - Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ + Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ + Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ #endif } /* If necessary, we can block-normalize Re and Im to improve precision */ @@ -852,9 +852,9 @@ static void LPCPowSpect_fx( Lacc = L_mult0( dh, dl ); #ifdef ISSUE_1867_replace_overflow_libenc - Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat + Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat #else - Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ + Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif dh = extract_h( Im ); dl = extract_l( Im ); @@ -887,7 +887,7 @@ static void LPCPowSpect_fx( } Ltemp = L_deposit_h( tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); //??sat //??sat + out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); //??sat //??sat #else out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); #endif diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index c206dbc07..49243f8fb 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -1051,7 +1051,7 @@ void pre_proc_fx( IF( ( ( st->tcxonly == 0 ) || ( EQ_16( st->codec_mode, MODE1 ) ) ) && GT_32( st->input_Fs, 8000 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); //??sat + st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); //??sat #else st->mem_preemph_enc = shl_o( new_inp_16k[sub( L_frame_tmp, 1 )], 1, &Overflow ); #endif diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index 952f16d85..b637c5aec 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -334,7 +334,7 @@ void pvq_encode_frame_ivas_fx( tmp = ratio( xy_corr, yy_corr, &exp ); #ifdef ISSUE_1867_replace_overflow_libenc - gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat + gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif @@ -956,7 +956,7 @@ static void densityIndexSymbolEncode_ivas_fx( { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); #ifdef ISSUE_1867_replace_overflow_libenc - angle = shl_sat( angle, 1 ); //??sat + angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif @@ -1039,7 +1039,7 @@ static void densityIndexSymbolEncode_fx( { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); #ifdef ISSUE_1867_replace_overflow_libenc - angle = shl_sat( angle, 1 ); //??sat + angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 7d603161b..71ca29eee 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -88,13 +88,13 @@ static Word16 one_pulse_search( FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ //??sat //??sat - corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ //??sat + L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ //??sat //??sat + corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ //??sat #else L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ #endif - corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ + corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ /* extract_l without shift can always be used for this section as energy is guaranteed to stay in the lower word, 1 op */ @@ -369,11 +369,11 @@ void pvq_encode_ivas_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat - xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ @@ -584,11 +584,11 @@ void pvq_encode_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat - xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ diff --git a/lib_enc/q_gain2p_fx.c b/lib_enc/q_gain2p_fx.c index b409a250f..ae1530e73 100644 --- a/lib_enc/q_gain2p_fx.c +++ b/lib_enc/q_gain2p_fx.c @@ -168,7 +168,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ //??sat //??sat + *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ //??sat //??sat #else *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ #endif @@ -384,7 +384,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat + L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -408,7 +408,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ //??sat + L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ //??sat #else L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ #endif @@ -418,7 +418,7 @@ static Word16 gain_enc( /* o : quantization pitch index /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); #ifdef ISSUE_1867_replace_overflow_libenc - *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); //??sat + *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); //??sat #else *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); #endif @@ -616,7 +616,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif @@ -633,7 +633,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 267d05169..36d33e996 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -444,9 +444,9 @@ void Unified_weighting_fx( FOR( i = 95; i < 127; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ //??sat + L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ //??sat #else - L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ + L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ #endif } @@ -529,7 +529,7 @@ void Unified_weighting_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ //??sat //??sat + L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ //??sat //??sat #else L_tmp = L_shl_o( L_deposit_l( sub_o( w_fft_fx[i], min_fx, &Overflow ) ), 13, &Overflow ); /* Q21 */ #endif diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 84104758c..6e0b63819 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -101,7 +101,7 @@ void Preemph_scaled( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - QVal = shl_sat( 1, sub( 15, bits ) ); //?sat + QVal = shl_sat( 1, sub( 15, bits ) ); //?sat #else Overflow = 0; QVal = shl_o( 1, sub( 15, bits ), &Overflow ); @@ -123,7 +123,7 @@ void Preemph_scaled( * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat #else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); #endif @@ -177,7 +177,7 @@ void Preemph_scaled( { L_tmp = L_mult( new_speech[i], QVal ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat #else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); #endif @@ -247,10 +247,10 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled FOR( i = 0; i < NB_BANDS; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); //??sat - bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); //??sat - ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); //??sat - ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); //??sat + enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); //??sat + bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); //??sat + ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); //??sat + ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); //??sat st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); //??sat st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); //??sat #else diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 962098065..76a4b1afb 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -125,8 +125,8 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 #endif } rr_fx[start1] = Lrr; @@ -134,7 +134,7 @@ void set_impulse_fx( #ifdef ISSUE_1867_replace_overflow_libenc dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat #else - dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 + dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 #endif rr_fx[start1] = L_max( rr_fx[start1], 1 ); @@ -153,8 +153,8 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 #endif } @@ -164,10 +164,10 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 #endif - dd_fx[i] = round_fx_sat( Ldd ); // Q11 + dd_fx[i] = round_fx_sat( Ldd ); // Q11 rr_fx[i] = L_max( Lrr, 1 ); move32(); /* move rr and dd into rr[i] and dd[i] */ @@ -229,7 +229,7 @@ void set_impulse_fx( #ifdef ISSUE_1867_replace_overflow_libenc krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat #else - krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ #endif IF( GT_16( krit_fx, krit_max_fx ) ) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 2235302ff..6e61e0862 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -156,7 +156,7 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = L_mac( Ltmp, pcn, 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat + fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat #else fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ #endif @@ -394,7 +394,7 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur Ltmp = L_mac( Ltmp, pcn, 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat + fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat #else fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ #endif diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index ab6e554b8..8482521cd 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -797,14 +797,14 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sum_PS = L_add_sat( sum_PS, PS[i] ); //??sat + sum_PS = L_add_sat( sum_PS, PS[i] ); //??sat #else sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); #endif } exp1 = norm_l( sum_PS ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); //??sat #else tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); #endif @@ -816,7 +816,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); //??sat + tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); //??sat #else tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); #endif @@ -881,7 +881,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { exp1 = norm_l( L_add( dPS[i], 336 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); //??sat //??sat + tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); //??sat //??sat #else tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); #endif @@ -942,7 +942,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /**pFV = pSF[0] * *pFV + pSF[1];*/ #ifdef ISSUE_1867_replace_overflow_libenc - *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); //??sat //??sat + *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); //??sat //??sat #else *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); #endif @@ -977,7 +977,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); //??sat + xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); //??sat #else xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -997,7 +997,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); //??sat + xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); //??sat #else xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -1016,7 +1016,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); //??sat + xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); //??sat #else xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -1034,9 +1034,9 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ #ifdef ISSUE_1867_replace_overflow_libenc - lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat + lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat #else - lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ + lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif lps = s_max( lps, -10832 ); @@ -1046,9 +1046,9 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ #ifdef ISSUE_1867_replace_overflow_libenc - lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat + lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat #else - lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ + lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif lpn = s_max( lpn, -10832 ); @@ -1524,7 +1524,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat #else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ #endif @@ -1549,17 +1549,17 @@ static Word16 attack_det_fx( /* o : attack flag tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ //??sat + L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ //??sat #else - L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < att_3lsub_pos; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1570,16 +1570,16 @@ static Word16 attack_det_fx( /* o : attack flag tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ //??sat + L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ //??sat #else - L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < tmp1; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -2702,7 +2702,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat #else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ #endif diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 225f26d3b..38a36083e 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -78,9 +78,9 @@ void stat_noise_uv_enc_fx( #else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ #endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -161,9 +161,9 @@ void stat_noise_uv_enc_ivas_fx( #else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ #endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 168b1e155..4bdd08923 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -411,7 +411,7 @@ void swb_bwe_enc_ivas_fx( /* tilt returned in Q24 goto to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat #else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); #endif @@ -548,9 +548,9 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat #else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -696,7 +696,7 @@ void swb_bwe_enc_fx( /* tilt returned in Q24 goto to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat #else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); #endif @@ -821,9 +821,9 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat #else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -1069,9 +1069,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class IF( hBWE_FD->prev_global_gain_fx == 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat + gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat #else - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ #endif } ELSE @@ -1094,7 +1094,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class scale = shr( sub( den, num ), 15 ); #ifdef ISSUE_1867_replace_overflow_libenc - num = shl_sat( num, scale ); //??sat + num = shl_sat( num, scale ); //??sat #else num = shl_o( num, scale, &Overflow ); #endif @@ -1103,9 +1103,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class tmp = div_s( num, den ); expn = sub( expn, expd ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ //??sat + gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ //??sat #else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif } test(); @@ -1195,10 +1195,10 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat + sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat #else sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ #endif @@ -1423,18 +1423,18 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat + dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat #else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ #endif - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat + temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat #else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); #endif @@ -1758,7 +1758,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM11; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat + quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat #else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); #endif @@ -1768,7 +1768,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat #else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ #endif @@ -1795,7 +1795,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat #else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); #endif @@ -1921,13 +1921,13 @@ static void msvq_interpol_2_fx( FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat #else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); #endif tmp_q = shr( tmp_q, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat + quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat #else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); #endif @@ -1952,13 +1952,13 @@ static void msvq_interpol_2_fx( FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat #else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); #endif tmp_q = shr( tmp_q, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc - quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat + quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat #else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); #endif @@ -2134,7 +2134,7 @@ static void calculate_Tonality_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat #else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2159,7 +2159,7 @@ static void calculate_Tonality_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat #else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2302,7 +2302,7 @@ static void calculate_Tonality_ivas_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat #else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2327,7 +2327,7 @@ static void calculate_Tonality_ivas_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat #else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2766,7 +2766,7 @@ static Word16 SWB_BWE_encoding_fx( /* tilt returned in Q24 go to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat #else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); #endif @@ -2874,7 +2874,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ #endif @@ -2890,9 +2890,9 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat #else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) @@ -3243,7 +3243,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( /* tilt returned in Q24 go to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat #else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); #endif @@ -3352,7 +3352,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expd = norm_l( WB_tenv_syn_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat + den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat #else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); #endif @@ -3369,7 +3369,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ #endif @@ -3382,11 +3382,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat #else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) -- GitLab From d8b12bd40942478a6212ead1daeea06ee6e49667 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 16:23:48 +0200 Subject: [PATCH 28/80] some more _o replacements --- lib_enc/swb_bwe_enc_hr_fx.c | 9 +- lib_enc/swb_bwe_enc_lr_fx.c | 7 ++ lib_enc/swb_pre_proc_fx.c | 24 ++++ lib_enc/swb_tbe_enc_fx.c | 224 +++++++++++++++++++++++++++++++----- 4 files changed, 234 insertions(+), 30 deletions(-) diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index f510a1cb6..ba5362365 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -117,9 +117,11 @@ void swb_bwe_enc_hr_fx( #else Word32 L_t_audio_tmp_fx[L_FRAME48k]; #endif +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -767,12 +769,13 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( L_tmp, temp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shr_sat( L_tmp, temp2 ); //??sat + t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat #else L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); -#endif t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); +#endif move16(); } diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 3c92c7f89..90c7ef2be 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -698,9 +698,11 @@ static void gethar_noisegn_fx( Word16 temp_lo, temp_hi; Word16 Qg; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*Generate HF noise*/ genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow, @@ -783,8 +785,13 @@ static void gethar_noisegn_fx( L_temp = L_Comp( exp, frac ); L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat + g_fx = round_fx_sat( L_temp ); //??sat +#else L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); +#endif } gqlevs_fx = 4; diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 85277e298..ba7bb3ef6 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -523,9 +523,11 @@ void swb_pre_proc_fx( Word16 ts, nB, uB; /* Highband energy computation using CLDFB */ Word32 CldfbHB_ener; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif Word16 realQ_neg1, imagQ_neg1, exp, Cldfbtemp1; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -703,8 +705,13 @@ void swb_pre_proc_fx( realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ +#ifdef ISSUE_1867_replace_overflow_libenc + CldfbHB_ener = L_mac0_sat( CldfbHB_ener, realQ_neg1, realQ_neg1 ); //??sat + CldfbHB_ener = L_mac0_sat( CldfbHB_ener, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat +#else CldfbHB_ener = L_mac0_o( CldfbHB_ener, realQ_neg1, realQ_neg1, &Overflow ); CldfbHB_ener = L_mac0_o( CldfbHB_ener, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ +#endif } } @@ -1100,9 +1107,11 @@ void swb_pre_proc_ivas_fx( { Word32 CldfbHB_fx = 0; // fixed counterpart Word16 CldfbHB_fx_e = 0; // fixed counterpart +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif Word16 realQ_neg1, imagQ_neg1, exp = 0, Cldfbtemp1; move32(); @@ -1211,8 +1220,13 @@ void swb_pre_proc_ivas_fx( realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#ifdef ISSUE_1867_replace_overflow_libenc + CldfbHB_fx = L_mac0_sat( CldfbHB_fx, realQ_neg1, realQ_neg1 ); //??sat + CldfbHB_fx = L_mac0_sat( CldfbHB_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat +#else CldfbHB_fx = L_mac0_o( CldfbHB_fx, realQ_neg1, realQ_neg1, &Overflow ); CldfbHB_fx = L_mac0_o( CldfbHB_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ +#endif } } CldfbHB_fx_e = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); @@ -1246,8 +1260,13 @@ void swb_pre_proc_ivas_fx( { realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#ifdef ISSUE_1867_replace_overflow_libenc + icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, realQ_neg1, realQ_neg1 ); //??sat + icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat +#else icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, realQ_neg1, realQ_neg1, &Overflow ); icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ +#endif } } exp_icbweRefEner_fx = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); @@ -1266,8 +1285,13 @@ void swb_pre_proc_ivas_fx( realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#ifdef ISSUE_1867_replace_overflow_libenc + lbEner = L_mac0_sat( lbEner, realQ_neg1, realQ_neg1 ); //??sat + lbEner = L_mac0_sat( lbEner, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat +#else lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ +#endif } } exp_lbEner = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 986aa26a6..d8105b88a 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -745,9 +745,11 @@ void wb_tbe_enc_fx( Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*Word16 att = 32767;*/ @@ -1216,8 +1218,13 @@ void wb_tbe_enc_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat + tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat +#else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ +#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -1347,9 +1354,11 @@ void wb_tbe_enc_ivas_fx( Word16 dummy = 0; Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif move16(); @@ -1381,7 +1390,11 @@ void wb_tbe_enc_ivas_fx( FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); +#ifdef ISSUE_1867_replace_overflow_libenc + hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); //??sat +#else hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); +#endif move16(); i--; k++; @@ -1871,8 +1884,13 @@ void wb_tbe_enc_ivas_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat + tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat +#else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ +#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -2053,9 +2071,11 @@ void swb_tbe_enc_fx( Word16 tilt_para; Word16 Q_bwe_exc_fb; Word16 n_subfr_saturation; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; @@ -2523,8 +2543,13 @@ void swb_tbe_enc_fx( curr_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ //??sat + curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ //??sat +#else prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ curr_pow_fx = L_mac0_o( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], &Overflow ); /* 2*Q_bwe_exc */ +#endif } if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) @@ -2559,11 +2584,19 @@ void swb_tbe_enc_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -2572,11 +2605,19 @@ void swb_tbe_enc_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -2807,7 +2848,11 @@ void swb_tbe_enc_fx( /* sd_uq_q*pitBufAvg */ L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat +#else tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ +#endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -2995,9 +3040,11 @@ void swb_tbe_enc_ivas_fx( Word16 tilt_para_fx; Word16 Q_bwe_exc_fb; Word16 n_subfr_saturation; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif Env_error_fx = 0; @@ -3857,7 +3904,11 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } IF( exp < 0 ) @@ -3875,11 +3926,19 @@ void swb_tbe_enc_ivas_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -3888,11 +3947,19 @@ void swb_tbe_enc_ivas_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -4401,7 +4468,11 @@ void swb_tbe_enc_ivas_fx( /* sd_uq_q*pitBufAvg */ L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat +#else tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ +#endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); tmp = s_max( tmp, 19661 /*0.6f Q15*/ ); @@ -4556,9 +4627,11 @@ static void EstimateSHBFrameGain_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif move16(); @@ -4669,27 +4742,46 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_rsat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat +#else sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ +#endif } FOR( ; i < l_frame; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat +#else oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ +#endif } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat +#else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ +#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -4698,30 +4790,33 @@ static void EstimateSHBFrameGain_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = shl_sat( oriSHB[i], scaling ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = shl_sat( oriSHB[i], scaling ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = shl_o( oriSHB[i], scaling, &Overflow ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } } L_tmp = root_a_over_b_fx( oriNrg, 2 * Q_oriSHB, synNrg, 2 * Q_synSHB, &exp_out ); @@ -4757,9 +4852,11 @@ static void EstimateSHBFrameGain_ivas_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move16(); @@ -4870,27 +4967,46 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat +#else sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ +#endif } FOR( ; i < l_frame; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat +#else oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ +#endif } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat +#else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ +#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -4899,30 +5015,33 @@ static void EstimateSHBFrameGain_ivas_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = shl_sat( oriSHB[i], scaling ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = shl_sat( oriSHB[i], scaling ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = shl_o( oriSHB[i], scaling, &Overflow ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } } L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out ); @@ -5036,9 +5155,11 @@ static void EstimateSHBGainShape_fx( Word16 length_tmp; Word32 L_tmp, normFact; Word16 scaling = 0; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move32(); move16(); @@ -5157,25 +5278,49 @@ static void EstimateSHBGainShape_fx( FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif } FOR( k = 0; k < ( join_length - length ); k++ ) { sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif } FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ scaling = 0; @@ -5222,8 +5367,13 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat + L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat +#else subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ +#endif move16(); } @@ -5238,7 +5388,11 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ +#ifdef ISSUE_1867_replace_overflow_libenc + subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat +#else subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#endif move16(); } } @@ -5247,7 +5401,11 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ +#ifdef ISSUE_1867_replace_overflow_libenc + subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat +#else subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ +#endif move16(); } } @@ -6253,7 +6411,7 @@ static void determine_gain_weights_fx( Word16 j; Word16 exp, exp1, frac, tmp, exp2; Word32 L_tmp; -#ifndef ISSUE_1796_replace_shl_o +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -6279,8 +6437,8 @@ static void determine_gain_weights_fx( { exp2 = sub( exp, 2 ); } -#ifdef ISSUE_1796_replace_shl_o - weights[j] = shl_sat( tmp, exp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + weights[j] = shl_sat( tmp, exp2 ); //??sat #else weights[j] = shl_o( tmp, exp2, &Overflow ); #endif @@ -6887,9 +7045,11 @@ static void first_VQstages_fx( move16(); Word16 maxC = LSFMBEST; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*float dd[16];*/ @@ -6916,7 +7076,11 @@ static void first_VQstages_fx( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat +#else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ +#endif L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } @@ -7406,9 +7570,11 @@ void fb_tbe_enc_fx( Word16 tmp, tmp1, tmp2, exp, exp2, exp_norm; Word16 s_max_value, exp_temp, i; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif s_max_value = 0; FOR( i = 0; i < L_FRAME48k; i++ ) @@ -7444,7 +7610,11 @@ void fb_tbe_enc_fx( Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat +#else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ +#endif hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ @@ -7471,8 +7641,8 @@ void fb_tbe_enc_fx( tmp = div_s( tmp2, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ //??sat #else L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ #endif -- GitLab From 6a59848d0273c92c870a4a364517fed0dde8de32 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 16:27:17 +0200 Subject: [PATCH 29/80] clang patch --- lib_enc/swb_bwe_enc_hr_fx.c | 2 +- lib_enc/swb_bwe_enc_lr_fx.c | 4 +- lib_enc/swb_pre_proc_fx.c | 8 +- lib_enc/swb_tbe_enc_fx.c | 228 ++++++++++++++++++------------------ 4 files changed, 121 insertions(+), 121 deletions(-) diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index ba5362365..4467fb988 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -770,7 +770,7 @@ void swb_bwe_enc_hr_fx( { L_tmp = L_mult( temp, t_audio_fx[i] ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, temp2 ); //??sat + L_tmp = L_shr_sat( L_tmp, temp2 ); //??sat t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat #else L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 90c7ef2be..2dedbfbeb 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -784,9 +784,9 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat + L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat g_fx = round_fx_sat( L_temp ); //??sat #else L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index ba7bb3ef6..3fc87460e 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -706,7 +706,7 @@ void swb_pre_proc_fx( imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ #ifdef ISSUE_1867_replace_overflow_libenc - CldfbHB_ener = L_mac0_sat( CldfbHB_ener, realQ_neg1, realQ_neg1 ); //??sat + CldfbHB_ener = L_mac0_sat( CldfbHB_ener, realQ_neg1, realQ_neg1 ); //??sat CldfbHB_ener = L_mac0_sat( CldfbHB_ener, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat #else CldfbHB_ener = L_mac0_o( CldfbHB_ener, realQ_neg1, realQ_neg1, &Overflow ); @@ -1221,7 +1221,7 @@ void swb_pre_proc_ivas_fx( imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 16 ) ); /* Q(-1), headroom needed */ #ifdef ISSUE_1867_replace_overflow_libenc - CldfbHB_fx = L_mac0_sat( CldfbHB_fx, realQ_neg1, realQ_neg1 ); //??sat + CldfbHB_fx = L_mac0_sat( CldfbHB_fx, realQ_neg1, realQ_neg1 ); //??sat CldfbHB_fx = L_mac0_sat( CldfbHB_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat #else CldfbHB_fx = L_mac0_o( CldfbHB_fx, realQ_neg1, realQ_neg1, &Overflow ); @@ -1261,7 +1261,7 @@ void swb_pre_proc_ivas_fx( realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ #ifdef ISSUE_1867_replace_overflow_libenc - icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, realQ_neg1, realQ_neg1 ); //??sat + icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, realQ_neg1, realQ_neg1 ); //??sat icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat #else icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, realQ_neg1, realQ_neg1, &Overflow ); @@ -1286,7 +1286,7 @@ void swb_pre_proc_ivas_fx( imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ #ifdef ISSUE_1867_replace_overflow_libenc - lbEner = L_mac0_sat( lbEner, realQ_neg1, realQ_neg1 ); //??sat + lbEner = L_mac0_sat( lbEner, realQ_neg1, realQ_neg1 ); //??sat lbEner = L_mac0_sat( lbEner, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat #else lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index d8105b88a..5a07da3e9 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1219,7 +1219,7 @@ void wb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); @@ -1391,7 +1391,7 @@ void wb_tbe_enc_ivas_fx( { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); #ifdef ISSUE_1867_replace_overflow_libenc - hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); //??sat + hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); //??sat #else hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); #endif @@ -1885,11 +1885,11 @@ void wb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); - tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ + tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ #endif } @@ -2544,7 +2544,7 @@ void swb_tbe_enc_fx( FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ //??sat + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ //??sat curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ //??sat #else prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ @@ -2583,19 +2583,19 @@ void swb_tbe_enc_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -2606,17 +2606,17 @@ void swb_tbe_enc_fx( { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -2846,12 +2846,12 @@ void swb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat #else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif } @@ -3903,11 +3903,11 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -3925,19 +3925,19 @@ void swb_tbe_enc_ivas_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -3948,17 +3948,17 @@ void swb_tbe_enc_ivas_fx( { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -4466,12 +4466,12 @@ void swb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat #else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -4743,28 +4743,28 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_rsat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat + sig = mult_rsat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ #endif } FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ #endif } @@ -4772,15 +4772,15 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ #endif } IF( EQ_32( oriNrg, MAX_32 ) ) @@ -4791,7 +4791,7 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); @@ -4801,7 +4801,7 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); //??sat + sig = shl_sat( oriSHB[i], scaling ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = shl_o( oriSHB[i], scaling, &Overflow ); @@ -4811,11 +4811,11 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } } @@ -4968,28 +4968,28 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ #endif } FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat #else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ #endif } @@ -4997,13 +4997,13 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ #endif @@ -5016,7 +5016,7 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); @@ -5026,7 +5026,7 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); //??sat + sig = shl_sat( oriSHB[i], scaling ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = shl_o( oriSHB[i], scaling, &Overflow ); @@ -5036,11 +5036,11 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } } @@ -5277,33 +5277,33 @@ static void EstimateSHBGainShape_fx( j = i_mult2( join_length, i ); FOR( k = 0; k < length; k++ ) { - sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } FOR( k = 0; k < ( join_length - length ); k++ ) { - sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ + sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5311,15 +5311,15 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ @@ -5368,11 +5368,11 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat + subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ + subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ #endif move16(); } @@ -5387,9 +5387,9 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat + subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat #else subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ #endif @@ -5400,11 +5400,11 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat + subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ #endif move16(); } @@ -6438,7 +6438,7 @@ static void determine_gain_weights_fx( exp2 = sub( exp, 2 ); } #ifdef ISSUE_1867_replace_overflow_libenc - weights[j] = shl_sat( tmp, exp2 ); //??sat + weights[j] = shl_sat( tmp, exp2 ); //??sat #else weights[j] = shl_o( tmp, exp2, &Overflow ); #endif @@ -7077,12 +7077,12 @@ static void first_VQstages_fx( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_tmp, maxC ); @@ -7609,13 +7609,13 @@ void fb_tbe_enc_fx( Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ + temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat + temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat #else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ #endif - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ @@ -7642,9 +7642,9 @@ void fb_tbe_enc_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ //??sat + L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ //??sat #else - L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ + L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ #endif } ELSE -- GitLab From 6de84000e889d0fece8ec1e84a40f10afc01055b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 13 Aug 2025 16:34:57 +0200 Subject: [PATCH 30/80] clang patch --- lib_enc/swb_tbe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 5a07da3e9..1e393dbe1 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4743,7 +4743,7 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_rsat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat -- GitLab From 9faaff84a7cf6136ef79deefc5943d37ec201159 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 06:58:18 +0200 Subject: [PATCH 31/80] clang patch --- lib_enc/swb_tbe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 1e393dbe1..b861dda1c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4743,7 +4743,7 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat -- GitLab From 0c11a11b43f913d3a26b32d3dc068c9187aa29e5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 08:37:05 +0200 Subject: [PATCH 32/80] clang patch --- lib_enc/analy_sp_fx.c | 6 +++--- lib_enc/find_tilt_fx.c | 12 ++++++------ lib_enc/find_uv_fx.c | 4 ++-- lib_enc/hvq_enc_fx.c | 4 ++-- lib_enc/nois_est_fx.c | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 6b9d38316..fa91cec99 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -954,7 +954,7 @@ static void find_enr( #ifdef ISSUE_1867_replace_overflow_libenc *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ //??sat #else - *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ + *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ #endif move32(); /* scaled by Q_new + QSCALE - 2 */ BASOP_SATURATE_WARNING_ON_EVS; @@ -984,7 +984,7 @@ static void find_enr( #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 */ BASOP_SATURATE_WARNING_ON_EVS; @@ -1039,7 +1039,7 @@ static void find_enr( #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 */ BASOP_SATURATE_WARNING_ON_EVS; diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 0ec03bd83..2f00c34d1 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -194,7 +194,7 @@ void find_tilt_fx( #ifdef ISSUE_1867_replace_overflow_libenc lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ //??sat //??sat #else - lp_E = L_sub_o(L_shr_sat(m_tmp, sub(e_tmp, 1)), lp_bckr, &Overflow); /* Q_new + QSCALE */ + lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ @@ -226,7 +226,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_sat(m_tmp, add(e_tmp, 15 - 6)); /* ee in Q6 */ + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #endif } ELSE IF( lp_E == 0 ) @@ -380,8 +380,8 @@ void find_tilt_ivas_fx( Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 //??sat mean_voi = round_fx_sat( Ltmp ); // Q15 //??sat #else - Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 - mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 + Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 + mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 #endif /*f0 = INT_FS_FX / pitch[2];*/ @@ -505,12 +505,12 @@ void find_tilt_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif move32(); } - IF(bwidth == NB) /* For NB input, compensate for the missing bands */ + IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ //??sat diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index bf53ef201..4d8922ad8 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -698,10 +698,10 @@ Word16 find_uv_ivas_fx( /* o : coding typ #ifdef ISSUE_1799_replace_L_shr_o fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ #else - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ + fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ #endif - if (GT_32(fac_32, dE1)) + if ( GT_32( fac_32, dE1 ) ) { ind_deltaMax = i; move16(); diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 97b48770f..8f9648208 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -151,11 +151,11 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add(19 - (15 + 16), expNfpe3); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else - adjust = add(19 - (15 + 16), expNfpe3); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 2a9e7290c..bbada46d5 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1305,7 +1305,7 @@ void noise_est_fx( #ifdef ISSUE_1867_replace_overflow_libenc alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -1346,8 +1346,8 @@ void noise_est_fx( L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else - L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ - L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ + L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ + L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */ @@ -1392,7 +1392,7 @@ void noise_est_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else - L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ + L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ { @@ -2628,7 +2628,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 //??sat #else - noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 + noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif } -- GitLab From e4c1da2f584a6225645bb92d0336a3b2ad85e4c5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 09:33:50 +0200 Subject: [PATCH 33/80] buildfix --- lib_com/options.h | 2 +- lib_enc/find_tilt_fx.c | 4 ---- lib_enc/find_uv_fx.c | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 24c6a9898..156434b1d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -76,6 +76,7 @@ #define ISSUE_1796_replace_shl_o /* FhG: replace shl_ro by overflow-free alternatives - BE*/ #define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives - BE */ #define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ +#define ISSUE_1867_replace_overflow_libenc /* FhG: BE - replace overflow operators by non-overflow-alternatives all over the lib_enc module */ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ @@ -99,7 +100,6 @@ #define NONBE_FIX_ISM_XOVER_BR /* FhG: issue 1072: select OSBA coding method depending on number of object and bitrate */ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ -#define ISSUE_1867_replace_overflow_libenc /* FhG: BE - replace overflow operators by non-overflow-alternatives all over the lib_enc module */ #define FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR /* issue 1068 : Memory leak in MC to BINAURAL_ROOM decoding with bitrate switching*/ #define NONBE_FIX_1052_SBA_EXT /* Dlb: SBA external output support */ diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 2f00c34d1..a0fef9f92 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -502,11 +502,7 @@ void find_tilt_ivas_fx( m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); -#ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ -#endif move32(); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 4d8922ad8..09bef73ea 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -695,11 +695,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); -#ifdef ISSUE_1799_replace_L_shr_o fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ -#else - fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ -#endif if ( GT_32( fac_32, dE1 ) ) { -- GitLab From 7750ed7cd1d67adb2ecb1215dd6b2214bb6df9e2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 10:20:10 +0200 Subject: [PATCH 34/80] some more _o replacements --- lib_enc/tcx_ltp_enc_fx.c | 48 +++++++++++++- lib_enc/tcx_utils_enc_fx.c | 16 +++++ lib_enc/tns_base_enc_fx.c | 12 ++++ lib_enc/transition_enc_fx.c | 25 ++++++++ lib_enc/vad_fx.c | 58 +++++++++++++++++ lib_enc/vad_param_updt_fx.c | 7 +++ lib_enc/vbr_average_rate_fx.c | 6 ++ lib_enc/vlpc_2st_cod_fx.c | 6 ++ lib_enc/voiced_enc_fx.c | 115 ++++++++++++++++++++++++++++++++-- 9 files changed, 288 insertions(+), 5 deletions(-) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index a069f99b4..e83785e10 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -542,7 +542,11 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra ener = L_shl( ener, tmp ); s2 = sub( s2, tmp ); +#ifdef ISSUE_1867_replace_overflow_libenc + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat +#else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); +#endif BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1796_replace_shl_o g = shl_sat( g, sub( s1, s2 ) ); @@ -552,7 +556,11 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra BASOP_SATURATE_WARNING_ON_EVS /* Quantize gain */ +#ifdef ISSUE_1867_replace_overflow_libenc + g = shr( sub_sat( g, 0x1000 ), 13 ); //??sat +#else g = shr( sub_o( g, 0x1000, &Overflow ), 13 ); +#endif g = s_max( g, -1 ); *gain_index = g; @@ -567,9 +575,11 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec { Word32 corr, ener; Word16 i, g, s1, s2, tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif s1 = sub( getScaleFactor16( speech, L_frame ), 4 ); @@ -597,9 +607,13 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec ener = L_shl( ener, tmp ); s2 = sub( s2, tmp ); +#ifdef ISSUE_1867_replace_overflow_libenc + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat +#else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); +#endif BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1796_replace_shl_o +#ifdef ISSUE_1867_replace_overflow_libenc g = shl_sat( g, sub( s1, s2 ) ); /*Q15*/ #else g = shl_o( g, sub( s1, s2 ), &Overflow ); /*Q15*/ @@ -655,10 +669,12 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, Word16 buf_zir[M + L_SUBFR], *zir; Word16 Aest[M + 1]; Word16 alpha, step; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif norm_corr = 0; @@ -819,10 +835,18 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); //??sat //??sat //??sat +#else speech_ltp[n] = sub_o( speech[n], mult_ro( *gain, mult_ro( alpha, pred_speech[n], &Overflow ), &Overflow ), &Overflow ); +#endif move16(); BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef ISSUE_1867_replace_overflow_libenc + alpha = add_sat( alpha, step ); //??sat +#else alpha = add_o( alpha, step, &Overflow ); +#endif BASOP_SATURATE_WARNING_ON_EVS; } } @@ -873,7 +897,11 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); //??sat //??sat //??sat +#else speech_ltp[n] = add_o( sub_o( speech[n], mult_ro( *gain, pred_speech[n], &Overflow ), &Overflow ), zir[n], &Overflow ); +#endif move16(); } } @@ -891,7 +919,11 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, { FOR( n = L_subfr; n < L_frame; n++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); //??sat +#else speech_ltp[n] = sub_o( speech[n], mult( *gain, pred_speech[n] ), &Overflow ); +#endif move16(); } } @@ -934,8 +966,10 @@ void tcx_ltp_encode_ivas_fx( Word16 Aest_fx[M + 1]; Word16 exponent; Word16 sqr; +#ifndef ISSUE_1867_replace_overflow_libenc Flag Overflow = 0; move32(); +#endif TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; @@ -1230,7 +1264,11 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); //??sat //??sat //??sat +#else speech_ltp_fx[n] = sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, mult_ro( alpha_fx, pred_speech_fx[n], &Overflow ), &Overflow ), &Overflow ); +#endif move16(); alpha_fx = add_sat( alpha_fx, step_fx ); } @@ -1280,7 +1318,11 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); //??sat //??sat //??sat +#else speech_ltp_fx[n] = add_o( sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, pred_speech_fx[n], &Overflow ), &Overflow ), zir_fx[n], &Overflow ); +#endif move16(); } } @@ -1298,7 +1340,11 @@ void tcx_ltp_encode_ivas_fx( { FOR( n = L_subfr; n < L_frame; n++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); //??sat +#else speech_ltp_fx[n] = sub_o( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ), &Overflow ); +#endif move16(); } } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 0face2cf4..debd2fa12 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -287,21 +287,31 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 { Word16 i, tmp; Word32 threshold; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif threshold = 256l /*0.1f * 2*NORM_MDCT_FACTOR Q3*/; /* Q3 */ move32(); BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ +#ifdef ISSUE_1867_replace_overflow_libenc + threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); //??sat +#else threshold = L_shl_o( threshold, sub( 28, powerSpec_e ), &Overflow ); +#endif IF( rectWin != 0 ) { /* compensate for bad side-lobe attenuation with asymmetric windows */ +#ifdef ISSUE_1867_replace_overflow_libenc + threshold = L_shl_sat( threshold, 1 ); //??sat +#else threshold = L_shl_o( threshold, 1, &Overflow ); +#endif } BASOP_SATURATE_WARNING_ON_EVS @@ -2517,9 +2527,11 @@ void tcx_noise_factor_ivas_fx( Word16 att; /* noise level attenuation factor for transient windows */ Word32 xMax; Word16 exp_spQ[N_MAX]; +#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif assert( nTransWidth <= 16 ); @@ -2774,7 +2786,11 @@ void tcx_noise_factor_ivas_fx( tmp4 = BASOP_Util_Divide3232_Scale_newton( Mpy_32_16_1( sqErrorNrg, att ), n, &s ); s = add( add( exp_sqErrorNrg, -15 ), s ); BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef ISSUE_1867_replace_overflow_libenc + tmp4 = L_shl_sat( tmp4, s ); //??sat +#else tmp4 = L_shl_o( tmp4, s, &Overflow ); +#endif BASOP_SATURATE_WARNING_ON_EVS; } ELSE diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 05b35813a..d7fa139cd 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -76,9 +76,11 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, Word16 idx1; Word16 nSubdivisions; Word16 iSubdivisions; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move16(); @@ -125,7 +127,11 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef ISSUE_1867_replace_overflow_libenc + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat +#else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); +#endif BASOP_SATURATE_WARNING_ON_EVS; /* get pre-shift for autocorrelation */ @@ -441,9 +447,11 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur Word16 idx1; Word16 nSubdivisions; Word16 iSubdivisions; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move16(); @@ -490,7 +498,11 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; +#ifdef ISSUE_1867_replace_overflow_libenc + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat +#else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); +#endif BASOP_SATURATE_WARNING_ON_EVS; /* get pre-shift for autocorrelation */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 76f1485b7..3776ded48 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2187,9 +2187,11 @@ static void gain_trans_enc_fx( ) { Word16 i, imax, istart, tmp16, gain_trans, gscale; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif istart = 0; @@ -2198,11 +2200,19 @@ static void gain_trans_enc_fx( move16(); gscale = 7; move16(); +#ifdef ISSUE_1867_replace_overflow_libenc + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ //??sat +#else gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ +#endif IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ //??sat +#else gain_trans = extract_h( L_shl_o( gain_trans32, 16 - 3, &Overflow ) ); /* Q4 */ +#endif istart = 4; move16(); imax = N_GAIN_TC - 1; @@ -2235,7 +2245,11 @@ static void gain_trans_enc_fx( FOR( i = 0; i < L_SUBFR; i++ ) { /*exc[i] *= (*gain_trans);*/ +#ifdef ISSUE_1867_replace_overflow_libenc + exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); //??sat //??sat +#else exc[i] = round_fx_o( L_shl_o( L_mult( exc[i], gain_trans ), tmp16, &Overflow ), &Overflow ); +#endif move16(); } } @@ -2258,9 +2272,11 @@ void tc_classif_enc_fx( { Word32 temp; Word16 T_op, i; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif T_op = pitch; @@ -2336,7 +2352,11 @@ void tc_classif_enc_fx( L_sum = L_mac_sat( 1L, res[0], res[0] ); FOR( i = 1; i < len; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_sum = L_mac0_sat( L_sum, res[i], res[i] ); //??sat +#else L_sum = L_mac0_o( L_sum, res[i], res[i], &Overflow ); +#endif } aver = L_sum; /*Q = 2*Q_new */ move32(); @@ -2349,8 +2369,13 @@ void tc_classif_enc_fx( L_temp1 = Mult_32_16( temp, 8192 ); /* Q=31-exp */ test(); +#ifdef ISSUE_1867_replace_overflow_libenc + IF( GT_32( temp2, L_shl_sat( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && //??sat + LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) //??sat +#else IF( GT_32( temp2, L_shl_o( L_temp2, ( 31 - exp2 ) - ( 31 - exp ), &Overflow ) ) && LT_32( aver, L_shl_o( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ), &Overflow ) ) ) +#endif { *position = position_tmp; move16(); diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index c70865a81..2dcc6c3eb 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -208,9 +208,11 @@ static void sign_thr_snr_acc_fx( { /*if( snr >= sign_thr ) */ Word32 L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif L_tmp = L_deposit_l( min_snr ); @@ -219,7 +221,11 @@ static void sign_thr_snr_acc_fx( L_tmp = L_add( L_snr, 0 ); /* Q4 */ } BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ +#ifdef ISSUE_1867_replace_overflow_libenc + *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); /* Q4 */ //??sat +#else *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ +#endif move32(); BASOP_SATURATE_WARNING_ON_EVS } @@ -695,9 +701,11 @@ Word16 wb_vad_fx( Word32 L_accum_ener_H; Word16 vad_bwidth_fx; Word16 last_7k2_coder_type; +#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif if ( hNoiseEst == NULL ) @@ -1047,19 +1055,35 @@ Word16 wb_vad_fx( #endif IF( LT_16( i, 2 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( tmp, delta1 ); /*Q13 */ //??sat +#else tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ +#endif } ELSE IF( LT_16( i, 7 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( tmp, delta2 ); /*Q13 */ //??sat +#else tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ +#endif } ELSE IF( LT_16( i, 18 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( tmp, delta3 ); /*Q13 */ //??sat +#else tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ +#endif } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( tmp, delta4 ); /*Q13 */ //??sat +#else tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ +#endif } tmp1 = tmp; @@ -1067,7 +1091,11 @@ Word16 wb_vad_fx( sub( 0, 0 ); if ( LT_16( i, 7 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ //??sat +#else tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ +#endif } tmp = s_min( tmp, 16384 ); /* Q13, ftmp = min(ftmp, 2.0f); */ @@ -1151,11 +1179,19 @@ Word16 wb_vad_fx( /* accumulate background noise energy in bands [0-2] and in bands [3-19]*/ IF( LT_16( i, 3 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat +#else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ +#endif } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat +#else L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ +#endif } /* Identify the outlier band */ @@ -1249,7 +1285,11 @@ Word16 wb_vad_fx( } } /*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/ +#ifdef ISSUE_1867_replace_overflow_libenc + hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ //??sat +#else hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/ +#endif move32(); /* snr_sum_ol = 10.0f * (float)log10( snr_sum_ol ); */ @@ -1363,7 +1403,11 @@ Word16 wb_vad_fx( thr1_ol = thr1; move16(); L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ //??sat +#else tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ +#endif IF( L_tmp2 > 0 ) { thr1_ol = add( thr1_ol, tmp2 ); /* Q24 >>16 + Q8 */ @@ -1933,9 +1977,11 @@ Word16 wb_vad_ivas_fx( Word16 last_7k2_coder_type; Word16 q_shift, q_ener, q_diff1, q_diff2; Word16 q_L_snr_sum_ol, e_snr, f_snr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 L_msnr_e = 0, L_mssnr_e = 0, L_mssnr_hov_e = 0, L_msnr18_e = 0, L_msnr19_e = 0; move16(); /*L_msnr_e*/ @@ -2401,11 +2447,19 @@ Word16 wb_vad_ivas_fx( /* accumulate background noise energy in bands [0-2] and in bands [3-19]*/ IF( LT_16( i, 3 ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ +#else + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ +#endif } ELSE { +#ifdef ISSUE_1867_replace_overflow_libenc + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ //??sat +#else L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ +#endif } /* Identify the outlier band */ @@ -2419,7 +2473,11 @@ Word16 wb_vad_ivas_fx( move16(); } } /* end of band loop */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 //??sat +#else L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 +#endif snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4 diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index 464903a03..5df777796 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -34,9 +34,11 @@ void vad_param_updt_fx( Word16 i, ini_frame, corr_shift_temp[2]; VAD_HANDLE hVAD; DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif corr_shift_temp[0] = corr_shift; /*Q15*/ @@ -165,8 +167,13 @@ void vad_param_updt_fx( L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ //??sat + voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ //??sat +#else L_tmp = L_mac_o( L_tmp, corr_shift_temp[i], 32767, &Overflow ); /*Q15 */ voice_tmp = round_fx_o( L_tmp, &Overflow ); /*Q15 */ +#endif /* abs(pitch[0] - *pitO) + abs(pitch[1] - pitch[0]) + abs(pitch[2] - pitch[1]) */ pitch_tmp = abs_s( sub( st_fx->pitch[0], old_pitch1 ) ); /*Q0 */ diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index 28371b2d7..ec5d71989 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -49,9 +49,11 @@ void update_average_rate_fx( Word16 tmp; Word32 L_tmp; Word32 L_tmp1, L_tmp2; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 exp, recip, Qrecip; @@ -258,7 +260,11 @@ void update_average_rate_fx( /* sum the total number of bits (in kbytes) * 10 here */ /*st->sum_of_rates += (hSC_VBR->core_brate / 1000.0f) * 10; */ L_tmp = L_shl( Mult_32_16( core_brate_fx, 20972 ), 7 ); /*Q13*/ +#ifdef ISSUE_1867_replace_overflow_libenc + hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); //??sat +#else hSC_VBR->sum_of_rates_fx = L_add_o( hSC_VBR->sum_of_rates_fx, L_tmp, &Overflow ); +#endif move32(); return; } diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index 2ea4df5a9..346117dcb 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -30,10 +30,12 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits Word16 nq, xq[M]; Word32 L_tmp; Word16 gap; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif /* 0 bit with true weighting: save 0.5 bit */ @@ -57,7 +59,11 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturate because we only need to know if the result is smaller than 8.0f */ FOR( i = 1; i < M; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ //??sat +#else L_tmp = L_mac_o( L_tmp, x[i], x[i], &Overflow ); /*10Q21*/ +#endif } BASOP_SATURATE_WARNING_ON_EVS diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 0de0285d5..421644494 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -122,9 +122,11 @@ ivas_error ppp_voiced_encoder_fx( Word32 low_band_en_fx; Word32 curr_Engy, prev_Engy; Word16 temp_Fs; +#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif DTFS_STRUCTURE *CURRP_NQ_FX; DTFS_STRUCTURE *TMPDTFS_FX; @@ -567,7 +569,11 @@ ivas_error ppp_voiced_encoder_fx( /*if ( res_enratio > 5.0 && tmp < 0.65 ) */ /* 5 in Q11, 0.65 in Q15 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q31 */ test(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) //??sat +#else if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 31, Qtmp ), &Overflow ) ), 21299 ) ) ) +#endif { PPP_MODE_E = 'B'; move16(); @@ -578,7 +584,11 @@ ivas_error ppp_voiced_encoder_fx( /* if ( res_enratio > 3.0 && tmp < 1.2 ) */ /*3 in Q11, 1.2 in Q14 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q14 */ test(); +#ifdef ISSUE_1867_replace_overflow_libenc + if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) //??sat +#else if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 30, Qtmp ), &Overflow ) ), 19661 ) ) ) +#endif { PPP_MODE_E = 'B'; move16(); @@ -596,7 +606,11 @@ ivas_error ppp_voiced_encoder_fx( #endif { /* if (res_enratio < 0.025) */ +#ifdef ISSUE_1867_replace_overflow_libenc + IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat +#else IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ +#endif { hSC_VBR->bump_up = 1; move16(); @@ -612,7 +626,11 @@ ivas_error ppp_voiced_encoder_fx( ELSE { /* if ( res_enratio < 0.092f) */ +#ifdef ISSUE_1867_replace_overflow_libenc + if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat +#else if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ +#endif { hSC_VBR->bump_up = 1; move16(); @@ -621,8 +639,8 @@ ivas_error ppp_voiced_encoder_fx( /* if (min(res_enratio, sp_enratio) < 0.075 && tmp < -0.5f)) : 2458 = 0.075 in Q15 */ test(); -#ifdef ISSUE_1796_replace_shl_o - if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) +#ifdef ISSUE_1867_replace_overflow_libenc + if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) //??sat #else if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_o( -1, sub( Qtmp, 1 ), &Overflow ) ) ) #endif @@ -748,7 +766,11 @@ ivas_error ppp_voiced_encoder_fx( Ltemp1 = L_negate( Ltemp1 ); } expa = norm_l( Ltemp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + fraca = extract_h( L_shl( Ltemp2, expa ) ); +#else fraca = extract_h( L_shl_o( Ltemp2, expa, &Overflow ) ); +#endif expa = sub( 30, expa ); expb = norm_l( Ltemp1 ); @@ -765,7 +787,11 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); //??sat +#else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); +#endif /*-------------------------------------------*/ sp_hb_enratio_fx = L_add( Ltemp_fx, 0 ); /* Q29 */ } @@ -789,7 +815,11 @@ ivas_error ppp_voiced_encoder_fx( move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_NQ_FX->Q, 1 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat +#else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ +#endif /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16( hSC_VBR->prev_cw_en_fx, 26214 ); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ @@ -898,7 +928,11 @@ ivas_error ppp_voiced_encoder_fx( /* compute energy of impz */ FOR( x_fx = 0; x_fx < 160; x_fx++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); //??sat +#else energy_impz_fx = L_add_o( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ), &Overflow ); +#endif } /*energy_impz = (float)(10*log10((float)energy_impz)); */ @@ -912,7 +946,11 @@ ivas_error ppp_voiced_encoder_fx( Ltmp_32 = DTFS_getEngy_fx( CURRP_Q_E_FX ); /*Q = 2*(CURRP_Q_E_FX->Q) */ move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_Q_E_FX->Q, 1 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ //??sat +#else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ +#endif /* if ((DTFS_getEngy(*CURRP_Q_E) > st->prev_cw_en)&&(max(pos_q,neg_q)>3.5) && energy_impz>15.0 && tmpres>0.7) */ test(); test(); @@ -980,7 +1018,11 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); /* tmp in Q15 */ exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat +#else Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ +#endif } test(); IF( GT_32( Ltemp_fx, 6710886 ) && ( !hSC_VBR->rate_control ) ) /* 0.05 in Q27 = 6710886 */ @@ -1016,7 +1058,11 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat +#else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ +#endif } /*-------------------------------------------*/ @@ -1084,7 +1130,11 @@ ivas_error ppp_voiced_encoder_fx( exp = sub( 30, add( expa, sub( 31, exp ) ) ); frac = Log2_norm_lc( L_tmp ); L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat +#else Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ +#endif } ELSE { @@ -1271,9 +1321,11 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ { Word32 acc; Word16 i, j; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif FOR( i = 0; i < N; i++ ) { @@ -1283,17 +1335,27 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ FOR( j = P - 1; j > 0; j-- ) { /* acc = L_sub(acc, L_mult(memory[j], coef[j])); */ +#ifdef ISSUE_1867_replace_overflow_libenc + acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat +#else acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ +#endif buf[j] = buf[j - 1]; move16(); } /* acc = L_sub(acc, L_mult(memory[0], coef[0])); */ +#ifdef ISSUE_1867_replace_overflow_libenc + acc = L_msu_sat( acc, buf[0], b[0] ); //??sat + acc = L_shl_sat( acc, 3 ); //??sat + *y++ = round_fx_sat( acc ); //??sat + buf[0] = round_fx_sat( acc ); //??sat +#else acc = L_msu_o( acc, buf[0], b[0], &Overflow ); acc = L_shl_o( acc, 3, &Overflow ); - *y++ = round_fx_o( acc, &Overflow ); - move16(); buf[0] = round_fx_o( acc, &Overflow ); +#endif + move16(); move16(); } } @@ -1337,9 +1399,11 @@ static Word32 DTFS_freq_corr_fx( Word16 exp, tmp; Word32 L_tmp; Word16 Q_num, Q_den; +#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif IF( LT_16( X1_DTFS_fx.lag_fx, X2_DTFS_fx.lag_fx ) ) { @@ -1375,8 +1439,13 @@ static Word32 DTFS_freq_corr_fx( FOR( k = lk; k < hk; k++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ //??sat + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ //??sat +#else corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ); /* Q(1) */ corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ); /* Q(1) */ +#endif } Qr = norm_l( corr_fx ); @@ -1386,7 +1455,11 @@ static Word32 DTFS_freq_corr_fx( move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ //??sat //??sat +#else E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ +#endif Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ Q_num = sub( shl( add( add( X1_DTFS_fx.Q, X2_DTFS_fx.Q ), Qr ), 1 ), 32 ); @@ -1400,7 +1473,11 @@ static Word32 DTFS_freq_corr_fx( move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ //??sat //??sat +#else E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ +#endif /* PORTING: Handling the functions with variable no. of arguments */ E_fx = DTFS_getEngy_band_fx( X2_DTFS_fx, lband, hband ); /* Q(1) */ q2 = norm_l( E_fx ); @@ -1410,7 +1487,11 @@ static Word32 DTFS_freq_corr_fx( move16(); } +#ifdef ISSUE_1867_replace_overflow_libenc + E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ //??sat //??sat +#else E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ +#endif Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ Q_den = sub( add( shl( add( X2_DTFS_fx.Q, X1_DTFS_fx.Q ), 1 ), add( q1, q2 ) ), 32 ); @@ -1427,12 +1508,20 @@ static Word32 DTFS_freq_corr_fx( { expa = norm_l( Num ); +#ifdef ISSUE_1867_replace_overflow_libenc + fraca = extract_h( L_shl_sat( Num, expa ) ); //??sat +#else fraca = extract_h( L_shl_o( Num, expa, &Overflow ) ); +#endif expa = sub( 30, add( expa, Q_num ) ); expb = norm_l( Den ); +#ifdef ISSUE_1867_replace_overflow_libenc + fracb = round_fx_sat( L_shl( Den, expb ) ); //??sat +#else fracb = round_fx_o( L_shl_o( Den, expb, &Overflow ), &Overflow ); +#endif expb = sub( 30, add( expb, Q_den ) ); @@ -1485,9 +1574,11 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) { Word16 j, k, idx, Adiff_fx; Word32 maxcorr, corr; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif maxcorr = L_add( MIN_32, 0 ); Adiff_fx = (Word16) ( s_max( 4, shr( lag, 3 ) ) ); @@ -1499,7 +1590,11 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) corr = L_deposit_l( 0 ); FOR( k = 0; k < lag; k++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); //??sat +#else corr = L_mac_o( corr, x1[k], x2[( k - j + lag ) % lag], &Overflow ); +#endif } IF( GT_32( corr, maxcorr ) ) { @@ -1542,9 +1637,11 @@ static Word32 DTFS_getEngy_band_fx( Word32 freq_fx, L_lband, L_hband; Word32 en_fx = 0; move32(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif L_lband = L_mult( lband, X_fx.lag_fx ); /* Q0 * Q0 -> Q1 */ L_hband = L_mult( hband, X_fx.lag_fx ); /* Q0 * Q0 -> Q1 */ @@ -1573,8 +1670,13 @@ static Word32 DTFS_getEngy_band_fx( FOR( k = lk; k < hk; k++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ //??sat + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat +#else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); /* 2*X1.Q+1 */ en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); +#endif } if ( lband == 0 ) @@ -1586,8 +1688,13 @@ static Word32 DTFS_getEngy_band_fx( test(); IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && ( hband == X_fx.upper_cut_off_freq_fx ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); //??sat + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat +#else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); +#endif } return en_fx; /* 2*X1.Q */ -- GitLab From 37585f2191e6601b4dd08d3c5f12fe4567483fbd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 11:19:02 +0200 Subject: [PATCH 35/80] clang format patch --- lib_enc/find_tilt_fx.c | 2 +- lib_enc/tcx_ltp_enc_fx.c | 20 ++++---- lib_enc/tcx_utils_enc_fx.c | 6 +-- lib_enc/tns_base_enc_fx.c | 4 +- lib_enc/transition_enc_fx.c | 12 ++--- lib_enc/vad_fx.c | 53 ++++++++++---------- lib_enc/vad_param_updt_fx.c | 4 +- lib_enc/vbr_average_rate_fx.c | 2 +- lib_enc/vlpc_2st_cod_fx.c | 2 +- lib_enc/voiced_enc_fx.c | 91 ++++++++++++++++++----------------- 10 files changed, 99 insertions(+), 97 deletions(-) diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index a0fef9f92..4c3c3c914 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -511,7 +511,7 @@ void find_tilt_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ //??sat #else - Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ + Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ #endif IF( EQ_32( Ltmp, MAX_32 ) ) /* if Overflow: Compute with less precision */ { diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index e83785e10..cbf5fbb70 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -543,7 +543,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra s2 = sub( s2, tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat #else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif @@ -557,7 +557,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra /* Quantize gain */ #ifdef ISSUE_1867_replace_overflow_libenc - g = shr( sub_sat( g, 0x1000 ), 13 ); //??sat + g = shr( sub_sat( g, 0x1000 ), 13 ); //??sat #else g = shr( sub_o( g, 0x1000, &Overflow ), 13 ); #endif @@ -608,7 +608,7 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec s2 = sub( s2, tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat #else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif @@ -836,14 +836,14 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); //??sat //??sat //??sat + speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); //??sat //??sat //??sat #else speech_ltp[n] = sub_o( speech[n], mult_ro( *gain, mult_ro( alpha, pred_speech[n], &Overflow ), &Overflow ), &Overflow ); #endif move16(); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - alpha = add_sat( alpha, step ); //??sat + alpha = add_sat( alpha, step ); //??sat #else alpha = add_o( alpha, step, &Overflow ); #endif @@ -898,7 +898,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); //??sat //??sat //??sat + speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); //??sat //??sat //??sat #else speech_ltp[n] = add_o( sub_o( speech[n], mult_ro( *gain, pred_speech[n], &Overflow ), &Overflow ), zir[n], &Overflow ); #endif @@ -920,7 +920,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = L_subfr; n < L_frame; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); //??sat + speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); //??sat #else speech_ltp[n] = sub_o( speech[n], mult( *gain, pred_speech[n] ), &Overflow ); #endif @@ -1265,7 +1265,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); //??sat //??sat //??sat + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); //??sat //??sat //??sat #else speech_ltp_fx[n] = sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, mult_ro( alpha_fx, pred_speech_fx[n], &Overflow ), &Overflow ), &Overflow ); #endif @@ -1319,7 +1319,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); //??sat //??sat //??sat + speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); //??sat //??sat //??sat #else speech_ltp_fx[n] = add_o( sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, pred_speech_fx[n], &Overflow ), &Overflow ), zir_fx[n], &Overflow ); #endif @@ -1341,7 +1341,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = L_subfr; n < L_frame; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); //??sat + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); //??sat #else speech_ltp_fx[n] = sub_o( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ), &Overflow ); #endif diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index debd2fa12..5e66b33f4 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -299,7 +299,7 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 move32(); BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ #ifdef ISSUE_1867_replace_overflow_libenc - threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); //??sat + threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); //??sat #else threshold = L_shl_o( threshold, sub( 28, powerSpec_e ), &Overflow ); #endif @@ -308,7 +308,7 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 { /* compensate for bad side-lobe attenuation with asymmetric windows */ #ifdef ISSUE_1867_replace_overflow_libenc - threshold = L_shl_sat( threshold, 1 ); //??sat + threshold = L_shl_sat( threshold, 1 ); //??sat #else threshold = L_shl_o( threshold, 1, &Overflow ); #endif @@ -2787,7 +2787,7 @@ void tcx_noise_factor_ivas_fx( s = add( add( exp_sqErrorNrg, -15 ), s ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp4 = L_shl_sat( tmp4, s ); //??sat + tmp4 = L_shl_sat( tmp4, s ); //??sat #else tmp4 = L_shl_o( tmp4, s, &Overflow ); #endif diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index d7fa139cd..568f312f1 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -128,7 +128,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat #else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); #endif @@ -499,7 +499,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat #else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); #endif diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 3776ded48..f827bb201 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2201,15 +2201,15 @@ static void gain_trans_enc_fx( gscale = 7; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ //??sat + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ //??sat #else - gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ + gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ #endif IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ //??sat + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ //??sat #else gain_trans = extract_h( L_shl_o( gain_trans32, 16 - 3, &Overflow ) ); /* Q4 */ #endif @@ -2246,7 +2246,7 @@ static void gain_trans_enc_fx( { /*exc[i] *= (*gain_trans);*/ #ifdef ISSUE_1867_replace_overflow_libenc - exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); //??sat //??sat + exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); //??sat //??sat #else exc[i] = round_fx_o( L_shl_o( L_mult( exc[i], gain_trans ), tmp16, &Overflow ), &Overflow ); #endif @@ -2353,7 +2353,7 @@ void tc_classif_enc_fx( FOR( i = 1; i < len; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_sum = L_mac0_sat( L_sum, res[i], res[i] ); //??sat + L_sum = L_mac0_sat( L_sum, res[i], res[i] ); //??sat #else L_sum = L_mac0_o( L_sum, res[i], res[i], &Overflow ); #endif @@ -2371,7 +2371,7 @@ void tc_classif_enc_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc IF( GT_32( temp2, L_shl_sat( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && //??sat - LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) //??sat + LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) //??sat #else IF( GT_32( temp2, L_shl_o( L_temp2, ( 31 - exp2 ) - ( 31 - exp ), &Overflow ) ) && LT_32( aver, L_shl_o( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ), &Overflow ) ) ) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 2dcc6c3eb..3a3efd20a 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -220,11 +220,12 @@ static void sign_thr_snr_acc_fx( { L_tmp = L_add( L_snr, 0 ); /* Q4 */ } - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc - *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); /* Q4 */ //??sat + *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); + /* Q4 */ //??sat #else - *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ + *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif move32(); BASOP_SATURATE_WARNING_ON_EVS @@ -1051,38 +1052,38 @@ Word16 wb_vad_fx( #ifdef ISSUE_1796_replace_shl_o tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ #else - tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ + tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ #endif IF( LT_16( i, 2 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta1 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta1 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ #endif } ELSE IF( LT_16( i, 7 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta2 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta2 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ #endif } ELSE IF( LT_16( i, 18 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta3 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta3 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta4 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta4 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ #endif } @@ -1092,9 +1093,9 @@ Word16 wb_vad_fx( if ( LT_16( i, 7 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ //??sat + tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ //??sat #else - tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ + tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #endif } @@ -1180,17 +1181,17 @@ Word16 wb_vad_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat #else - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat #else - L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ + L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif } @@ -1286,7 +1287,7 @@ Word16 wb_vad_fx( } /*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ //??sat + hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ //??sat #else hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/ #endif @@ -1404,9 +1405,9 @@ Word16 wb_vad_fx( move16(); L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ //??sat + tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ //??sat #else - tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ + tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #endif IF( L_tmp2 > 0 ) { @@ -2450,15 +2451,15 @@ Word16 wb_vad_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #else - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ //??sat + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ //??sat #else - L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ + L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ #endif } @@ -2472,11 +2473,11 @@ Word16 wb_vad_ivas_fx( move16(); move16(); } - } /* end of band loop */ + } /* end of band loop */ #ifdef ISSUE_1867_replace_overflow_libenc L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 //??sat #else - L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 + L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 #endif snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4 diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index 5df777796..da724a781 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -166,9 +166,9 @@ void vad_param_updt_fx( /* (voicing[0] + voicing[1] + voicing[2]) / 3 + corr_shift */ L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); - L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ + L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ //??sat + L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ //??sat voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ //??sat #else L_tmp = L_mac_o( L_tmp, corr_shift_temp[i], 32767, &Overflow ); /*Q15 */ diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index ec5d71989..cc3d04437 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -261,7 +261,7 @@ void update_average_rate_fx( /*st->sum_of_rates += (hSC_VBR->core_brate / 1000.0f) * 10; */ L_tmp = L_shl( Mult_32_16( core_brate_fx, 20972 ), 7 ); /*Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); //??sat + hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); //??sat #else hSC_VBR->sum_of_rates_fx = L_add_o( hSC_VBR->sum_of_rates_fx, L_tmp, &Overflow ); #endif diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index 346117dcb..18713437c 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -60,7 +60,7 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits FOR( i = 1; i < M; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ //??sat + L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ //??sat #else L_tmp = L_mac_o( L_tmp, x[i], x[i], &Overflow ); /*10Q21*/ #endif diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 421644494..08086c8fd 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -570,7 +570,7 @@ ivas_error ppp_voiced_encoder_fx( /* 5 in Q11, 0.65 in Q15 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q31 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) //??sat + if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) //??sat #else if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 31, Qtmp ), &Overflow ) ), 21299 ) ) ) #endif @@ -585,7 +585,7 @@ ivas_error ppp_voiced_encoder_fx( /*3 in Q11, 1.2 in Q14 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q14 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) //??sat + if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) //??sat #else if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 30, Qtmp ), &Overflow ) ), 19661 ) ) ) #endif @@ -602,14 +602,15 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1796_replace_shl_o IF( LT_16( shl_sat( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ #else - IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ + IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ #endif { /* if (res_enratio < 0.025) */ #ifdef ISSUE_1867_replace_overflow_libenc - IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat + IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) + /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ + IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -627,9 +628,9 @@ ivas_error ppp_voiced_encoder_fx( { /* if ( res_enratio < 0.092f) */ #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat + if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ + if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -640,7 +641,7 @@ ivas_error ppp_voiced_encoder_fx( /* if (min(res_enratio, sp_enratio) < 0.075 && tmp < -0.5f)) : 2458 = 0.075 in Q15 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) //??sat + if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) //??sat #else if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_o( -1, sub( Qtmp, 1 ), &Overflow ) ) ) #endif @@ -788,7 +789,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); //??sat + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); //??sat #else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); #endif @@ -816,9 +817,9 @@ ivas_error ppp_voiced_encoder_fx( Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_NQ_FX->Q, 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat #else - Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #endif /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16( hSC_VBR->prev_cw_en_fx, 26214 ); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ @@ -929,7 +930,7 @@ ivas_error ppp_voiced_encoder_fx( FOR( x_fx = 0; x_fx < 160; x_fx++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); //??sat + energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); //??sat #else energy_impz_fx = L_add_o( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ), &Overflow ); #endif @@ -947,7 +948,7 @@ ivas_error ppp_voiced_encoder_fx( move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_Q_E_FX->Q, 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ //??sat + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ //??sat #else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ #endif @@ -1016,12 +1017,12 @@ ivas_error ppp_voiced_encoder_fx( fracb = shl( fracb, scale ); expb = sub( expb, scale ); - tmp = div_s( fracb, fraca ); /* tmp in Q15 */ - exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ + tmp = div_s( fracb, fraca ); /* tmp in Q15 */ + exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat + Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ #endif } test(); @@ -1059,9 +1060,9 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ #endif } /*-------------------------------------------*/ @@ -1129,11 +1130,11 @@ ivas_error ppp_voiced_encoder_fx( L_tmp = L_shl( L_tmp, expa ); exp = sub( 30, add( expa, sub( 31, exp ) ) ); frac = Log2_norm_lc( L_tmp ); - L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ + L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat + Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat #else - Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ + Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ #endif } ELSE @@ -1336,19 +1337,19 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ { /* acc = L_sub(acc, L_mult(memory[j], coef[j])); */ #ifdef ISSUE_1867_replace_overflow_libenc - acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat + acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat #else - acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ + acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ #endif buf[j] = buf[j - 1]; move16(); } /* acc = L_sub(acc, L_mult(memory[0], coef[0])); */ #ifdef ISSUE_1867_replace_overflow_libenc - acc = L_msu_sat( acc, buf[0], b[0] ); //??sat - acc = L_shl_sat( acc, 3 ); //??sat - *y++ = round_fx_sat( acc ); //??sat - buf[0] = round_fx_sat( acc ); //??sat + acc = L_msu_sat( acc, buf[0], b[0] ); //??sat + acc = L_shl_sat( acc, 3 ); //??sat + *y++ = round_fx_sat( acc ); //??sat + buf[0] = round_fx_sat( acc ); //??sat #else acc = L_msu_o( acc, buf[0], b[0], &Overflow ); acc = L_shl_o( acc, 3, &Overflow ); @@ -1440,8 +1441,8 @@ static Word32 DTFS_freq_corr_fx( FOR( k = lk; k < hk; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ //??sat - corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ //??sat + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ //??sat + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ //??sat #else corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ); /* Q(1) */ corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ); /* Q(1) */ @@ -1456,11 +1457,11 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ //??sat //??sat + E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ //??sat //??sat #else - E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ + E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ #endif - Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ + Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ Q_num = sub( shl( add( add( X1_DTFS_fx.Q, X2_DTFS_fx.Q ), Qr ), 1 ), 32 ); /* PORTING: Handling the functions with variable no. of arguments */ @@ -1474,9 +1475,9 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ //??sat //??sat + E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ //??sat //??sat #else - E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ + E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ #endif /* PORTING: Handling the functions with variable no. of arguments */ E_fx = DTFS_getEngy_band_fx( X2_DTFS_fx, lband, hband ); /* Q(1) */ @@ -1488,11 +1489,11 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ //??sat //??sat + E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ //??sat //??sat #else - E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ + E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ #endif - Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ + Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ Q_den = sub( add( shl( add( X2_DTFS_fx.Q, X1_DTFS_fx.Q ), 1 ), add( q1, q2 ) ), 32 ); Num = L_max( Num, 1 ); @@ -1509,7 +1510,7 @@ static Word32 DTFS_freq_corr_fx( expa = norm_l( Num ); #ifdef ISSUE_1867_replace_overflow_libenc - fraca = extract_h( L_shl_sat( Num, expa ) ); //??sat + fraca = extract_h( L_shl_sat( Num, expa ) ); //??sat #else fraca = extract_h( L_shl_o( Num, expa, &Overflow ) ); #endif @@ -1518,7 +1519,7 @@ static Word32 DTFS_freq_corr_fx( expb = norm_l( Den ); #ifdef ISSUE_1867_replace_overflow_libenc - fracb = round_fx_sat( L_shl( Den, expb ) ); //??sat + fracb = round_fx_sat( L_shl( Den, expb ) ); //??sat #else fracb = round_fx_o( L_shl_o( Den, expb, &Overflow ), &Overflow ); #endif @@ -1591,7 +1592,7 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) FOR( k = 0; k < lag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); //??sat + corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); //??sat #else corr = L_mac_o( corr, x1[k], x2[( k - j + lag ) % lag], &Overflow ); #endif @@ -1671,8 +1672,8 @@ static Word32 DTFS_getEngy_band_fx( FOR( k = lk; k < hk; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ //??sat - en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ //??sat + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat #else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); /* 2*X1.Q+1 */ en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); @@ -1689,8 +1690,8 @@ static Word32 DTFS_getEngy_band_fx( IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && ( hband == X_fx.upper_cut_off_freq_fx ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); //??sat - en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); //??sat + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat #else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); -- GitLab From 73c7e86519dbfda3b7ff18a2e94220a3f7fc0485 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 11:31:49 +0200 Subject: [PATCH 36/80] clang format patch --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 3a3efd20a..f3d0111f6 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -223,7 +223,7 @@ static void sign_thr_snr_acc_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); - /* Q4 */ //??sat + /* Q4 */ //??sat #else *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif -- GitLab From ad122bde34ac3c738068a66b8bcc3715110f599d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 11:38:49 +0200 Subject: [PATCH 37/80] buildfix --- lib_enc/tcx_ltp_enc_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index cbf5fbb70..ed65272c9 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -511,10 +511,12 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra { Word32 corr, ener; Word16 i, g, s1, s2, tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); #endif +#endif s1 = sub( getScaleFactor16( speech, L_frame ), 4 ); -- GitLab From ee29b04d32a3be71f264d23bfae421e9f476ab17 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 11:50:53 +0200 Subject: [PATCH 38/80] buildfix --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index f3d0111f6..d591bafe3 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -2449,7 +2449,7 @@ Word16 wb_vad_ivas_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ //??sat #else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif -- GitLab From bb7f803a160006beafa80579263d7c4b66ddec6b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 12:04:06 +0200 Subject: [PATCH 39/80] clang format patch --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index d591bafe3..64043975f 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -2449,7 +2449,7 @@ Word16 wb_vad_ivas_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ //??sat + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ //??sat #else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif -- GitLab From 7c01e90887a73b60c1d57f911d096cc2ecc61ee4 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 11:54:43 +0000 Subject: [PATCH 40/80] reviewed 'til m* --- lib_enc/lsf_enc_fx.c | 54 ++++++++++++++++++++++++------------ lib_enc/lsf_msvq_ma_enc_fx.c | 4 +++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index a6b4ba56a..3c39fe15f 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -2201,8 +2201,8 @@ static void first_VQstages_ivas_fx( #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_shr( L_tmp, 1 ), maxC ); /*Q-1 + x2.56 +x2.56 */ @@ -2438,22 +2438,22 @@ static Word32 vq_lvq_lsf_enc( Vr_subt( cand[i], lsf, diff, M ); FOR( j = 0; j < M; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - diff[j] = shl_sat( diff[j], 4 ); //??sat +#ifdef ISSUE_1796_replace_shl_o + diff[j] = shl_sat( diff[j], 4 ); #else diff[j] = shl_o( diff[j], 4, &Overflow ); #endif move16(); } -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat +#ifdef ISSUE_1796_replace_shl_o + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #else L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif FOR( j = 1; j < M; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat +#ifdef ISSUE_1796_replace_shl_o + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #else L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif @@ -2503,7 +2503,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 quant[LSFMBEST][M], diff[M], dd[M]; Word16 lat_cv[LSFMBEST][M]; Word16 idx_lead[LSFMBEST][2], idx_scale[LSFMBEST][2]; -#ifndef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1796_replace_shl_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif @@ -2575,22 +2575,22 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( Vr_subt( cand[i], lsf, diff, M ); FOR( j = 0; j < M; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - diff[j] = shl_sat( diff[j], 4 ); //??sat +#ifdef ISSUE_1796_replace_shl_o + diff[j] = shl_sat( diff[j], 4 ); #else diff[j] = shl_o( diff[j], 4, &Overflow ); #endif move16(); } -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat +#ifdef ISSUE_1796_replace_shl_o + L_tmp = L_mult( mult( diff[0], shl_sat( w[0], 1 ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #else L_tmp = L_mult( mult( diff[0], shl_o( w[0], 1, &Overflow ) ), diff[0] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif FOR( j = 1; j < M; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ //??sat +#ifdef ISSUE_1796_replace_shl_o + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #else L_tmp = L_mac( L_tmp, mult( diff[j], shl_o( w[j], 1, &Overflow ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif @@ -3446,8 +3446,12 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( move16(); #ifdef ISSUE_1867_replace_overflow_libenc temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); //??sat //??sat +#else +#ifdef ISSUE_1796_replace_shl_o + temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i], &Overflow ); #else temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_o( w_fx[i], 2, &Overflow ) ), yy_fx[i], &Overflow ); +#endif #endif } cs = shl( cs, 1 ); @@ -3664,10 +3668,18 @@ static void lsf_mid_enc_fx( tmp = shl_sat( tmp, 4 ); //??sat tmp = mult_r_sat( tmp, tmp ); //??sat err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat +#else +#ifdef ISSUE_1796_replace_shl_o + tmp = shl_sat( tmp, 4 ); #else tmp = shl_o( tmp, 4, &Overflow ); +#endif tmp = mult_ro( tmp, tmp, &Overflow ); +#ifdef ISSUE_1796_replace_shl_o + err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); +#else err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); +#endif #endif } /* err = L_shl(err,Wscale); */ @@ -3856,12 +3868,20 @@ static void lsf_mid_enc_ivas_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ #ifdef ISSUE_1867_replace_overflow_libenc tmp = shl_sat( tmp, 4 ); //??sat - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat tmp = mult_r_sat( tmp, tmp ); //??sat + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat +#else +#ifdef ISSUE_1796_replace_shl_o + tmp = shl_sat( tmp, 4 ); #else tmp = shl_o( tmp, 4, &Overflow ); - err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); +#endif tmp = mult_ro( tmp, tmp, &Overflow ); +#ifdef ISSUE_1796_replace_shl_o + err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); +#else + err = L_mac_o( err, tmp, shl_o( wghts[j], 2, &Overflow ), &Overflow ); +#endif #endif } /* err = L_shl(err,Wscale); */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index e502b9062..e6b61af8a 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1635,8 +1635,12 @@ void midlsf_enc_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = shl_sat( tmp, 4 ); //??sat tmp = mult_r_sat( tmp, tmp ); //??sat +#else +#ifdef ISSUE_1796_replace_shl_o + tmp = shl_sat( tmp, 4 ); #else tmp = shl_o( tmp, 4, &Overflow ); +#endif tmp = mult_ro( tmp, tmp, &Overflow ); #endif err = L_mac( err, tmp, wghts[j] ); -- GitLab From bd84167d6242f05a04edf687519a9b7c9fdd4936 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 12:34:32 +0000 Subject: [PATCH 41/80] reviewed 'till q* --- lib_enc/nelp_enc_fx.c | 12 +++++----- lib_enc/nois_est_fx.c | 50 +++++++++++++++++++-------------------- lib_enc/pitch_ol2_fx.c | 24 +++++++++---------- lib_enc/pitch_ol_fx.c | 3 ++- lib_enc/ppp_enc_fx.c | 22 ++++++++--------- lib_enc/pre_proc_fx.c | 6 ++--- lib_enc/pvq_core_enc_fx.c | 24 +++++++++---------- lib_enc/pvq_encode_fx.c | 10 ++++---- lib_enc/qlpc_stoch_fx.c | 2 +- 9 files changed, 75 insertions(+), 78 deletions(-) diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 2d4ea5cd0..db3f07f93 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -427,7 +427,7 @@ void nelp_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat #else - E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif } @@ -487,7 +487,7 @@ void nelp_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -515,7 +515,7 @@ void nelp_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -1196,7 +1196,7 @@ void nelp_encoder_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat #else - E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif } @@ -1254,7 +1254,7 @@ void nelp_encoder_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -1282,7 +1282,7 @@ void nelp_encoder_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ +Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index bbada46d5..0612539d2 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -107,12 +107,10 @@ static Word16 noise_est_ln_q8_fx( Flag Overflow = 0; move32(); #endif -#endif -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ //??sat -#else L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */ +#else + L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ //??sat #endif if ( flag_add1p0 == 0 ) { @@ -692,7 +690,7 @@ void noise_est_down_fx( #ifdef ISSUE_1867_replace_overflow_libenc totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ //??sat #else - totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ + totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ #endif } totalNoise_temp = L_max( totalNoise_temp, L_shl( e_min, 4 ) ); @@ -1300,12 +1298,12 @@ void noise_est_fx( tmp = s_max( relE, 0 ); /* Q8 */ /* alpha = 0.064f * ftemp + 0.75f; */ - Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ - Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ + Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ + Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ #ifdef ISSUE_1867_replace_overflow_libenc alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -1341,13 +1339,13 @@ void noise_est_fx( /* + 1.0f added to reduce sensitivity to non stationarity in low energies */ /* tmp_enr = enr[i] + 1.0f; */ tmp_Q = add( Q_new, Q_SCALE ); - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else - L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ - L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ + L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ + L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */ @@ -1387,14 +1385,14 @@ void noise_est_fx( } */ /* ave_enr2:: calculation of another non-stationarity measure (following attacks) */ - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ - /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif - IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ + IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ { Lnum = L_max( L_tmp_enr, L_tmp_ave_enr2 ); Lden = L_min( L_tmp_enr, L_tmp_ave_enr2 ); @@ -1572,13 +1570,13 @@ void noise_est_fx( /*epsP_0_2 = max(0 , min(8, epsP[0] / epsP[2])); */ Ltmp = eps_quota_fx( epsP_h[0], epsP_l[0], - epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ + epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat #else - epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ + epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #endif BASOP_SATURATE_WARNING_ON_EVS @@ -1616,14 +1614,14 @@ void noise_est_fx( /* epsP_2_16 = max(0 , min(8, epsP[2] / epsP[16])); */ Ltmp = eps_quota_fx( epsP_h[2], epsP_l[2], - epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ + epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_2_16 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 ,*/ #else - epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ + epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ #endif - /* NB saturation in Q12 sets max value to 7, 999 */ + /*NB saturation in Q12 sets max value to 7,999 */ BASOP_SATURATE_WARNING_ON_EVS epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */ @@ -2625,10 +2623,10 @@ void noise_est_ivas_fx( { /* ftemp2 /= ftemp */ num = div_s( extract_h( Ltmp2 ), extract_h( Ltmp ) ); // 15+exp2-exp -#ifdef ISSUE_1867_replace_overflow_libenc - noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 //??sat +#ifdef ISSUE_1796_replace_shl_o + noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 #else - noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 + noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif } @@ -2698,7 +2696,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -2881,7 +2879,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat #else - non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ + non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif } } diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 857844f75..23a0c9f78 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -315,27 +315,27 @@ void StableHighPitchDetect_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_sat( diff ); //??sat #else - diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); #endif - BASOP_SATURATE_WARNING_ON_EVS } ELSE { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_sat( diff ); //??sat #else - diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); #endif - BASOP_SATURATE_WARNING_ON_EVS } } ELSE @@ -550,27 +550,27 @@ void StableHighPitchDetect_ivas_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); //??sat + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_sat( diff ); //??sat #else - diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); #endif - BASOP_SATURATE_WARNING_ON_EVS } ELSE { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); //??sat + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_sat( diff ); //??sat #else - diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); + BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); #endif - BASOP_SATURATE_WARNING_ON_EVS } } ELSE diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 470e0e161..02ed82473 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -1730,7 +1730,8 @@ void pitch_ol_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 //??sat #else - corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 + + corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 #endif move16(); diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index a662ee328..787cc7fe1 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -687,8 +687,8 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat #else - temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ - wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ + temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ + wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #endif IF( GE_16( Qmaxcorr, Qcorr ) ) @@ -715,7 +715,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X #ifdef ISSUE_1867_replace_overflow_libenc maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat #else - maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ + maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif Qmaxcorr = Qcorr; move16(); @@ -805,12 +805,12 @@ static void LPCPowSpect_fx( Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat #else - Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ - Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ - Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ + Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ + Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ + Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ #endif - w = extract_h( Ltemp ); /* w is equivalent cos index */ - dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ + w = extract_h( Ltemp ); /* w is equivalent cos index */ + dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); t1 = cos_table[w]; /*t2=cos_table[s_and(add(w,1),511)]; */ @@ -834,8 +834,8 @@ static void LPCPowSpect_fx( Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat #else - Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ - Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ + Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ + Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ #endif } /* If necessary, we can block-normalize Re and Im to improve precision */ @@ -854,7 +854,7 @@ static void LPCPowSpect_fx( #ifdef ISSUE_1867_replace_overflow_libenc Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat #else - Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ + Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif dh = extract_h( Im ); dl = extract_l( Im ); diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 6da970ead..0dc722acd 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -127,12 +127,10 @@ void pre_proc_fx( FD_BWE_ENC_HANDLE hBWE_FD = st->hBWE_FD; #ifndef ISSUE_1796_replace_shl_o -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif -#endif #endif /*------------------------------------------------------------------* @@ -1050,8 +1048,8 @@ void pre_proc_fx( test(); IF( ( ( st->tcxonly == 0 ) || ( EQ_16( st->codec_mode, MODE1 ) ) ) && GT_32( st->input_Fs, 8000 ) ) { -#ifdef ISSUE_1867_replace_overflow_libenc - st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); //??sat +#ifdef ISSUE_1796_replace_shl_o + st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); #else st->mem_preemph_enc = shl_o( new_inp_16k[sub( L_frame_tmp, 1 )], 1, &Overflow ); #endif diff --git a/lib_enc/pvq_core_enc_fx.c b/lib_enc/pvq_core_enc_fx.c index b637c5aec..a5e193461 100644 --- a/lib_enc/pvq_core_enc_fx.c +++ b/lib_enc/pvq_core_enc_fx.c @@ -267,7 +267,7 @@ void pvq_encode_frame_ivas_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; -#ifndef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1796_replace_shl_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -333,8 +333,8 @@ void pvq_encode_frame_ivas_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); -#ifdef ISSUE_1867_replace_overflow_libenc - gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat +#ifdef ISSUE_1796_replace_shl_o + gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif @@ -397,7 +397,7 @@ void pvq_encode_frame_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; -#ifndef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1796_replace_shl_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -463,8 +463,8 @@ void pvq_encode_frame_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); -#ifdef ISSUE_1867_replace_overflow_libenc - gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat +#ifdef ISSUE_1796_replace_shl_o + gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif @@ -943,7 +943,7 @@ static void densityIndexSymbolEncode_ivas_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; -#ifndef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1796_replace_shl_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -955,8 +955,8 @@ static void densityIndexSymbolEncode_ivas_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); -#ifdef ISSUE_1867_replace_overflow_libenc - angle = shl_sat( angle, 1 ); //??sat +#ifdef ISSUE_1796_replace_shl_o + angle = shl_sat( angle, 1 ); #else angle = shl_o( angle, 1, &Overflow ); #endif @@ -1026,7 +1026,7 @@ static void densityIndexSymbolEncode_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; -#ifndef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1796_replace_shl_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -1038,8 +1038,8 @@ static void densityIndexSymbolEncode_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); -#ifdef ISSUE_1867_replace_overflow_libenc - angle = shl_sat( angle, 1 ); //??sat +#ifdef ISSUE_1796_replace_shl_o + angle = shl_sat( angle, 1 ); #else angle = shl_o( angle, 1, &Overflow ); #endif diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 71ca29eee..595f1ac8b 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -94,7 +94,7 @@ static Word16 one_pulse_search( L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ #endif - corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ + corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ /* extract_l without shift can always be used for this section as energy is guaranteed to stay in the lower word, 1 op */ @@ -372,8 +372,8 @@ void pvq_encode_ivas_fx( L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ @@ -587,8 +587,8 @@ void pvq_encode_fx( L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 36d33e996..e6e51ef72 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -446,7 +446,7 @@ void Unified_weighting_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ //??sat #else - L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ + L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ #endif } -- GitLab From 62affabbc5951b102e43c4e79635bf1fefab22ea Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 14:51:02 +0200 Subject: [PATCH 42/80] clang format patch --- lib_enc/lsf_enc_fx.c | 4 ++-- lib_enc/nelp_enc_fx.c | 12 ++++++------ lib_enc/nois_est_fx.c | 40 ++++++++++++++++++++-------------------- lib_enc/pitch_ol2_fx.c | 8 ++++---- lib_enc/pitch_ol_fx.c | 2 +- lib_enc/ppp_enc_fx.c | 22 +++++++++++----------- lib_enc/pvq_encode_fx.c | 10 +++++----- lib_enc/qlpc_stoch_fx.c | 2 +- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 3c39fe15f..b9d0c1678 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -2201,8 +2201,8 @@ static void first_VQstages_ivas_fx( #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_shr( L_tmp, 1 ), maxC ); /*Q-1 + x2.56 +x2.56 */ diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index db3f07f93..2d4ea5cd0 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -427,7 +427,7 @@ void nelp_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat #else - E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif } @@ -487,7 +487,7 @@ void nelp_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -515,7 +515,7 @@ void nelp_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -1196,7 +1196,7 @@ void nelp_encoder_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat #else - E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif } @@ -1254,7 +1254,7 @@ void nelp_encoder_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else - Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } @@ -1282,7 +1282,7 @@ void nelp_encoder_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat #else -Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ + Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif } diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 0612539d2..fb5157db5 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -690,7 +690,7 @@ void noise_est_down_fx( #ifdef ISSUE_1867_replace_overflow_libenc totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ //??sat #else - totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ + totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ #endif } totalNoise_temp = L_max( totalNoise_temp, L_shl( e_min, 4 ) ); @@ -1298,12 +1298,12 @@ void noise_est_fx( tmp = s_max( relE, 0 ); /* Q8 */ /* alpha = 0.064f * ftemp + 0.75f; */ - Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ - Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ + Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ + Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ #ifdef ISSUE_1867_replace_overflow_libenc alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -1339,13 +1339,13 @@ void noise_est_fx( /* + 1.0f added to reduce sensitivity to non stationarity in low energies */ /* tmp_enr = enr[i] + 1.0f; */ tmp_Q = add( Q_new, Q_SCALE ); - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else - L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ - L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ + L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ + L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif IF( LE_32( non_sta, th_sta ) ) /* Just to limit the saturation */ @@ -1385,14 +1385,14 @@ void noise_est_fx( } */ /* ave_enr2:: calculation of another non-stationarity measure (following attacks) */ - Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ - /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ + Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ + /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat #else L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif - IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ + IF( LE_32( Lnon_sta2, th_sta ) ) /* Just to limit the saturation */ { Lnum = L_max( L_tmp_enr, L_tmp_ave_enr2 ); Lden = L_min( L_tmp_enr, L_tmp_ave_enr2 ); @@ -1570,13 +1570,13 @@ void noise_est_fx( /*epsP_0_2 = max(0 , min(8, epsP[0] / epsP[2])); */ Ltmp = eps_quota_fx( epsP_h[0], epsP_l[0], - epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ + epsP_h[2], epsP_l[2], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat #else - epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ + epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #endif BASOP_SATURATE_WARNING_ON_EVS @@ -1614,14 +1614,14 @@ void noise_est_fx( /* epsP_2_16 = max(0 , min(8, epsP[2] / epsP[16])); */ Ltmp = eps_quota_fx( epsP_h[2], epsP_l[2], - epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ + epsP_h[16], epsP_l[16], 12 ); /* Word32 Q12 */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_2_16 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12+16 -16 -> Q12 ,*/ #else - epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ + epsP_2_16 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 ,*/ #endif - /*NB saturation in Q12 sets max value to 7,999 */ + /*NB saturation in Q12 sets max value to 7,999 */ BASOP_SATURATE_WARNING_ON_EVS epsP_2_16 = s_max( 0, epsP_2_16 ); /* min value is 0 , Q12 */ @@ -2626,7 +2626,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1796_replace_shl_o noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 #else - noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 + noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif } @@ -2696,7 +2696,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat #else - alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif /*if( alpha > 0.999f { alpha = 0.999f;} */ @@ -2879,7 +2879,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat #else - non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ + non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif } } diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 23a0c9f78..2e30ff54b 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -318,7 +318,7 @@ void StableHighPitchDetect_fx( diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -331,7 +331,7 @@ void StableHighPitchDetect_fx( diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -553,7 +553,7 @@ void StableHighPitchDetect_ivas_fx( diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -566,7 +566,7 @@ void StableHighPitchDetect_ivas_fx( diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); //??sat #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 02ed82473..78f59ac14 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -1731,7 +1731,7 @@ void pitch_ol_ivas_fx( corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 //??sat #else - corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 + corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 #endif move16(); diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index 787cc7fe1..a662ee328 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -687,8 +687,8 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat #else - temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ - wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ + temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ + wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #endif IF( GE_16( Qmaxcorr, Qcorr ) ) @@ -715,7 +715,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X #ifdef ISSUE_1867_replace_overflow_libenc maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat #else - maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ + maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif Qmaxcorr = Qcorr; move16(); @@ -805,12 +805,12 @@ static void LPCPowSpect_fx( Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat #else - Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ - Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ - Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ + Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ + Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ + Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ #endif - w = extract_h( Ltemp ); /* w is equivalent cos index */ - dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ + w = extract_h( Ltemp ); /* w is equivalent cos index */ + dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); t1 = cos_table[w]; /*t2=cos_table[s_and(add(w,1),511)]; */ @@ -834,8 +834,8 @@ static void LPCPowSpect_fx( Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat #else - Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ - Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ + Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ + Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ #endif } /* If necessary, we can block-normalize Re and Im to improve precision */ @@ -854,7 +854,7 @@ static void LPCPowSpect_fx( #ifdef ISSUE_1867_replace_overflow_libenc Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat #else - Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ + Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif dh = extract_h( Im ); dl = extract_l( Im ); diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 595f1ac8b..f055bbd89 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -94,7 +94,7 @@ static Word16 one_pulse_search( L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ #endif - corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ + corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ /* extract_l without shift can always be used for this section as energy is guaranteed to stay in the lower word, 1 op */ @@ -372,8 +372,8 @@ void pvq_encode_ivas_fx( L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ @@ -587,8 +587,8 @@ void pvq_encode_fx( L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index e6e51ef72..36d33e996 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -446,7 +446,7 @@ void Unified_weighting_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ //??sat #else - L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ + L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ #endif } -- GitLab From e5b1be3da073c1a39453d8f217502fb455caa23f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 18 Aug 2025 13:46:15 +0000 Subject: [PATCH 43/80] reviewed all --- lib_enc/scale_enc_fx.c | 6 +- lib_enc/set_impulse_fx.c | 18 ++-- lib_enc/speech_music_classif_fx.c | 8 +- lib_enc/stat_noise_uv_enc_fx.c | 12 +-- lib_enc/swb_bwe_enc_fx.c | 32 +++---- lib_enc/swb_bwe_enc_hr_fx.c | 3 +- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 140 +++++++++++++++--------------- lib_enc/tcx_ltp_enc_fx.c | 2 +- lib_enc/transition_enc_fx.c | 2 +- lib_enc/vad_fx.c | 33 ++++--- lib_enc/vad_param_updt_fx.c | 2 +- lib_enc/voiced_enc_fx.c | 38 ++++---- 13 files changed, 151 insertions(+), 147 deletions(-) diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 6e0b63819..9539ca3af 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,7 +86,7 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; -#ifndef ISSUE_1867_replace_overflow_libenc +#if !defined(ISSUE_1867_replace_overflow_libenc) &6 !defined(ISSUE_1796_replace_shl_o) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -104,7 +104,11 @@ void Preemph_scaled( QVal = shl_sat( 1, sub( 15, bits ) ); //?sat #else Overflow = 0; +#ifdef ISSUE_1796_replace_shl_o + QVal = shl_sat( 1, sub( 15, bits ) ); +#else QVal = shl_o( 1, sub( 15, bits ), &Overflow ); +#endif #endif BASOP_SATURATE_WARNING_ON_EVS mu = shr( Preemph_factor, bits ); /* Q15 --> Q(15-bits) */ diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 76a4b1afb..962098065 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -125,8 +125,8 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 #endif } rr_fx[start1] = Lrr; @@ -134,7 +134,7 @@ void set_impulse_fx( #ifdef ISSUE_1867_replace_overflow_libenc dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat #else - dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 + dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 #endif rr_fx[start1] = L_max( rr_fx[start1], 1 ); @@ -153,8 +153,8 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 #endif } @@ -164,10 +164,10 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 #endif - dd_fx[i] = round_fx_sat( Ldd ); // Q11 + dd_fx[i] = round_fx_sat( Ldd ); // Q11 rr_fx[i] = L_max( Lrr, 1 ); move32(); /* move rr and dd into rr[i] and dd[i] */ @@ -229,7 +229,7 @@ void set_impulse_fx( #ifdef ISSUE_1867_replace_overflow_libenc krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat #else - krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ #endif IF( GT_16( krit_fx, krit_max_fx ) ) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 3ca43ee7f..55436dc9e 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1036,7 +1036,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis #ifdef ISSUE_1867_replace_overflow_libenc lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat #else - lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ + lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif lps = s_max( lps, -10832 ); @@ -1048,7 +1048,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis #ifdef ISSUE_1867_replace_overflow_libenc lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat #else - lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ + lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif lpn = s_max( lpn, -10832 ); @@ -1555,7 +1555,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1571,7 +1571,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 38a36083e..225f26d3b 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -78,9 +78,9 @@ void stat_noise_uv_enc_fx( #else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ #endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -161,9 +161,9 @@ void stat_noise_uv_enc_ivas_fx( #else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ #endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 4bdd08923..dfee7a7d1 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -548,7 +548,7 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat #else @@ -821,7 +821,7 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat #else @@ -1071,7 +1071,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class #ifdef ISSUE_1867_replace_overflow_libenc gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat #else - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ #endif } ELSE @@ -1093,8 +1093,8 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); -#ifdef ISSUE_1867_replace_overflow_libenc - num = shl_sat( num, scale ); //??sat +#ifdef ISSUE_1796_replace_shl_o + num = shl_sat( num, scale ); #else num = shl_o( num, scale, &Overflow ); #endif @@ -1102,10 +1102,10 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class tmp = div_s( num, den ); expn = sub( expn, expd ); -#ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ //??sat +#ifdef ISSUE_1796_replace_shl_o + gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ #else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif } test(); @@ -1195,8 +1195,8 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ #ifdef ISSUE_1867_replace_overflow_libenc sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat #else @@ -1427,9 +1427,9 @@ static void vqWithCand_w_fx( #else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ #endif - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { @@ -2892,7 +2892,7 @@ static Word16 SWB_BWE_encoding_fx( #ifdef ISSUE_1867_replace_overflow_libenc Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat #else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) @@ -3382,11 +3382,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat #else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index 4467fb988..d7cebe322 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -769,11 +769,10 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); + L_tmp = L_shr_sat( L_tmp, temp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, temp2 ); //??sat t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat #else - L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); #endif move16(); diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 2dedbfbeb..dc5b662f9 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -784,7 +784,7 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ #ifdef ISSUE_1867_replace_overflow_libenc L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat g_fx = round_fx_sat( L_temp ); //??sat diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 1e4f328ff..1290dcfeb 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1889,7 +1889,7 @@ void wb_tbe_enc_ivas_fx( tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); - tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ + tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ #endif } @@ -2583,19 +2583,19 @@ void swb_tbe_enc_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -2608,15 +2608,15 @@ void swb_tbe_enc_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -2846,12 +2846,12 @@ void swb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat #else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif } @@ -3903,11 +3903,11 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -3925,19 +3925,19 @@ void swb_tbe_enc_ivas_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -3950,15 +3950,15 @@ void swb_tbe_enc_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -4466,12 +4466,12 @@ void swb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat #else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -4748,10 +4748,10 @@ static void EstimateSHBFrameGain_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ #endif } @@ -4762,9 +4762,9 @@ static void EstimateSHBFrameGain_fx( sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ #endif } @@ -4777,10 +4777,11 @@ static void EstimateSHBFrameGain_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ #endif } IF( EQ_32( oriNrg, MAX_32 ) ) @@ -4973,10 +4974,10 @@ static void EstimateSHBFrameGain_ivas_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ #endif } @@ -4987,9 +4988,9 @@ static void EstimateSHBFrameGain_ivas_fx( sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat #else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ #endif } @@ -5002,8 +5003,9 @@ static void EstimateSHBFrameGain_ivas_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ #endif @@ -5280,14 +5282,12 @@ static void EstimateSHBGainShape_fx( sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat -#else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#endif - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -#ifdef ISSUE_1867_replace_overflow_libenc synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #else - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5296,14 +5296,12 @@ static void EstimateSHBGainShape_fx( sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat -#else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#endif sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ -#ifdef ISSUE_1867_replace_overflow_libenc synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5312,14 +5310,12 @@ static void EstimateSHBGainShape_fx( sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat -#else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#endif sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ -#ifdef ISSUE_1867_replace_overflow_libenc synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ @@ -5371,8 +5367,8 @@ static void EstimateSHBGainShape_fx( subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ + subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ #endif move16(); } @@ -5387,7 +5383,7 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat #else @@ -5400,11 +5396,11 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ #endif move16(); } @@ -6411,7 +6407,7 @@ static void determine_gain_weights_fx( Word16 j; Word16 exp, exp1, frac, tmp, exp2; Word32 L_tmp; -#ifndef ISSUE_1867_replace_overflow_libenc +#ifndef ISSUE_1796_replace_shl_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); @@ -6437,8 +6433,8 @@ static void determine_gain_weights_fx( { exp2 = sub( exp, 2 ); } -#ifdef ISSUE_1867_replace_overflow_libenc - weights[j] = shl_sat( tmp, exp2 ); //??sat +#ifdef ISSUE_1796_replace_shl_o + weights[j] = shl_sat( tmp, exp2 ); #else weights[j] = shl_o( tmp, exp2, &Overflow ); #endif @@ -7079,10 +7075,10 @@ static void first_VQstages_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_tmp, maxC ); @@ -7609,13 +7605,13 @@ void fb_tbe_enc_fx( Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ + temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat #else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ #endif - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index ed65272c9..d5916e918 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -615,7 +615,7 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif BASOP_SATURATE_WARNING_OFF_EVS -#ifdef ISSUE_1867_replace_overflow_libenc +#ifdef ISSUE_1796_replace_shl_o g = shl_sat( g, sub( s1, s2 ) ); /*Q15*/ #else g = shl_o( g, sub( s1, s2 ), &Overflow ); /*Q15*/ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index f827bb201..98b068071 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2203,7 +2203,7 @@ static void gain_trans_enc_fx( #ifdef ISSUE_1867_replace_overflow_libenc gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ //??sat #else - gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ + gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ #endif IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 64043975f..c09736e61 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -220,12 +220,11 @@ static void sign_thr_snr_acc_fx( { L_tmp = L_add( L_snr, 0 ); /* Q4 */ } - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc - *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); - /* Q4 */ //??sat + *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); /* Q4 */ //??sat #else - *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ + *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif move32(); BASOP_SATURATE_WARNING_ON_EVS @@ -1052,14 +1051,14 @@ Word16 wb_vad_fx( #ifdef ISSUE_1796_replace_shl_o tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ #else - tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ + tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ #endif IF( LT_16( i, 2 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta1 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ #endif } ELSE IF( LT_16( i, 7 ) ) @@ -1067,7 +1066,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta2 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ #endif } ELSE IF( LT_16( i, 18 ) ) @@ -1075,7 +1074,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta3 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ #endif } ELSE @@ -1083,7 +1082,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta4 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ #endif } @@ -1095,7 +1094,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ //??sat #else - tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ + tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #endif } @@ -1183,7 +1182,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat #else - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif } ELSE @@ -1191,7 +1190,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat #else - L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ + L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif } @@ -1407,7 +1406,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ //??sat #else - tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ + tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #endif IF( L_tmp2 > 0 ) { @@ -2451,7 +2450,7 @@ Word16 wb_vad_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ //??sat #else - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif } ELSE @@ -2459,7 +2458,7 @@ Word16 wb_vad_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ //??sat #else - L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ + L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ #endif } @@ -2473,11 +2472,11 @@ Word16 wb_vad_ivas_fx( move16(); move16(); } - } /* end of band loop */ + } /* end of band loop */ #ifdef ISSUE_1867_replace_overflow_libenc L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 //??sat #else - L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 + L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 #endif snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4 diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index da724a781..26522bce5 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -166,7 +166,7 @@ void vad_param_updt_fx( /* (voicing[0] + voicing[1] + voicing[2]) / 3 + corr_shift */ L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); - L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ + L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ //??sat voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ //??sat diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 08086c8fd..49500bcae 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -602,7 +602,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1796_replace_shl_o IF( LT_16( shl_sat( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ #else - IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ + IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ #endif { /* if (res_enratio < 0.025) */ @@ -610,7 +610,7 @@ ivas_error ppp_voiced_encoder_fx( IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ + IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -630,7 +630,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ + if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -642,8 +642,12 @@ ivas_error ppp_voiced_encoder_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) //??sat +#else +#ifdef ISSUE_1796_replace_shl_o + if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) #else if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_o( -1, sub( Qtmp, 1 ), &Overflow ) ) ) +#endif #endif { hSC_VBR->bump_up = 1; @@ -819,7 +823,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat #else - Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #endif /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16( hSC_VBR->prev_cw_en_fx, 26214 ); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ @@ -1017,12 +1021,12 @@ ivas_error ppp_voiced_encoder_fx( fracb = shl( fracb, scale ); expb = sub( expb, scale ); - tmp = div_s( fracb, fraca ); /* tmp in Q15 */ - exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ + tmp = div_s( fracb, fraca ); /* tmp in Q15 */ + exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ #ifdef ISSUE_1867_replace_overflow_libenc Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ #endif } test(); @@ -1062,7 +1066,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ #endif } /*-------------------------------------------*/ @@ -1130,11 +1134,11 @@ ivas_error ppp_voiced_encoder_fx( L_tmp = L_shl( L_tmp, expa ); exp = sub( 30, add( expa, sub( 31, exp ) ) ); frac = Log2_norm_lc( L_tmp ); - L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ + L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat #else - Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ + Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ #endif } ELSE @@ -1339,7 +1343,7 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ #ifdef ISSUE_1867_replace_overflow_libenc acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat #else - acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ + acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ #endif buf[j] = buf[j - 1]; move16(); @@ -1353,7 +1357,9 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ #else acc = L_msu_o( acc, buf[0], b[0], &Overflow ); acc = L_shl_o( acc, 3, &Overflow ); + *y++ = round_fx_o( acc, &Overflow ); + buf[0] = round_fx_o( acc, &Overflow ); #endif move16(); @@ -1459,9 +1465,9 @@ static Word32 DTFS_freq_corr_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ //??sat //??sat #else - E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ + E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ #endif - Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ + Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ Q_num = sub( shl( add( add( X1_DTFS_fx.Q, X2_DTFS_fx.Q ), Qr ), 1 ), 32 ); /* PORTING: Handling the functions with variable no. of arguments */ @@ -1477,7 +1483,7 @@ static Word32 DTFS_freq_corr_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ //??sat //??sat #else - E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ + E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ #endif /* PORTING: Handling the functions with variable no. of arguments */ E_fx = DTFS_getEngy_band_fx( X2_DTFS_fx, lband, hband ); /* Q(1) */ @@ -1491,9 +1497,9 @@ static Word32 DTFS_freq_corr_fx( #ifdef ISSUE_1867_replace_overflow_libenc E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ //??sat //??sat #else - E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ + E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ #endif - Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ + Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ Q_den = sub( add( shl( add( X2_DTFS_fx.Q, X1_DTFS_fx.Q ), 1 ), add( q1, q2 ) ), 32 ); Num = L_max( Num, 1 ); -- GitLab From 1d241d6bd9823c009c1ce40b25870c34d9418d8a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 19 Aug 2025 07:26:06 +0200 Subject: [PATCH 44/80] clang format patch --- lib_enc/scale_enc_fx.c | 2 +- lib_enc/set_impulse_fx.c | 18 ++--- lib_enc/speech_music_classif_fx.c | 8 +- lib_enc/stat_noise_uv_enc_fx.c | 12 +-- lib_enc/swb_bwe_enc_fx.c | 24 +++--- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 126 +++++++++++++++--------------- lib_enc/transition_enc_fx.c | 2 +- lib_enc/vad_fx.c | 33 ++++---- lib_enc/vad_param_updt_fx.c | 2 +- lib_enc/voiced_enc_fx.c | 32 ++++---- 11 files changed, 131 insertions(+), 130 deletions(-) diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 9539ca3af..bc3bdda69 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,7 +86,7 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; -#if !defined(ISSUE_1867_replace_overflow_libenc) &6 !defined(ISSUE_1796_replace_shl_o) +#if !defined( ISSUE_1867_replace_overflow_libenc ) & 6 !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 962098065..76a4b1afb 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -125,8 +125,8 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 #endif } rr_fx[start1] = Lrr; @@ -134,7 +134,7 @@ void set_impulse_fx( #ifdef ISSUE_1867_replace_overflow_libenc dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat #else - dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 + dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 #endif rr_fx[start1] = L_max( rr_fx[start1], 1 ); @@ -153,8 +153,8 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 #endif } @@ -164,10 +164,10 @@ void set_impulse_fx( Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat #else - Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 + Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 #endif - dd_fx[i] = round_fx_sat( Ldd ); // Q11 + dd_fx[i] = round_fx_sat( Ldd ); // Q11 rr_fx[i] = L_max( Lrr, 1 ); move32(); /* move rr and dd into rr[i] and dd[i] */ @@ -229,7 +229,7 @@ void set_impulse_fx( #ifdef ISSUE_1867_replace_overflow_libenc krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat #else - krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ #endif IF( GT_16( krit_fx, krit_max_fx ) ) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 55436dc9e..4f809d827 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1036,7 +1036,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis #ifdef ISSUE_1867_replace_overflow_libenc lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat #else - lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ + lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif lps = s_max( lps, -10832 ); @@ -1048,7 +1048,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis #ifdef ISSUE_1867_replace_overflow_libenc lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat #else - lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ + lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif lpn = s_max( lpn, -10832 ); @@ -1555,7 +1555,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1571,7 +1571,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 225f26d3b..38a36083e 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -78,9 +78,9 @@ void stat_noise_uv_enc_fx( #else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ #endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -161,9 +161,9 @@ void stat_noise_uv_enc_ivas_fx( #else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ #endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index dfee7a7d1..280624b4f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -548,7 +548,7 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat #else @@ -821,7 +821,7 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat #else @@ -1071,7 +1071,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class #ifdef ISSUE_1867_replace_overflow_libenc gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat #else - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ #endif } ELSE @@ -1105,7 +1105,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class #ifdef ISSUE_1796_replace_shl_o gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ #else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif } test(); @@ -1195,8 +1195,8 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ #ifdef ISSUE_1867_replace_overflow_libenc sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat #else @@ -1427,9 +1427,9 @@ static void vqWithCand_w_fx( #else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ #endif - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { @@ -2892,7 +2892,7 @@ static Word16 SWB_BWE_encoding_fx( #ifdef ISSUE_1867_replace_overflow_libenc Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat #else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) @@ -3382,11 +3382,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat #else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index dc5b662f9..2dedbfbeb 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -784,7 +784,7 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ #ifdef ISSUE_1867_replace_overflow_libenc L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat g_fx = round_fx_sat( L_temp ); //??sat diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 1290dcfeb..09560f568 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1889,7 +1889,7 @@ void wb_tbe_enc_ivas_fx( tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); - tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ + tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ #endif } @@ -2583,19 +2583,19 @@ void swb_tbe_enc_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -2608,15 +2608,15 @@ void swb_tbe_enc_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -2846,12 +2846,12 @@ void swb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat #else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif } @@ -3903,11 +3903,11 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -3925,19 +3925,19 @@ void swb_tbe_enc_ivas_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -3950,15 +3950,15 @@ void swb_tbe_enc_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat #else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat #else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif move16(); } @@ -4466,12 +4466,12 @@ void swb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat #else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -4748,10 +4748,10 @@ static void EstimateSHBFrameGain_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ #endif } @@ -4762,9 +4762,9 @@ static void EstimateSHBFrameGain_fx( sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ #endif } @@ -4777,8 +4777,8 @@ static void EstimateSHBFrameGain_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ @@ -4816,7 +4816,7 @@ static void EstimateSHBFrameGain_fx( oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } } @@ -4974,10 +4974,10 @@ static void EstimateSHBFrameGain_ivas_fx( sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat #else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ #endif } @@ -4988,9 +4988,9 @@ static void EstimateSHBFrameGain_ivas_fx( sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat #else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ #endif } @@ -5283,11 +5283,11 @@ static void EstimateSHBGainShape_fx( #ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5296,12 +5296,12 @@ static void EstimateSHBGainShape_fx( sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5309,13 +5309,13 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ @@ -5367,8 +5367,8 @@ static void EstimateSHBGainShape_fx( subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ + subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ #endif move16(); } @@ -5383,7 +5383,7 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat #else @@ -5396,11 +5396,11 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ #endif move16(); } @@ -7075,10 +7075,10 @@ static void first_VQstages_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_tmp, maxC ); @@ -7605,13 +7605,13 @@ void fb_tbe_enc_fx( Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ + temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat #else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ #endif - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 98b068071..f827bb201 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2203,7 +2203,7 @@ static void gain_trans_enc_fx( #ifdef ISSUE_1867_replace_overflow_libenc gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ //??sat #else - gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ + gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ #endif IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index c09736e61..6a8b06a57 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -220,11 +220,12 @@ static void sign_thr_snr_acc_fx( { L_tmp = L_add( L_snr, 0 ); /* Q4 */ } - BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ + BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc - *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); /* Q4 */ //??sat + *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); + /* Q4 */ //??sat #else - *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ + *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif move32(); BASOP_SATURATE_WARNING_ON_EVS @@ -1051,14 +1052,14 @@ Word16 wb_vad_fx( #ifdef ISSUE_1796_replace_shl_o tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ #else - tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ + tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ #endif IF( LT_16( i, 2 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta1 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ #endif } ELSE IF( LT_16( i, 7 ) ) @@ -1066,7 +1067,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta2 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ #endif } ELSE IF( LT_16( i, 18 ) ) @@ -1074,7 +1075,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta3 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ #endif } ELSE @@ -1082,7 +1083,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp = add_sat( tmp, delta4 ); /*Q13 */ //??sat #else - tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ + tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ #endif } @@ -1094,7 +1095,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ //??sat #else - tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ + tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #endif } @@ -1182,7 +1183,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat #else - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif } ELSE @@ -1190,7 +1191,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat #else - L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ + L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif } @@ -1406,7 +1407,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1867_replace_overflow_libenc tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ //??sat #else - tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ + tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #endif IF( L_tmp2 > 0 ) { @@ -2450,7 +2451,7 @@ Word16 wb_vad_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ //??sat #else - L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ + L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif } ELSE @@ -2458,7 +2459,7 @@ Word16 wb_vad_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ //??sat #else - L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ + L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ #endif } @@ -2472,11 +2473,11 @@ Word16 wb_vad_ivas_fx( move16(); move16(); } - } /* end of band loop */ + } /* end of band loop */ #ifdef ISSUE_1867_replace_overflow_libenc L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 //??sat #else - L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 + L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 #endif snr_sumt = extract_h( L_shl( L_snr_sumt, Q4 ) ); // Q16 -> Q4 diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index 26522bce5..da724a781 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -166,7 +166,7 @@ void vad_param_updt_fx( /* (voicing[0] + voicing[1] + voicing[2]) / 3 + corr_shift */ L_tmp = L_mult( st_fx->voicing_fx[0], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); - L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ + L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ //??sat voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ //??sat diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 49500bcae..34a21b66f 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -602,7 +602,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1796_replace_shl_o IF( LT_16( shl_sat( hSC_VBR->vadsnr_fx, 1 ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ #else - IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ + IF( LT_16( shl_o( hSC_VBR->vadsnr_fx, 1, &Overflow ), hSC_VBR->SNR_THLD_fx ) ) /*Q8 */ #endif { /* if (res_enratio < 0.025) */ @@ -610,7 +610,7 @@ ivas_error ppp_voiced_encoder_fx( IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ + IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -630,7 +630,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ + if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -823,7 +823,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat #else - Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #endif /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16( hSC_VBR->prev_cw_en_fx, 26214 ); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ @@ -1021,12 +1021,12 @@ ivas_error ppp_voiced_encoder_fx( fracb = shl( fracb, scale ); expb = sub( expb, scale ); - tmp = div_s( fracb, fraca ); /* tmp in Q15 */ - exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ + tmp = div_s( fracb, fraca ); /* tmp in Q15 */ + exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ #ifdef ISSUE_1867_replace_overflow_libenc Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ #endif } test(); @@ -1066,7 +1066,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ #endif } /*-------------------------------------------*/ @@ -1134,11 +1134,11 @@ ivas_error ppp_voiced_encoder_fx( L_tmp = L_shl( L_tmp, expa ); exp = sub( 30, add( expa, sub( 31, exp ) ) ); frac = Log2_norm_lc( L_tmp ); - L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ + L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat #else - Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ + Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ #endif } ELSE @@ -1343,7 +1343,7 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ #ifdef ISSUE_1867_replace_overflow_libenc acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat #else - acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ + acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ #endif buf[j] = buf[j - 1]; move16(); @@ -1465,9 +1465,9 @@ static Word32 DTFS_freq_corr_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ //??sat //??sat #else - E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ + E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ #endif - Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ + Num = L_mult0( E1_fx, E1_fx ); /* Q(2+2*Qr-32+1) */ Q_num = sub( shl( add( add( X1_DTFS_fx.Q, X2_DTFS_fx.Q ), Qr ), 1 ), 32 ); /* PORTING: Handling the functions with variable no. of arguments */ @@ -1483,7 +1483,7 @@ static Word32 DTFS_freq_corr_fx( #ifdef ISSUE_1867_replace_overflow_libenc E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ //??sat //??sat #else - E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ + E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ #endif /* PORTING: Handling the functions with variable no. of arguments */ E_fx = DTFS_getEngy_band_fx( X2_DTFS_fx, lband, hband ); /* Q(1) */ @@ -1497,9 +1497,9 @@ static Word32 DTFS_freq_corr_fx( #ifdef ISSUE_1867_replace_overflow_libenc E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ //??sat //??sat #else - E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ + E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ #endif - Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ + Den = L_mult0( E1_fx, E2_fx ); /* Q(2+q1+q2-32+1) */ Q_den = sub( add( shl( add( X2_DTFS_fx.Q, X1_DTFS_fx.Q ), 1 ), add( q1, q2 ) ), 32 ); Num = L_max( Num, 1 ); -- GitLab From e3989cac59a0a5ec10634928682dd2f7f6423bc0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 19 Aug 2025 07:50:37 +0200 Subject: [PATCH 45/80] clang format patch --- lib_enc/vad_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 6a8b06a57..64043975f 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -223,7 +223,7 @@ static void sign_thr_snr_acc_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); - /* Q4 */ //??sat + /* Q4 */ //??sat #else *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif -- GitLab From e8bbd62eabd24763100cce1d80f404ecc6405bdf Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 19 Aug 2025 08:04:26 +0200 Subject: [PATCH 46/80] buildfix --- lib_enc/scale_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index bc3bdda69..f0508b67c 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,7 +86,7 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; -#if !defined( ISSUE_1867_replace_overflow_libenc ) & 6 !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -- GitLab From 383e78b1814f977e6579bd10506ea092698169ad Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 19 Aug 2025 11:11:04 +0200 Subject: [PATCH 47/80] fix potential flaw --- lib_dec/dec_post_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index d2130cddc..ccfb26a47 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -1720,7 +1720,7 @@ void blend_subfr2_fx( FOR( i = 0; i < L_SUBFR / 2; i++ ) { #ifdef ISSUE_1866_replace_overflow_libdec - sigOut[i] = mac_r_sat( L_mult( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat + sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat fac1 = sub_sat( fac1, step ); //??sat fac2 = add_sat( fac2, step ); //??sat #else -- GitLab From eca10a23b7b8ec19698481b133a6cefa2012ec9c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 19 Aug 2025 11:24:01 +0200 Subject: [PATCH 48/80] Revert "fix potential flaw" This reverts commit 383e78b1814f977e6579bd10506ea092698169ad. --- lib_dec/dec_post_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index ccfb26a47..d2130cddc 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -1720,7 +1720,7 @@ void blend_subfr2_fx( FOR( i = 0; i < L_SUBFR / 2; i++ ) { #ifdef ISSUE_1866_replace_overflow_libdec - sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat + sigOut[i] = mac_r_sat( L_mult( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat fac1 = sub_sat( fac1, step ); //??sat fac2 = add_sat( fac2, step ); //??sat #else -- GitLab From 88939336ebac10aac14d1a615ee4f29ef147e567 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 09:22:37 +0200 Subject: [PATCH 49/80] Reapply "fix potential flaw" This reverts commit eca10a23b7b8ec19698481b133a6cefa2012ec9c. --- lib_dec/dec_post_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index d2130cddc..ccfb26a47 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -1720,7 +1720,7 @@ void blend_subfr2_fx( FOR( i = 0; i < L_SUBFR / 2; i++ ) { #ifdef ISSUE_1866_replace_overflow_libdec - sigOut[i] = mac_r_sat( L_mult( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat + sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx //??sat fac1 = sub_sat( fac1, step ); //??sat fac2 = add_sat( fac2, step ); //??sat #else -- GitLab From 6fc6220e86d26ecc9f57109b9f43b033d48ddd5e Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 09:27:57 +0200 Subject: [PATCH 50/80] use s* from main --- lib_enc/scale_enc_fx.c | 26 --- lib_enc/set_impulse_fx.c | 50 ++--- lib_enc/sig_clas_fx.c | 12 -- lib_enc/speech_music_classif_fx.c | 70 +------ lib_enc/stat_noise_uv_enc_fx.c | 32 +-- lib_enc/swb_bwe_enc_fx.c | 156 ++------------- lib_enc/swb_bwe_enc_hr_fx.c | 6 - lib_enc/swb_bwe_enc_lr_fx.c | 9 +- lib_enc/swb_pre_proc_fx.c | 24 --- lib_enc/swb_tbe_enc_fx.c | 320 +++++++----------------------- 10 files changed, 113 insertions(+), 592 deletions(-) diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index f0508b67c..32633c89d 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,11 +86,9 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; -#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /*---------------------------------------------------------------* @@ -99,16 +97,11 @@ void Preemph_scaled( *---------------------------------------------------------------*/ BASOP_SATURATE_WARNING_OFF_EVS - -#ifdef ISSUE_1867_replace_overflow_libenc - QVal = shl_sat( 1, sub( 15, bits ) ); //?sat -#else Overflow = 0; #ifdef ISSUE_1796_replace_shl_o QVal = shl_sat( 1, sub( 15, bits ) ); #else QVal = shl_o( 1, sub( 15, bits ), &Overflow ); -#endif #endif BASOP_SATURATE_WARNING_ON_EVS mu = shr( Preemph_factor, bits ); /* Q15 --> Q(15-bits) */ @@ -126,11 +119,7 @@ void Preemph_scaled( /* Equivalent to tmp = max((abs(x[i] - mu*x[i-1]),tmp) * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat -#else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); -#endif L_tmp = L_abs( L_tmp ); L_maxloc = L_max( L_tmp, L_maxloc ); } @@ -180,11 +169,7 @@ void Preemph_scaled( FOR( i = sub( Lframe, 1 ); i > 0; i-- ) { L_tmp = L_mult( new_speech[i], QVal ); -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat -#else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); -#endif L_tmp = L_shl( L_tmp, *Q_new ); new_speech[i] = round_fx_sat( L_tmp ); // Q_new } @@ -217,10 +202,8 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled { Word16 i; Word32 e_min_scaled; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif #endif e_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( *Q_new, QSCALE ) ) ), 1 ), 1 ); @@ -250,21 +233,12 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled /* Do scaling and valide minimum energy value */ FOR( i = 0; i < NB_BANDS; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); //??sat - bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); //??sat - ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); //??sat - ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); //??sat - st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); //??sat - st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); //??sat -#else enrO[i] = L_max( L_shl_o( enrO[i], Q_exp, &Overflow ), e_min_scaled ); bckr[i] = L_max( L_shl_o( bckr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr[i] = L_max( L_shl_o( ave_enr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr2[i] = L_max( L_shl_o( ave_enr2[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands1[i] = L_max( L_shl_o( st_fr_bands1[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands2[i] = L_max( L_shl_o( st_fr_bands2[i], Q_exp, &Overflow ), e_min_scaled ); -#endif move32(); move32(); move32(); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 76a4b1afb..7a2224611 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -65,11 +65,9 @@ void set_impulse_fx( Word16 krit_fx, krit_max_fx, gain16; Word32 Lrr, Ldd, Ltmp, Ltmp1; const Word16 *pt_Glt; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif krit_max_fx = -32768; move16(); @@ -121,21 +119,12 @@ void set_impulse_fx( /* nominator & DEnominator row <0> */ FOR( i = 0; i < L_SUBFR; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat - Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat -#else - Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 -#endif + Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 } rr_fx[start1] = Lrr; move32(); -#ifdef ISSUE_1867_replace_overflow_libenc - dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat -#else - dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 -#endif + dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 rr_fx[start1] = L_max( rr_fx[start1], 1 ); FOR( i = add( start1, 1 ); i < L_IMPULSE2; i++ ) @@ -149,25 +138,15 @@ void set_impulse_fx( gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ), Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); -#ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat - Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat -#else - Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 -#endif + Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 } gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); -#ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat - Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat -#else - Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 -#endif - dd_fx[i] = round_fx_sat( Ldd ); // Q11 + Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 + dd_fx[i] = round_fx_sat( Ldd ); // Q11 rr_fx[i] = L_max( Lrr, 1 ); move32(); /* move rr and dd into rr[i] and dd[i] */ @@ -200,11 +179,8 @@ void set_impulse_fx( FOR( i = L_SUBFR - 2; i >= start2; i-- ) { /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ -#ifdef ISSUE_1867_replace_overflow_libenc - rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 //??sat -#else - rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 -#endif + rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], + gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 move32(); } /* nominator rows */ @@ -226,10 +202,10 @@ void set_impulse_fx( num = div_s( num, den ); -#ifdef ISSUE_1867_replace_overflow_libenc - krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat +#ifdef ISSUE_1796_replace_shl_o + krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ #else - krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ #endif IF( GT_16( krit_fx, krit_max_fx ) ) diff --git a/lib_enc/sig_clas_fx.c b/lib_enc/sig_clas_fx.c index 6e61e0862..beb97514a 100644 --- a/lib_enc/sig_clas_fx.c +++ b/lib_enc/sig_clas_fx.c @@ -56,11 +56,9 @@ Word16 signal_clas_fx( /* o : classification for current Word16 i, clas, pc, zc, lo, lo2, hi, hi2, exp_ee, frac_ee; Word16 tmp16, tmpS; const Word16 *pt1; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /*----------------------------------------------------------------* @@ -155,11 +153,7 @@ Word16 signal_clas_fx( /* o : classification for current Ltmp = L_mac( Ltmp, relEn, 10923 ); Ltmp = L_mac( Ltmp, pcn, 10923 ); -#ifdef ISSUE_1867_replace_overflow_libenc - fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat -#else fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ -#endif /*-----------------------------------------------------------------* * FEC classification @@ -293,11 +287,9 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur Word16 tmp16, tmpS; const Word16 *pt1; Word64 tmp64; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /*----------------------------------------------------------------* @@ -393,11 +385,7 @@ Word16 signal_clas_ivas_fx( /* o : classification for cur Ltmp = L_mac( Ltmp, relEn, 10923 ); Ltmp = L_mac( Ltmp, pcn, 10923 ); -#ifdef ISSUE_1867_replace_overflow_libenc - fmerit1 = round_fx_sat( L_shl_sat( Ltmp, 16 - 10 - 1 ) ); /* fmerit1 ->Q15 */ //??sat //??sat -#else fmerit1 = round_fx_o( L_shl_o( Ltmp, 16 - 10 - 1, &Overflow ), &Overflow ); /* fmerit1 ->Q15 */ -#endif /*-----------------------------------------------------------------* * FEC classification diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 4f809d827..65f3fb1b8 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -662,11 +662,9 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis Word16 tmp1, tmp2, exp2, scale, exp3; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif /*------------------------------------------------------------------* @@ -796,18 +794,10 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis sum_PS = L_deposit_l( 0 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sum_PS = L_add_sat( sum_PS, PS[i] ); //??sat -#else sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); -#endif } exp1 = norm_l( sum_PS ); -#ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); //??sat -#else tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); -#endif exp1 = sub( 30, exp1 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) @@ -815,11 +805,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*PS_norm[i] = PS[i] / sum_PS;*/ /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); -#ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); //??sat -#else tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); -#endif exp2 = sub( 30, exp2 ); scale = shr( sub( tmp1, tmp2 ), 15 ); @@ -880,11 +866,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis ELSE { exp1 = norm_l( L_add( dPS[i], 336 ) ); -#ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); //??sat //??sat -#else tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); -#endif exp1 = sub( 30, exp1 ); exp2 = norm_l( mx ); @@ -941,11 +923,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = 0; i < N_FEATURES; i++ ) { /**pFV = pSF[0] * *pFV + pSF[1];*/ -#ifdef ISSUE_1867_replace_overflow_libenc - *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); //??sat //??sat -#else *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); -#endif move16(); pFV++; } @@ -976,11 +954,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ -#ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); //??sat -#else xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); -#endif move16(); /*Q15 */ } @@ -996,11 +970,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ -#ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); //??sat -#else xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); -#endif move16(); /*Q15 */ } @@ -1015,11 +985,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ -#ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); //??sat -#else xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); -#endif move16(); /*Q15 */ } @@ -1033,11 +999,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ -#ifdef ISSUE_1867_replace_overflow_libenc - lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat -#else - lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ -#endif + lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ lps = s_max( lps, -10832 ); lpm = extract_h( L_shl( L_sub( max_m, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ @@ -1045,11 +1007,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ -#ifdef ISSUE_1867_replace_overflow_libenc - lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat -#else - lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ -#endif + lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ lpn = s_max( lpn, -10832 ); *high_lpn_flag_ptr = 0; @@ -1501,11 +1459,9 @@ static Word16 attack_det_fx( /* o : attack flag Word16 i, j, tmp, tmp1, attack, exp1; Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG]; Word16 att_3lsub_pos; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -1523,11 +1479,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat -#else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ -#endif } finc[i] = L_tmp; @@ -1552,11 +1504,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( i = 1; i < att_3lsub_pos; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat -#else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ -#endif + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -1568,11 +1516,7 @@ static Word16 attack_det_fx( /* o : attack flag L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ FOR( i = 1; i < tmp1; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat -#else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ -#endif + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -2671,11 +2615,9 @@ static Word16 attack_det_ivas_fx( /* o : attack flag Word64 W_tmp; Word16 q_diff; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -2693,11 +2635,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat -#else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ -#endif } finc[i] = L_tmp; diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 38a36083e..598745ebd 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -50,11 +50,9 @@ void stat_noise_uv_enc_fx( Word16 noisiness = 0; move16(); Word16 num, den, expn, expd; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif test(); test(); @@ -67,20 +65,12 @@ void stat_noise_uv_enc_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); -#ifdef ISSUE_1867_replace_overflow_libenc - num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ -#else num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ -#endif expd = norm_l( LepsP[1] ); -#ifdef ISSUE_1867_replace_overflow_libenc - den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ -#else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ -#endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -133,11 +123,9 @@ void stat_noise_uv_enc_ivas_fx( Word16 noisiness = 0; move16(); Word16 num, den, expn, expd; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif test(); test(); @@ -150,20 +138,12 @@ void stat_noise_uv_enc_ivas_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); -#ifdef ISSUE_1867_replace_overflow_libenc - num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ -#else num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ -#endif expd = norm_l( LepsP[1] ); -#ifdef ISSUE_1867_replace_overflow_libenc - den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ -#else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ -#endif - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 280624b4f..40fefd684 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -303,11 +303,9 @@ void swb_bwe_enc_ivas_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif Word16 fb_band_begin; Word16 q_new_input_hp; @@ -410,11 +408,7 @@ void swb_bwe_enc_ivas_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat -#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); -#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -548,12 +542,8 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ -#ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat -#else + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#endif } ELSE { @@ -633,11 +623,9 @@ void swb_bwe_enc_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -695,11 +683,7 @@ void swb_bwe_enc_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat -#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); -#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -821,12 +805,8 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ -#ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat -#else + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#endif } ELSE { @@ -1027,11 +1007,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class Word16 sharplimit; Word16 numsharp, num, den; Word16 numharmonic, tmp, expn, expd, scale; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1068,28 +1046,16 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class { IF( hBWE_FD->prev_global_gain_fx == 0 ) { -#ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat -#else - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ -#endif + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ } ELSE { expn = norm_l( fGain ); -#ifdef ISSUE_1867_replace_overflow_libenc - num = extract_h( L_shl( fGain, expn ) ); -#else num = extract_h( L_shl_o( fGain, expn, &Overflow ) ); -#endif expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) ); expd = norm_l( hBWE_FD->prev_global_gain_fx ); -#ifdef ISSUE_1867_replace_overflow_libenc - den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) ); -#else den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) ); -#endif expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); @@ -1105,7 +1071,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class #ifdef ISSUE_1796_replace_shl_o gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ #else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif } test(); @@ -1195,13 +1161,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ -#ifdef ISSUE_1867_replace_overflow_libenc - sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat -#else + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ -#endif } ELSE { @@ -1401,11 +1363,9 @@ static void vqWithCand_w_fx( const Word16 *p_E_ROM_dico; Word16 dist, temp1; Word32 L_dist, L_tmp; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif IF( flag ) { @@ -1422,22 +1382,14 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat -#else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ -#endif - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat -#else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); -#endif L_tmp = L_mult( temp1, w[j] ); /*Q22 */ L_tmp = Mult_32_16( L_tmp, temp1 ); /*Q15 */ L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */ @@ -1712,11 +1664,9 @@ static void msvq_interpol_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2], tmp; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* Extract target vector */ @@ -1757,21 +1707,13 @@ static void msvq_interpol_fx( /* Extract vector for odd position */ FOR( n_band = 0; n_band < DIM11; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat -#else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); -#endif move16(); } FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat -#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ -#endif tmp = shr( tmp, 1 ); quant_tmp2[n_band] = sub( env_temp12[n_band], tmp ); move16(); /*Q8 */ @@ -1794,11 +1736,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat -#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); -#endif tmp = shr( tmp, 1 ); quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] ); move16(); /*Q8 */ @@ -1858,11 +1796,9 @@ static void msvq_interpol_2_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2]; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* Extract target vector */ FOR( n_band = 0; n_band < DIM11 - 1; n_band++ ) @@ -1920,17 +1856,9 @@ static void msvq_interpol_2_fx( move16(); FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat -#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); -#endif tmp_q = shr( tmp_q, 1 ); -#ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat -#else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); -#endif move16(); } @@ -1951,17 +1879,9 @@ static void msvq_interpol_2_fx( move16(); /*Q8 */ FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat -#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); -#endif tmp_q = shr( tmp_q, 1 ); -#ifdef ISSUE_1867_replace_overflow_libenc - quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat -#else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); -#endif } L_dist = L_deposit_l( 0 ); @@ -2023,11 +1943,9 @@ static void calculate_Tonality_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2133,11 +2051,7 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2158,11 +2072,7 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2191,11 +2101,9 @@ static void calculate_Tonality_ivas_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2301,11 +2209,7 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2326,11 +2230,7 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2718,11 +2618,9 @@ static Word16 SWB_BWE_encoding_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -2765,11 +2663,7 @@ static Word16 SWB_BWE_encoding_fx( } /* tilt returned in Q24 go to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat -#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); -#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -2873,11 +2767,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat -#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ -#endif } ELSE { @@ -2889,11 +2779,7 @@ static Word16 SWB_BWE_encoding_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat -#else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ -#endif + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -3177,11 +3063,9 @@ static Word16 SWB_BWE_encoding_ivas_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif Word16 inner_frame; Word16 q_shift; @@ -3242,11 +3126,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( } /* tilt returned in Q24 go to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat -#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); -#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -3351,11 +3231,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); expd = norm_l( WB_tenv_syn_fx ); -#ifdef ISSUE_1867_replace_overflow_libenc - den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat -#else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); -#endif expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); @@ -3368,11 +3244,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat -#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ -#endif } ELSE { @@ -3382,12 +3254,8 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat -#else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ -#endif + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index d7cebe322..dc962d1bc 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -117,11 +117,9 @@ void swb_bwe_enc_hr_fx( #else Word32 L_t_audio_tmp_fx[L_FRAME48k]; #endif -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -770,11 +768,7 @@ void swb_bwe_enc_hr_fx( { L_tmp = L_mult( temp, t_audio_fx[i] ); L_tmp = L_shr_sat( L_tmp, temp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat -#else t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); -#endif move16(); } diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 2dedbfbeb..3c92c7f89 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -698,11 +698,9 @@ static void gethar_noisegn_fx( Word16 temp_lo, temp_hi; Word16 Qg; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif /*Generate HF noise*/ genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow, @@ -784,14 +782,9 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ -#ifdef ISSUE_1867_replace_overflow_libenc - L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat - g_fx = round_fx_sat( L_temp ); //??sat -#else + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); -#endif } gqlevs_fx = 4; diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index cb5a5ca52..ca7233c95 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -523,11 +523,9 @@ void swb_pre_proc_fx( Word16 ts, nB, uB; /* Highband energy computation using CLDFB */ Word32 CldfbHB_ener; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif Word16 realQ_neg1, imagQ_neg1, exp, Cldfbtemp1; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -709,13 +707,8 @@ void swb_pre_proc_fx( realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ -#ifdef ISSUE_1867_replace_overflow_libenc - CldfbHB_ener = L_mac0_sat( CldfbHB_ener, realQ_neg1, realQ_neg1 ); //??sat - CldfbHB_ener = L_mac0_sat( CldfbHB_ener, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat -#else CldfbHB_ener = L_mac0_o( CldfbHB_ener, realQ_neg1, realQ_neg1, &Overflow ); CldfbHB_ener = L_mac0_o( CldfbHB_ener, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ -#endif } } @@ -1115,11 +1108,9 @@ void swb_pre_proc_ivas_fx( { Word32 CldfbHB_fx = 0; // fixed counterpart Word16 CldfbHB_fx_e = 0; // fixed counterpart -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif Word16 realQ_neg1, imagQ_neg1, exp = 0, Cldfbtemp1; move32(); @@ -1228,13 +1219,8 @@ void swb_pre_proc_ivas_fx( realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 16 ) ); /* Q(-1), headroom needed */ -#ifdef ISSUE_1867_replace_overflow_libenc - CldfbHB_fx = L_mac0_sat( CldfbHB_fx, realQ_neg1, realQ_neg1 ); //??sat - CldfbHB_fx = L_mac0_sat( CldfbHB_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat -#else CldfbHB_fx = L_mac0_o( CldfbHB_fx, realQ_neg1, realQ_neg1, &Overflow ); CldfbHB_fx = L_mac0_o( CldfbHB_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ -#endif } } CldfbHB_fx_e = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); @@ -1268,13 +1254,8 @@ void swb_pre_proc_ivas_fx( { realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ -#ifdef ISSUE_1867_replace_overflow_libenc - icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, realQ_neg1, realQ_neg1 ); //??sat - icbweRefEner_fx = L_mac0_sat( icbweRefEner_fx, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat -#else icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, realQ_neg1, realQ_neg1, &Overflow ); icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ -#endif } } exp_icbweRefEner_fx = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); @@ -1293,13 +1274,8 @@ void swb_pre_proc_ivas_fx( realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ -#ifdef ISSUE_1867_replace_overflow_libenc - lbEner = L_mac0_sat( lbEner, realQ_neg1, realQ_neg1 ); //??sat - lbEner = L_mac0_sat( lbEner, imagQ_neg1, imagQ_neg1 ); /* Q(-2) */ //??sat -#else lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ -#endif } } exp_lbEner = sub( Q31, shl( sub( q_reImBuffer, Q16 ), 1 ) ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 09560f568..f243cd27c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -745,11 +745,9 @@ void wb_tbe_enc_fx( Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif /*Word16 att = 32767;*/ @@ -1218,13 +1216,8 @@ void wb_tbe_enc_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat - tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat -#else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ -#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -1354,11 +1347,9 @@ void wb_tbe_enc_ivas_fx( Word16 dummy = 0; Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif move16(); @@ -1390,11 +1381,7 @@ void wb_tbe_enc_ivas_fx( FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); -#ifdef ISSUE_1867_replace_overflow_libenc - hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); //??sat -#else hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); -#endif move16(); i--; k++; @@ -1884,13 +1871,8 @@ void wb_tbe_enc_ivas_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat - tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat -#else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); - tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ -#endif + tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -2071,11 +2053,9 @@ void swb_tbe_enc_fx( Word16 tilt_para; Word16 Q_bwe_exc_fb; Word16 n_subfr_saturation; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; @@ -2543,13 +2523,8 @@ void swb_tbe_enc_fx( curr_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ //??sat - curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ //??sat -#else prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ curr_pow_fx = L_mac0_o( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], &Overflow ); /* 2*Q_bwe_exc */ -#endif } if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) @@ -2583,20 +2558,12 @@ void swb_tbe_enc_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat -#else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ -#endif + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ -#ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat -#else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ -#endif + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } } @@ -2605,19 +2572,11 @@ void swb_tbe_enc_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat -#else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ -#endif + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ -#ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat -#else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ -#endif + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } } @@ -2846,13 +2805,9 @@ void swb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ -#ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat -#else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ -#endif + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -3040,11 +2995,9 @@ void swb_tbe_enc_ivas_fx( Word16 tilt_para_fx; Word16 Q_bwe_exc_fb; Word16 n_subfr_saturation; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif Env_error_fx = 0; @@ -3903,12 +3856,8 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ -#ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat -#else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ -#endif + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } IF( exp < 0 ) @@ -3925,20 +3874,12 @@ void swb_tbe_enc_ivas_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat -#else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ -#endif + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ -#ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat -#else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ -#endif + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } } @@ -3947,19 +3888,11 @@ void swb_tbe_enc_ivas_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat -#else - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ -#endif + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ -#ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat -#else - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ -#endif + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } } @@ -4466,13 +4399,9 @@ void swb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ -#ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat -#else - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ -#endif + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); tmp = s_max( tmp, 19661 /*0.6f Q15*/ ); @@ -4627,11 +4556,9 @@ static void EstimateSHBFrameGain_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif move16(); @@ -4742,47 +4669,27 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat -#else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ -#endif + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat -#else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ -#endif + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat -#else - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ -#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -4791,33 +4698,30 @@ static void EstimateSHBFrameGain_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat +#ifdef ISSUE_1796_replace_shl_o + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat +#ifdef ISSUE_1796_replace_shl_o + sig = shl_sat( oriSHB[i], scaling ); #else sig = shl_o( oriSHB[i], scaling, &Overflow ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat +#ifdef ISSUE_1796_replace_shl_o + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } } L_tmp = root_a_over_b_fx( oriNrg, 2 * Q_oriSHB, synNrg, 2 * Q_synSHB, &exp_out ); @@ -4853,11 +4757,9 @@ static void EstimateSHBFrameGain_ivas_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif move16(); @@ -4968,47 +4870,27 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat -#else - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ -#endif + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat -#else - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ -#endif + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat -#else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ -#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -5017,33 +4899,30 @@ static void EstimateSHBFrameGain_ivas_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat +#ifdef ISSUE_1796_replace_shl_o + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat +#ifdef ISSUE_1796_replace_shl_o + sig = shl_sat( oriSHB[i], scaling ); #else sig = shl_o( oriSHB[i], scaling, &Overflow ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat +#ifdef ISSUE_1796_replace_shl_o + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } } L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out ); @@ -5157,11 +5036,9 @@ static void EstimateSHBGainShape_fx( Word16 length_tmp; Word32 L_tmp, normFact; Word16 scaling = 0; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif move32(); move16(); @@ -5279,44 +5156,26 @@ static void EstimateSHBGainShape_fx( j = i_mult2( join_length, i ); FOR( k = 0; k < length; k++ ) { - sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -#ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -#else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#endif + sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ } FOR( k = 0; k < ( join_length - length ); k++ ) { - sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ -#ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat -#else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#endif + sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ } FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ -#ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat -#else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ -#endif + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ scaling = 0; @@ -5363,13 +5222,8 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat - L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat -#else - subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ -#endif + subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ move16(); } @@ -5383,12 +5237,8 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ -#ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat -#else + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#endif move16(); } } @@ -5396,12 +5246,8 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ -#ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat -#else - subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ -#endif + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ move16(); } } @@ -7041,11 +6887,9 @@ static void first_VQstages_fx( move16(); Word16 maxC = LSFMBEST; move16(); -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif /*float dd[16];*/ @@ -7072,13 +6916,9 @@ static void first_VQstages_fx( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat -#else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ -#endif - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_tmp, maxC ); @@ -7566,11 +7406,9 @@ void fb_tbe_enc_fx( Word16 tmp, tmp1, tmp2, exp, exp2, exp_norm; Word16 s_max_value, exp_temp, i; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif s_max_value = 0; FOR( i = 0; i < L_FRAME48k; i++ ) @@ -7605,13 +7443,9 @@ void fb_tbe_enc_fx( Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat -#else + temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ -#endif - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ -- GitLab From 555905347610bbd128dc97c362dba6dd010edf76 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 09:41:07 +0200 Subject: [PATCH 51/80] clang patch --- lib_enc/nois_est_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 927dda9b3..f5551ed48 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2546,7 +2546,7 @@ void noise_est_ivas_fx( #ifdef FIX_ISSUE_1811_EXCEEDING_W_SHIFTS w_tmp = W_shl( num, s_min( 63, sub( q_fr_bands, sub( ExpNum, ExpDen ) ) ) ); // q_fr_bands+15 #else - w_tmp = W_shl( num, sub( q_fr_bands, sub( ExpNum, ExpDen ) ) ); // q_fr_bands+15 + w_tmp = W_shl( num, sub( q_fr_bands, sub( ExpNum, ExpDen ) ) ); // q_fr_bands+15 #endif w_sum_num = W_add( w_sum_num, w_tmp ); -- GitLab From 22b17f18890389f16fef10ad4cc7f03e857226e5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 10:39:14 +0200 Subject: [PATCH 52/80] re-use swb_[tbe,bwe]_enc* from 9b193cb --- lib_enc/swb_bwe_enc_fx.c | 156 ++++++++++++++++-- lib_enc/swb_bwe_enc_hr_fx.c | 6 + lib_enc/swb_bwe_enc_lr_fx.c | 9 +- lib_enc/swb_tbe_enc_fx.c | 320 +++++++++++++++++++++++++++--------- 4 files changed, 401 insertions(+), 90 deletions(-) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 40fefd684..280624b4f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -303,9 +303,11 @@ void swb_bwe_enc_ivas_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 fb_band_begin; Word16 q_new_input_hp; @@ -408,7 +410,11 @@ void swb_bwe_enc_ivas_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat +#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); +#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -542,8 +548,12 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat +#else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE { @@ -623,9 +633,11 @@ void swb_bwe_enc_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -683,7 +695,11 @@ void swb_bwe_enc_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat +#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); +#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -805,8 +821,12 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat +#else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE { @@ -1007,9 +1027,11 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class Word16 sharplimit; Word16 numsharp, num, den; Word16 numharmonic, tmp, expn, expd, scale; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1046,16 +1068,28 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class { IF( hBWE_FD->prev_global_gain_fx == 0 ) { - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ +#ifdef ISSUE_1867_replace_overflow_libenc + gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat +#else + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { expn = norm_l( fGain ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( fGain, expn ) ); +#else num = extract_h( L_shl_o( fGain, expn, &Overflow ) ); +#endif expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) ); expd = norm_l( hBWE_FD->prev_global_gain_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) ); +#else den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) ); +#endif expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); @@ -1071,7 +1105,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class #ifdef ISSUE_1796_replace_shl_o gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ #else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif } test(); @@ -1161,9 +1195,13 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ +#ifdef ISSUE_1867_replace_overflow_libenc + sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat +#else sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ +#endif } ELSE { @@ -1363,9 +1401,11 @@ static void vqWithCand_w_fx( const Word16 *p_E_ROM_dico; Word16 dist, temp1; Word32 L_dist, L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif IF( flag ) { @@ -1382,14 +1422,22 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat +#else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ +#endif + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat +#else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); +#endif L_tmp = L_mult( temp1, w[j] ); /*Q22 */ L_tmp = Mult_32_16( L_tmp, temp1 ); /*Q15 */ L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */ @@ -1664,9 +1712,11 @@ static void msvq_interpol_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2], tmp; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Extract target vector */ @@ -1707,13 +1757,21 @@ static void msvq_interpol_fx( /* Extract vector for odd position */ FOR( n_band = 0; n_band < DIM11; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat +#else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); +#endif move16(); } FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat +#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ +#endif tmp = shr( tmp, 1 ); quant_tmp2[n_band] = sub( env_temp12[n_band], tmp ); move16(); /*Q8 */ @@ -1736,7 +1794,11 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat +#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); +#endif tmp = shr( tmp, 1 ); quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] ); move16(); /*Q8 */ @@ -1796,9 +1858,11 @@ static void msvq_interpol_2_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2]; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Extract target vector */ FOR( n_band = 0; n_band < DIM11 - 1; n_band++ ) @@ -1856,9 +1920,17 @@ static void msvq_interpol_2_fx( move16(); FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat +#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); +#endif tmp_q = shr( tmp_q, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat +#else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); +#endif move16(); } @@ -1879,9 +1951,17 @@ static void msvq_interpol_2_fx( move16(); /*Q8 */ FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat +#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); +#endif tmp_q = shr( tmp_q, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat +#else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); +#endif } L_dist = L_deposit_l( 0 ); @@ -1943,9 +2023,11 @@ static void calculate_Tonality_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2051,7 +2133,11 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2072,7 +2158,11 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2101,9 +2191,11 @@ static void calculate_Tonality_ivas_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2209,7 +2301,11 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2230,7 +2326,11 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2618,9 +2718,11 @@ static Word16 SWB_BWE_encoding_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -2663,7 +2765,11 @@ static Word16 SWB_BWE_encoding_fx( } /* tilt returned in Q24 go to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat +#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); +#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -2767,7 +2873,11 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { @@ -2779,7 +2889,11 @@ static Word16 SWB_BWE_encoding_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat +#else + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -3063,9 +3177,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 inner_frame; Word16 q_shift; @@ -3126,7 +3242,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( } /* tilt returned in Q24 go to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat +#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); +#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -3231,7 +3351,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); expd = norm_l( WB_tenv_syn_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat +#else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); +#endif expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); @@ -3244,7 +3368,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { @@ -3254,8 +3382,12 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat +#else + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index dc962d1bc..d7cebe322 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -117,9 +117,11 @@ void swb_bwe_enc_hr_fx( #else Word32 L_t_audio_tmp_fx[L_FRAME48k]; #endif +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -768,7 +770,11 @@ void swb_bwe_enc_hr_fx( { L_tmp = L_mult( temp, t_audio_fx[i] ); L_tmp = L_shr_sat( L_tmp, temp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat +#else t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); +#endif move16(); } diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 3c92c7f89..2dedbfbeb 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -698,9 +698,11 @@ static void gethar_noisegn_fx( Word16 temp_lo, temp_hi; Word16 Qg; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*Generate HF noise*/ genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow, @@ -782,9 +784,14 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat + g_fx = round_fx_sat( L_temp ); //??sat +#else L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); +#endif } gqlevs_fx = 4; diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index f243cd27c..09560f568 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -745,9 +745,11 @@ void wb_tbe_enc_fx( Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*Word16 att = 32767;*/ @@ -1216,8 +1218,13 @@ void wb_tbe_enc_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat + tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat +#else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ +#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -1347,9 +1354,11 @@ void wb_tbe_enc_ivas_fx( Word16 dummy = 0; Word16 avg_voice_fac; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif move16(); @@ -1381,7 +1390,11 @@ void wb_tbe_enc_ivas_fx( FOR( j = 0; j < L_SUBFR16k; j = j + 4 ) { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); +#ifdef ISSUE_1867_replace_overflow_libenc + hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); //??sat +#else hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); +#endif move16(); i--; k++; @@ -1871,8 +1884,13 @@ void wb_tbe_enc_ivas_fx( exp = norm_s( voicingBufAvg_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat + tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat +#else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); - tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ + tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ +#endif } tmp = s_max( s_min( tmp, 32767 ), 22938 ); /* Q15 */ @@ -2053,9 +2071,11 @@ void swb_tbe_enc_fx( Word16 tilt_para; Word16 Q_bwe_exc_fb; Word16 n_subfr_saturation; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; RF_ENC_HANDLE hRF = st_fx->hRF; @@ -2523,8 +2543,13 @@ void swb_tbe_enc_fx( curr_pow_fx = L_shl( 21475l /*0.00001f Q31*/, tmp ); /* 2*(Q_bwe_exc) */ FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ //??sat + curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ //??sat +#else prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ curr_pow_fx = L_mac0_o( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], &Overflow ); /* 2*Q_bwe_exc */ +#endif } if ( GT_16( voice_factors_fx[0], 24576 /*0.75f Q15*/ ) ) @@ -2558,12 +2583,20 @@ void swb_tbe_enc_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -2572,11 +2605,19 @@ void swb_tbe_enc_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -2805,9 +2846,13 @@ void swb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat +#else + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ +#endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); @@ -2995,9 +3040,11 @@ void swb_tbe_enc_ivas_fx( Word16 tilt_para_fx; Word16 Q_bwe_exc_fb; Word16 n_subfr_saturation; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif Env_error_fx = 0; @@ -3856,8 +3903,12 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { - L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } IF( exp < 0 ) @@ -3874,12 +3925,20 @@ void swb_tbe_enc_ivas_fx( { FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -3888,11 +3947,19 @@ void swb_tbe_enc_ivas_fx( FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); - L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat +#else + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ +#endif tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); - L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ - shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat +#else + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ +#endif move16(); } } @@ -4399,9 +4466,13 @@ void swb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ /* sd_uq_q*pitBufAvg */ - L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ - L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ - tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ + L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ + L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat +#else + tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ +#endif } tmp = s_min( tmp, 32767 /*1.0f Q15*/ ); tmp = s_max( tmp, 19661 /*0.6f Q15*/ ); @@ -4556,9 +4627,11 @@ static void EstimateSHBFrameGain_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif move16(); @@ -4669,27 +4742,47 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat +#else + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB */ +#endif } FOR( ; i < l_frame; i++ ) { - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat +#else + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ +#endif } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { - sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat +#else + sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ +#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -4698,30 +4791,33 @@ static void EstimateSHBFrameGain_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = shl_sat( oriSHB[i], scaling ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = shl_sat( oriSHB[i], scaling ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = shl_o( oriSHB[i], scaling, &Overflow ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } } L_tmp = root_a_over_b_fx( oriNrg, 2 * Q_oriSHB, synNrg, 2 * Q_synSHB, &exp_out ); @@ -4757,9 +4853,11 @@ static void EstimateSHBFrameGain_ivas_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move16(); @@ -4870,27 +4968,47 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { - sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ - sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat +#else + sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ + sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[i] ), &Overflow ); /*Q_synSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_synSHB - 2*/ +#endif } FOR( ; i < l_frame; i++ ) { - oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ - sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat +#else + oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ + sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ +#endif } tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat +#else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ), &Overflow ); /* Q_oriSHB */ synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB - 2*/ +#endif } IF( EQ_32( oriNrg, MAX_32 ) ) { @@ -4899,30 +5017,33 @@ static void EstimateSHBFrameGain_ivas_fx( move32(); FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[i] ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = shl_sat( oriSHB[i], scaling ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = shl_sat( oriSHB[i], scaling ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = shl_o( oriSHB[i], scaling, &Overflow ); -#endif oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ +#endif } FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1796_replace_shl_o - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else sig = mult_r( shl_o( oriSHB[i], scaling, &Overflow ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ } } L_tmp = root_a_over_b_fx( oriNrg, shl( Q_oriSHB, 1 ), synNrg, sub( shl( Q_synSHB, 1 ), 2 ), &exp_out ); @@ -5036,9 +5157,11 @@ static void EstimateSHBGainShape_fx( Word16 length_tmp; Word32 L_tmp, normFact; Word16 scaling = 0; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif move32(); move16(); @@ -5156,26 +5279,44 @@ static void EstimateSHBGainShape_fx( j = i_mult2( join_length, i ); FOR( k = 0; k < length; k++ ) { - sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ +#else + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif } FOR( k = 0; k < ( join_length - length ); k++ ) { - sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif } FOR( k = 0; k < length; k++ ) { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#ifdef ISSUE_1867_replace_overflow_libenc + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat +#else + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ +#endif } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ scaling = 0; @@ -5222,8 +5363,13 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { - subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ +#ifdef ISSUE_1867_replace_overflow_libenc + subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat + L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat +#else + subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ +#endif move16(); } @@ -5237,8 +5383,12 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ +#ifdef ISSUE_1867_replace_overflow_libenc + subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat +#else subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#endif move16(); } } @@ -5246,8 +5396,12 @@ static void EstimateSHBGainShape_fx( { FOR( i = 0; i < num_gains; i++ ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ - subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ +#ifdef ISSUE_1867_replace_overflow_libenc + subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat +#else + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ +#endif move16(); } } @@ -6887,9 +7041,11 @@ static void first_VQstages_fx( move16(); Word16 maxC = LSFMBEST; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*float dd[16];*/ @@ -6916,9 +7072,13 @@ static void first_VQstages_fx( L_tmp = L_deposit_l( 0 ); FOR( j = 0; j < N; j++ ) { - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ - L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ - L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat +#else + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ +#endif + L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ + L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ } set32_fx( dist[1], L_tmp, maxC ); @@ -7406,9 +7566,11 @@ void fb_tbe_enc_fx( Word16 tmp, tmp1, tmp2, exp, exp2, exp_norm; Word16 s_max_value, exp_temp, i; TD_BWE_ENC_HANDLE hBWE_TD = st->hBWE_TD; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif s_max_value = 0; FOR( i = 0; i < L_FRAME48k; i++ ) @@ -7443,9 +7605,13 @@ void fb_tbe_enc_fx( Copy( hBWE_TD->old_input_fhb_fx, input_fhb, Sample_Delay_HP ); Copy( tmp_vec, input_fhb + Sample_Delay_HP, L_FRAME48k - Sample_Delay_HP ); Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); - temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ + temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat +#else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ - hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ +#endif + hBWE_TD->prev_fb_energy_fx = sum2_fx_mod( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); /*Q11*/ hBWE_TD->prev_fb_energy_fx_Q = sub( add( exp_temp, exp_temp ), 6 ); fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* Q(2*Q_fb_exc+1 -7) */ -- GitLab From 59189eaf388b2e13ee680f537c87c52ee1464f4c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 11:34:07 +0200 Subject: [PATCH 53/80] use swb_bwe_enc[fx, hr]_fx from main --- lib_enc/swb_bwe_enc_fx.c | 156 +++--------------------------------- lib_enc/swb_bwe_enc_hr_fx.c | 8 +- 2 files changed, 15 insertions(+), 149 deletions(-) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 280624b4f..40fefd684 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -303,11 +303,9 @@ void swb_bwe_enc_ivas_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif Word16 fb_band_begin; Word16 q_new_input_hp; @@ -410,11 +408,7 @@ void swb_bwe_enc_ivas_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat -#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); -#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -548,12 +542,8 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ -#ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat -#else + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#endif } ELSE { @@ -633,11 +623,9 @@ void swb_bwe_enc_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -695,11 +683,7 @@ void swb_bwe_enc_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat -#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); -#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -821,12 +805,8 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ -#ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat -#else + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ -#endif } ELSE { @@ -1027,11 +1007,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class Word16 sharplimit; Word16 numsharp, num, den; Word16 numharmonic, tmp, expn, expd, scale; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1068,28 +1046,16 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class { IF( hBWE_FD->prev_global_gain_fx == 0 ) { -#ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat -#else - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ -#endif + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ } ELSE { expn = norm_l( fGain ); -#ifdef ISSUE_1867_replace_overflow_libenc - num = extract_h( L_shl( fGain, expn ) ); -#else num = extract_h( L_shl_o( fGain, expn, &Overflow ) ); -#endif expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) ); expd = norm_l( hBWE_FD->prev_global_gain_fx ); -#ifdef ISSUE_1867_replace_overflow_libenc - den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) ); -#else den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) ); -#endif expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); @@ -1105,7 +1071,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class #ifdef ISSUE_1796_replace_shl_o gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ #else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ #endif } test(); @@ -1195,13 +1161,9 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ -#ifdef ISSUE_1867_replace_overflow_libenc - sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat -#else + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ -#endif } ELSE { @@ -1401,11 +1363,9 @@ static void vqWithCand_w_fx( const Word16 *p_E_ROM_dico; Word16 dist, temp1; Word32 L_dist, L_tmp; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif IF( flag ) { @@ -1422,22 +1382,14 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat -#else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ -#endif - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat -#else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); -#endif L_tmp = L_mult( temp1, w[j] ); /*Q22 */ L_tmp = Mult_32_16( L_tmp, temp1 ); /*Q15 */ L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */ @@ -1712,11 +1664,9 @@ static void msvq_interpol_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2], tmp; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* Extract target vector */ @@ -1757,21 +1707,13 @@ static void msvq_interpol_fx( /* Extract vector for odd position */ FOR( n_band = 0; n_band < DIM11; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat -#else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); -#endif move16(); } FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat -#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ -#endif tmp = shr( tmp, 1 ); quant_tmp2[n_band] = sub( env_temp12[n_band], tmp ); move16(); /*Q8 */ @@ -1794,11 +1736,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat -#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); -#endif tmp = shr( tmp, 1 ); quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] ); move16(); /*Q8 */ @@ -1858,11 +1796,9 @@ static void msvq_interpol_2_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2]; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* Extract target vector */ FOR( n_band = 0; n_band < DIM11 - 1; n_band++ ) @@ -1920,17 +1856,9 @@ static void msvq_interpol_2_fx( move16(); FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat -#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); -#endif tmp_q = shr( tmp_q, 1 ); -#ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat -#else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); -#endif move16(); } @@ -1951,17 +1879,9 @@ static void msvq_interpol_2_fx( move16(); /*Q8 */ FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat -#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); -#endif tmp_q = shr( tmp_q, 1 ); -#ifdef ISSUE_1867_replace_overflow_libenc - quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat -#else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); -#endif } L_dist = L_deposit_l( 0 ); @@ -2023,11 +1943,9 @@ static void calculate_Tonality_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2133,11 +2051,7 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2158,11 +2072,7 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2191,11 +2101,9 @@ static void calculate_Tonality_ivas_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2301,11 +2209,7 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2326,11 +2230,7 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat -#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ -#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2718,11 +2618,9 @@ static Word16 SWB_BWE_encoding_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -2765,11 +2663,7 @@ static Word16 SWB_BWE_encoding_fx( } /* tilt returned in Q24 go to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat -#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); -#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -2873,11 +2767,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat -#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ -#endif } ELSE { @@ -2889,11 +2779,7 @@ static Word16 SWB_BWE_encoding_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat -#else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ -#endif + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -3177,11 +3063,9 @@ static Word16 SWB_BWE_encoding_ivas_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -#endif #endif Word16 inner_frame; Word16 q_shift; @@ -3242,11 +3126,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( } /* tilt returned in Q24 go to Q11 */ -#ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat -#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); -#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -3351,11 +3231,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); expd = norm_l( WB_tenv_syn_fx ); -#ifdef ISSUE_1867_replace_overflow_libenc - den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat -#else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); -#endif expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); @@ -3368,11 +3244,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat -#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ -#endif } ELSE { @@ -3382,12 +3254,8 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ -#ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat -#else - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ -#endif + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index d7cebe322..f510a1cb6 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -117,11 +117,9 @@ void swb_bwe_enc_hr_fx( #else Word32 L_t_audio_tmp_fx[L_FRAME48k]; #endif -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -769,12 +767,12 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); +#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, temp2 ); -#ifdef ISSUE_1867_replace_overflow_libenc - t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat #else - t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); + L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); #endif + t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); move16(); } -- GitLab From c74ee2931d451b0be6545cc522b3bd5d1ef57c8a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 12:16:25 +0200 Subject: [PATCH 54/80] use swb_bwe_enc_lr_fx from main --- lib_enc/swb_bwe_enc_lr_fx.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 2dedbfbeb..3c92c7f89 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -698,11 +698,9 @@ static void gethar_noisegn_fx( Word16 temp_lo, temp_hi; Word16 Qg; -#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif /*Generate HF noise*/ genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow, @@ -784,14 +782,9 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ -#ifdef ISSUE_1867_replace_overflow_libenc - L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat - g_fx = round_fx_sat( L_temp ); //??sat -#else + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); -#endif } gqlevs_fx = 4; -- GitLab From 40a861608ed1517af9c9ab4700bd6ba5dee97f06 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 12:36:35 +0200 Subject: [PATCH 55/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from beginning --- lib_enc/swb_tbe_enc_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 09560f568..6d1d46b12 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -13,7 +13,9 @@ #include "stl.h" #include "ivas_prot_fx.h" - +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ -- GitLab From 439fc9e66f5d07de70dfd3e587c80a10bebe5573 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 14:53:01 +0200 Subject: [PATCH 56/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from EstimateSHBFrameGain_fx --- lib_enc/swb_tbe_enc_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6d1d46b12..ed00628c2 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -13,9 +13,6 @@ #include "stl.h" #include "ivas_prot_fx.h" -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ @@ -4605,6 +4602,9 @@ void swb_tbe_enc_ivas_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------*/ +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif static void EstimateSHBFrameGain_fx( const Word16 length, /* i : SHB overlap length */ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ -- GitLab From 480de262fa995a48ea1ab803d006f4909cf59b27 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 15:03:34 +0200 Subject: [PATCH 57/80] clang patch --- lib_enc/enc_acelp_fx.c | 16 ++++++++-------- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/gain_enc_fx.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 2dcf98a36..3bfc0eea0 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1238,7 +1238,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/ //??sat #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*/ @@ -1394,7 +1394,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/ //??sat #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*/ @@ -1455,7 +1455,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #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(); } @@ -1509,7 +1509,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #ifdef ISSUE_1867_replace_overflow_libenc y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat #else - y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ + y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif move16(); } @@ -1583,7 +1583,7 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/ //??sat #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*/ @@ -1737,7 +1737,7 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/ //??sat #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*/ @@ -1798,7 +1798,7 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, #ifdef ISSUE_1867_replace_overflow_libenc vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */ //??sat #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(); } @@ -1852,7 +1852,7 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, #ifdef ISSUE_1867_replace_overflow_libenc y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat #else - y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ + y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif move16(); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 22c7f1af3..7b50ef8e2 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -794,7 +794,7 @@ void encod_gen_voic_ivas_fx( Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat gcode16 = round_fx_sat( Lgcode ); //??sat #else - Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ + Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index f84bcc52f..ed91abb45 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -911,7 +911,7 @@ void enc_pit_exc_ivas_fx( Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 //??sat hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat #else - Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift + Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 4dd367ef9..4fa2b20b3 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -466,7 +466,7 @@ void gain_enc_mless_fx( #ifdef ISSUE_1867_replace_overflow_libenc *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat #else - *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ + *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ #endif } ELSE -- GitLab From 4c114d73dc2589ab3d1c425cabf0ac7c50f0d8b7 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 21 Aug 2025 16:36:15 +0200 Subject: [PATCH 58/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from pow_off_pk_fx --- lib_enc/swb_tbe_enc_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index ed00628c2..678892c1c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4602,9 +4602,6 @@ void swb_tbe_enc_ivas_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------*/ -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif static void EstimateSHBFrameGain_fx( const Word16 length, /* i : SHB overlap length */ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ @@ -5057,7 +5054,9 @@ static void EstimateSHBFrameGain_ivas_fx( return; } - +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) { Word16 i, j; -- GitLab From 181e498a22ff93ce671ca55fab590c662067ac8b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 26 Aug 2025 07:12:53 +0200 Subject: [PATCH 59/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from EstimateSHBFrameGain_ivas_fx() --- lib_enc/swb_tbe_enc_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 678892c1c..e7aa0abb5 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4828,6 +4828,10 @@ static void EstimateSHBFrameGain_fx( return; } +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif + static void EstimateSHBFrameGain_ivas_fx( const Word16 length, /* i : SHB overlap length */ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ @@ -5054,9 +5058,6 @@ static void EstimateSHBFrameGain_ivas_fx( return; } -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) { Word16 i, j; -- GitLab From 40eac3fde262c7112e42307a71a4eff564359d46 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 26 Aug 2025 08:43:53 +0200 Subject: [PATCH 60/80] clang patch --- lib_enc/gain_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 53031dd76..ef6a4bd34 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -373,14 +373,14 @@ void gain_enc_mless_fx( #ifdef FIX_1959_assert_in_gain_enc_mless_fx L_tmp1 = L_mult_sat( coeff[0], coeff[2] ); /*Q31*/ #else - L_tmp1 = L_mult( coeff[0], coeff[2] ); /*Q31*/ + L_tmp1 = L_mult( coeff[0], coeff[2] ); /*Q31*/ #endif exp1 = add( exp_coeff[0], exp_coeff[2] ); #ifdef FIX_1959_assert_in_gain_enc_mless_fx L_tmp2 = L_shr( L_mult_sat( coeff[4], coeff[4] ), 2 ); /*Q31*/ #else - L_tmp2 = L_shr( L_mult( coeff[4], coeff[4] ), 2 ); /*Q31*/ + L_tmp2 = L_shr( L_mult( coeff[4], coeff[4] ), 2 ); /*Q31*/ #endif exp2 = add( exp_coeff[4], exp_coeff[4] ); -- GitLab From cdd4cc7ee17a70c8bf228e87cd8ac99f67b7c8f8 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 26 Aug 2025 10:01:00 +0200 Subject: [PATCH 61/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from second half of EstimateSHBFrameGain_ivas_fx() --- lib_enc/swb_tbe_enc_fx.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e7aa0abb5..21c9b843e 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4828,9 +4828,6 @@ static void EstimateSHBFrameGain_fx( return; } -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif static void EstimateSHBFrameGain_ivas_fx( const Word16 length, /* i : SHB overlap length */ @@ -4856,12 +4853,7 @@ static void EstimateSHBFrameGain_ivas_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; -#ifndef ISSUE_1867_replace_overflow_libenc -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif -#endif + move16(); /* initilaization */ @@ -4971,7 +4963,7 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc +#ifdef ISSUE_1867_replace_overflow_libenc_ sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat @@ -4986,7 +4978,7 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc +#ifdef ISSUE_1867_replace_overflow_libenc_ oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat @@ -5000,7 +4992,7 @@ static void EstimateSHBFrameGain_ivas_fx( tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc +#ifdef ISSUE_1867_replace_overflow_libenc_ sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat @@ -5058,6 +5050,10 @@ static void EstimateSHBFrameGain_ivas_fx( return; } +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif + static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) { Word16 i, j; -- GitLab From bf97fdb376537ef124393e5dcf9d87b896f6831a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 26 Aug 2025 08:30:29 +0000 Subject: [PATCH 62/80] fix builderror --- lib_enc/swb_tbe_enc_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 21c9b843e..562659f2c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4853,7 +4853,12 @@ static void EstimateSHBFrameGain_ivas_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; - +#ifndef ISSUE_1867_replace_overflow_libenc_ +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif +#endif move16(); /* initilaization */ -- GitLab From d5f13f9b5c5f8d22846e66f54a44eacecc72e4d3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 26 Aug 2025 13:45:20 +0200 Subject: [PATCH 63/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from second half of EstimateSHBFrameGain_ivas_fx() and reactivate line 5000 --- lib_enc/swb_tbe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 562659f2c..435d6dd6f 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4997,7 +4997,7 @@ static void EstimateSHBFrameGain_ivas_fx( tmp = add( l_frame, l_shb_lahead ); FOR( ; i < tmp; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc_ +#ifdef ISSUE_1867_replace_overflow_libenc sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat -- GitLab From 586436b31aa90d0af50a1b013cb92a8c152a3dab Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 26 Aug 2025 14:27:56 +0200 Subject: [PATCH 64/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from second half of EstimateSHBFrameGain_ivas_fx() and reactivate line 5000 and 4986 --- lib_enc/swb_tbe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 435d6dd6f..e6c9485de 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4983,7 +4983,7 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc_ +#ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat -- GitLab From c3a352186f77835d3452d5d873c18ce6885454bb Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 27 Aug 2025 08:06:36 +0200 Subject: [PATCH 65/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from second half of EstimateSHBFrameGain_ivas_fx() and reactivate line 5000 and 4986 and 4971 --- lib_enc/swb_tbe_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e6c9485de..ac72cd5b6 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4853,7 +4853,7 @@ static void EstimateSHBFrameGain_ivas_fx( Word16 exp_out; Word16 tmp; Word16 scaling = 0; -#ifndef ISSUE_1867_replace_overflow_libenc_ +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -4968,7 +4968,7 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { -#ifdef ISSUE_1867_replace_overflow_libenc_ +#ifdef ISSUE_1867_replace_overflow_libenc sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat -- GitLab From 70de930d93da1fd4bf8a62db0b82c7332e3b1d18 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 27 Aug 2025 09:41:53 +0200 Subject: [PATCH 66/80] clang patch --- lib_enc/core_enc_ol_fx.c | 2 +- lib_enc/enc_acelp_fx.c | 8 +++---- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/hvq_enc_fx.c | 6 ++--- lib_enc/lsf_enc_fx.c | 16 ++++++------- lib_enc/lsf_msvq_ma_enc_fx.c | 6 ++--- lib_enc/swb_tbe_enc_fx.c | 46 ++++++++++++++++++------------------ lib_enc/voiced_enc_fx.c | 16 ++++++------- 9 files changed, 52 insertions(+), 52 deletions(-) diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 0f60b5e06..cdf7f0362 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -558,7 +558,7 @@ void core_encode_openloop_fx( #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 ); //??sat #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(); /*input value is in Qx2.56, convert to Q6 to match table, quantizer table kept at Q6 to avoid losing precision */ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 0ede60ba4..d05508bb5 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1230,7 +1230,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/ //??sat #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*/ @@ -1384,7 +1384,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/ //??sat #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*/ @@ -1445,7 +1445,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #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(); } @@ -1499,7 +1499,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const #ifdef ISSUE_1867_replace_overflow_libenc y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat #else - y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ + y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif move16(); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 9485f24b5..c54975764 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -749,7 +749,7 @@ void encod_gen_voic_ivas_fx( Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat gcode16 = round_fx_sat( Lgcode ); //??sat #else - Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ + Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 061c6b42b..7d9b99a11 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -879,7 +879,7 @@ void enc_pit_exc_ivas_fx( Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 //??sat hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat #else - Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift + Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow ); // Q_new-1+15+shift Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index edab539ec..209277092 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -123,7 +123,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits #ifdef ISSUE_1867_replace_overflow_libenc pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat #else - pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ + pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif } @@ -155,7 +155,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits #ifdef ISSUE_1867_replace_overflow_libenc noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); @@ -310,7 +310,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits #ifdef ISSUE_1867_replace_overflow_libenc pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat #else - pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ + pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif } diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 93febb6b6..cf4c31982 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -789,7 +789,7 @@ static Word16 qlsf_Mode_Select_fx( #ifdef ISSUE_1867_replace_overflow_libenc En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ //??sat //??sat #else - En = L_mac_o(En, mult(pred_pow2[i], shl_sat(w[i], 2)), pred_pow2[i], &Overflow); /* 2.56*2.56 at Q-4 */ + En = L_mac_o( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i], &Overflow ); /* 2.56*2.56 at Q-4 */ #endif } @@ -2003,7 +2003,7 @@ static void first_VQstages( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ @@ -2199,7 +2199,7 @@ static void first_VQstages_ivas_fx( #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat #else - L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif L_tmp1 = Mult_32_16( L_tmp1, u[j] ); /*x2.56 + Q15 + x2.56 -Q15 */ L_tmp = L_add( L_tmp, L_tmp1 ); /*Q0 + x2.56 +x2.56 */ @@ -3413,7 +3413,7 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( #ifdef ISSUE_1867_replace_overflow_libenc temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); //??sat //??sat #else - temp_l = L_mac_o(temp_l, mult(yy_fx[i], shl_sat(w_fx[i], 2)), yy_fx[i], &Overflow); + temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i], &Overflow ); #endif } cs = shl( cs, 1 ); @@ -3626,7 +3626,7 @@ static void lsf_mid_enc_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ - tmp = shl_sat(tmp, 4); + tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc tmp = mult_r_sat( tmp, tmp ); //??sat err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat @@ -3819,13 +3819,13 @@ static void lsf_mid_enc_ivas_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ - tmp = shl_sat(tmp, 4); + tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc tmp = mult_r_sat( tmp, tmp ); //??sat err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat #else - tmp = mult_ro(tmp, tmp, &Overflow); - err = L_mac_o(err, tmp, shl_sat(wghts[j], 2), &Overflow); + tmp = mult_ro( tmp, tmp, &Overflow ); + err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); #endif } /* err = L_shl(err,Wscale); */ diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 0b953d14a..9c00bd44b 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1632,11 +1632,11 @@ void midlsf_enc_fx( tmp = sub( lsf[j], qlsf[j] ); /* err += wghts[j] * ftemp * ftemp; */ /* tmp is usually very small, we can have some extra precision with very rare saturation */ - tmp = shl_sat(tmp, 4); + tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat(tmp, tmp); //??sat + tmp = mult_r_sat( tmp, tmp ); //??sat #else - tmp = mult_ro(tmp, tmp, &Overflow); + tmp = mult_ro( tmp, tmp, &Overflow ); #endif err = L_mac( err, tmp, wghts[j] ); } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index aee22e18f..1355eba6c 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -4790,8 +4790,8 @@ static void EstimateSHBFrameGain_fx( sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else - sig = mult_r(shl_sat(oriSHB[i], scaling), win_shb[i]); - oriNrg = L_mac0_o(oriNrg, sig, sig, &Overflow); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } FOR( ; i < l_frame; i++ ) @@ -4800,8 +4800,8 @@ static void EstimateSHBFrameGain_fx( sig = shl_sat( oriSHB[i], scaling ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else - sig = shl_sat(oriSHB[i], scaling); - oriNrg = L_mac0_o(oriNrg, sig, sig, &Overflow); /* 2*Q_oriSHB + 2*scaling */ + sig = shl_sat( oriSHB[i], scaling ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } FOR( ; i < tmp; i++ ) @@ -4810,8 +4810,8 @@ static void EstimateSHBFrameGain_fx( sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else - sig = mult_r(shl_sat(oriSHB[i], scaling), win_shb[l_frame + l_shb_lahead - 1 - i]); - oriNrg = L_mac0_o(oriNrg, sig, sig, &Overflow); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } } @@ -5027,8 +5027,8 @@ static void EstimateSHBFrameGain_ivas_fx( sig = shl_sat( oriSHB[i], scaling ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else - sig = shl_sat(oriSHB[i], scaling); - oriNrg = L_mac0_o(oriNrg, sig, sig, &Overflow); /* 2*Q_oriSHB + 2*scaling */ + sig = shl_sat( oriSHB[i], scaling ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } FOR( ; i < tmp; i++ ) @@ -5037,8 +5037,8 @@ static void EstimateSHBFrameGain_ivas_fx( sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat #else - sig = mult_r(shl_sat(oriSHB[i], scaling), win_shb[l_frame + l_shb_lahead - 1 - i]); - oriNrg = L_mac0_o(oriNrg, sig, sig, &Overflow); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ #endif } } @@ -5284,9 +5284,9 @@ static void EstimateSHBGainShape_fx( synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5298,9 +5298,9 @@ static void EstimateSHBGainShape_fx( sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } @@ -5312,9 +5312,9 @@ static void EstimateSHBGainShape_fx( sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else - oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ + synNrg = L_mac0_o( synNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ #endif } /* Only implemented in SWB because the length of samples in SWB frame is longer, more likely to saturate */ @@ -5366,8 +5366,8 @@ static void EstimateSHBGainShape_fx( subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ + subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ #endif move16(); } @@ -5386,7 +5386,7 @@ static void EstimateSHBGainShape_fx( #ifdef ISSUE_1867_replace_overflow_libenc subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat #else - subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ + subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ #endif move16(); } @@ -5399,7 +5399,7 @@ static void EstimateSHBGainShape_fx( #ifdef ISSUE_1867_replace_overflow_libenc subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat #else - subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ #endif move16(); } diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index f4115093a..93a8a10b8 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -602,7 +602,7 @@ ivas_error ppp_voiced_encoder_fx( IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ + IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -622,7 +622,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat #else - if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ + if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif { hSC_VBR->bump_up = 1; @@ -804,7 +804,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat #else - Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #endif /* Ltmp1_32 = 0.8f * st->prev_cw_en */ Ltmp1_32 = Mult_32_16( hSC_VBR->prev_cw_en_fx, 26214 ); /* Q = (Q_prev_cw_en_fx + Q15+1)-Q16 = Q_prev_cw_en_fx */ @@ -931,7 +931,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ //??sat #else - Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ #endif /* if ((DTFS_getEngy(*CURRP_Q_E) > st->prev_cw_en)&&(max(pos_q,neg_q)>3.5) && energy_impz>15.0 && tmpres>0.7) */ test(); @@ -999,7 +999,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ #endif } test(); @@ -1039,7 +1039,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat #else - Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ + Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ #endif } /*-------------------------------------------*/ @@ -1111,7 +1111,7 @@ ivas_error ppp_voiced_encoder_fx( #ifdef ISSUE_1867_replace_overflow_libenc Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat #else - Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ + Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ #endif } ELSE @@ -1312,7 +1312,7 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ #ifdef ISSUE_1867_replace_overflow_libenc acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat #else - acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ + acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ #endif buf[j] = buf[j - 1]; move16(); -- GitLab From 1603d8df016c895d8327db05192b06107778bee7 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 27 Aug 2025 11:33:34 +0200 Subject: [PATCH 67/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from 5080 --- lib_enc/swb_tbe_enc_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 1355eba6c..9c0de76a2 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -5051,9 +5051,6 @@ static void EstimateSHBFrameGain_ivas_fx( return; } -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) { @@ -5080,6 +5077,9 @@ static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) return ( sum ); } +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ) { -- GitLab From 3001dc29405f57d096f54417773f6cdea7783289 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 27 Aug 2025 12:34:09 +0200 Subject: [PATCH 68/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from 5400 --- lib_enc/swb_tbe_enc_fx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 9c0de76a2..611ac0984 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -5077,10 +5077,6 @@ static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) return ( sum ); } -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif - static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ) { Word16 i, j; @@ -5408,7 +5404,9 @@ static void EstimateSHBGainShape_fx( return; } - +#ifdef ISSUE_1867_replace_overflow_libenc +#undef ISSUE_1867_replace_overflow_libenc +#endif /*==========================================================================*/ /* FUNCTION :static short closest_centroid_fx () */ /*--------------------------------------------------------------------------*/ -- GitLab From 1a0596577820d1bfc3da3c22d54e441479b5668a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 27 Aug 2025 13:37:55 +0200 Subject: [PATCH 69/80] use swb_bwe_enc_fx from 9b193cb, deactivate file from 5400, fix error --- lib_enc/swb_tbe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 611ac0984..394c9e87d 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -5277,8 +5277,8 @@ static void EstimateSHBGainShape_fx( sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ -- GitLab From e2f8ba4c8f19af259b5862b8d36295fb9c5c14aa Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 27 Aug 2025 14:55:19 +0200 Subject: [PATCH 70/80] take all files from 9b193cb --- lib_enc/scale_enc_fx.c | 30 ++++++ lib_enc/set_impulse_fx.c | 50 +++++++-- lib_enc/speech_music_classif_fx.c | 74 ++++++++++++- lib_enc/stat_noise_uv_enc_fx.c | 32 ++++-- lib_enc/swb_bwe_enc_fx.c | 166 ++++++++++++++++++++++++++++-- lib_enc/swb_bwe_enc_hr_fx.c | 8 +- lib_enc/swb_bwe_enc_lr_fx.c | 9 +- lib_enc/swb_tbe_enc_fx.c | 3 - 8 files changed, 333 insertions(+), 39 deletions(-) diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 2f3cd1833..f0508b67c 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,9 +86,11 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; +#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /*---------------------------------------------------------------* @@ -97,8 +99,17 @@ void Preemph_scaled( *---------------------------------------------------------------*/ BASOP_SATURATE_WARNING_OFF_EVS + +#ifdef ISSUE_1867_replace_overflow_libenc + QVal = shl_sat( 1, sub( 15, bits ) ); //?sat +#else Overflow = 0; +#ifdef ISSUE_1796_replace_shl_o QVal = shl_sat( 1, sub( 15, bits ) ); +#else + QVal = shl_o( 1, sub( 15, bits ), &Overflow ); +#endif +#endif BASOP_SATURATE_WARNING_ON_EVS mu = shr( Preemph_factor, bits ); /* Q15 --> Q(15-bits) */ @@ -115,7 +126,11 @@ void Preemph_scaled( /* Equivalent to tmp = max((abs(x[i] - mu*x[i-1]),tmp) * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat +#else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); +#endif L_tmp = L_abs( L_tmp ); L_maxloc = L_max( L_tmp, L_maxloc ); } @@ -165,7 +180,11 @@ void Preemph_scaled( FOR( i = sub( Lframe, 1 ); i > 0; i-- ) { L_tmp = L_mult( new_speech[i], QVal ); +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat +#else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); +#endif L_tmp = L_shl( L_tmp, *Q_new ); new_speech[i] = round_fx_sat( L_tmp ); // Q_new } @@ -198,8 +217,10 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled { Word16 i; Word32 e_min_scaled; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif e_min_scaled = L_shr_r( L_add( L_shr( E_MIN_FXQ15, sub( 14, add( *Q_new, QSCALE ) ) ), 1 ), 1 ); @@ -229,12 +250,21 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled /* Do scaling and valide minimum energy value */ FOR( i = 0; i < NB_BANDS; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); //??sat + bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); //??sat + ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); //??sat + ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); //??sat + st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); //??sat + st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); //??sat +#else enrO[i] = L_max( L_shl_o( enrO[i], Q_exp, &Overflow ), e_min_scaled ); bckr[i] = L_max( L_shl_o( bckr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr[i] = L_max( L_shl_o( ave_enr[i], Q_exp, &Overflow ), e_min_scaled ); ave_enr2[i] = L_max( L_shl_o( ave_enr2[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands1[i] = L_max( L_shl_o( st_fr_bands1[i], Q_exp, &Overflow ), e_min_scaled ); st_fr_bands2[i] = L_max( L_shl_o( st_fr_bands2[i], Q_exp, &Overflow ), e_min_scaled ); +#endif move32(); move32(); move32(); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 46693bfe0..76a4b1afb 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -65,9 +65,11 @@ void set_impulse_fx( Word16 krit_fx, krit_max_fx, gain16; Word32 Lrr, Ldd, Ltmp, Ltmp1; const Word16 *pt_Glt; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif krit_max_fx = -32768; move16(); @@ -119,12 +121,21 @@ void set_impulse_fx( /* nominator & DEnominator row <0> */ FOR( i = 0; i < L_SUBFR; i++ ) { - Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 +#ifdef ISSUE_1867_replace_overflow_libenc + Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat + Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat +#else + Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 +#endif } rr_fx[start1] = Lrr; move32(); - dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 +#ifdef ISSUE_1867_replace_overflow_libenc + dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat +#else + dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 +#endif rr_fx[start1] = L_max( rr_fx[start1], 1 ); FOR( i = add( start1, 1 ); i < L_IMPULSE2; i++ ) @@ -138,15 +149,25 @@ void set_impulse_fx( gh_fx[j] = mac_r( L_deposit_h( gh_fx[j - 1] ), Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); - Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 +#ifdef ISSUE_1867_replace_overflow_libenc + Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat + Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat +#else + Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 +#endif } gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); - Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 - Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 - dd_fx[i] = round_fx_sat( Ldd ); // Q11 +#ifdef ISSUE_1867_replace_overflow_libenc + Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat + Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat +#else + Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 + Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 +#endif + dd_fx[i] = round_fx_sat( Ldd ); // Q11 rr_fx[i] = L_max( Lrr, 1 ); move32(); /* move rr and dd into rr[i] and dd[i] */ @@ -179,8 +200,11 @@ void set_impulse_fx( FOR( i = L_SUBFR - 2; i >= start2; i-- ) { /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ - rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], - gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 +#ifdef ISSUE_1867_replace_overflow_libenc + rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 //??sat +#else + rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 +#endif move32(); } /* nominator rows */ @@ -202,7 +226,11 @@ void set_impulse_fx( num = div_s( num, den ); - krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ +#ifdef ISSUE_1867_replace_overflow_libenc + krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat +#else + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ +#endif IF( GT_16( krit_fx, krit_max_fx ) ) { diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index e2c8f59ff..4f809d827 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -662,9 +662,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis Word16 tmp1, tmp2, exp2, scale, exp3; SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas; HQ_ENC_HANDLE hHQ_core = st_fx->hHQ_core; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*------------------------------------------------------------------* @@ -794,10 +796,18 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis sum_PS = L_deposit_l( 0 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + sum_PS = L_add_sat( sum_PS, PS[i] ); //??sat +#else sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); +#endif } exp1 = norm_l( sum_PS ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); //??sat +#else tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); +#endif exp1 = sub( 30, exp1 ); FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) @@ -805,7 +815,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*PS_norm[i] = PS[i] / sum_PS;*/ /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); //??sat +#else tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); +#endif exp2 = sub( 30, exp2 ); scale = shr( sub( tmp1, tmp2 ), 15 ); @@ -866,7 +880,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis ELSE { exp1 = norm_l( L_add( dPS[i], 336 ) ); +#ifdef ISSUE_1867_replace_overflow_libenc + tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); //??sat //??sat +#else tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); +#endif exp1 = sub( 30, exp1 ); exp2 = norm_l( mx ); @@ -923,7 +941,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = 0; i < N_FEATURES; i++ ) { /**pFV = pSF[0] * *pFV + pSF[1];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); //??sat //??sat +#else *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); +#endif move16(); pFV++; } @@ -954,7 +976,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); //??sat +#else xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); +#endif move16(); /*Q15 */ } @@ -970,7 +996,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); //??sat +#else xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); +#endif move16(); /*Q15 */ } @@ -985,7 +1015,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( p = 0; p < N_FEATURES; p++ ) { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ +#ifdef ISSUE_1867_replace_overflow_libenc + xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); //??sat +#else xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); +#endif move16(); /*Q15 */ } @@ -999,7 +1033,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ - lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ +#ifdef ISSUE_1867_replace_overflow_libenc + lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat +#else + lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ +#endif lps = s_max( lps, -10832 ); lpm = extract_h( L_shl( L_sub( max_m, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ @@ -1007,7 +1045,11 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ - lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ +#ifdef ISSUE_1867_replace_overflow_libenc + lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat +#else + lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ +#endif lpn = s_max( lpn, -10832 ); *high_lpn_flag_ptr = 0; @@ -1459,9 +1501,11 @@ static Word16 attack_det_fx( /* o : attack flag Word16 i, j, tmp, tmp1, attack, exp1; Word32 L_tmp, etmp, etmp2, finc[ATT_NSEG]; Word16 att_3lsub_pos; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -1479,7 +1523,11 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat +#else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ +#endif } finc[i] = L_tmp; @@ -1504,7 +1552,11 @@ static Word16 attack_det_fx( /* o : attack flag FOR( i = 1; i < att_3lsub_pos; i++ ) { - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat +#else + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ +#endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -1516,7 +1568,11 @@ static Word16 attack_det_fx( /* o : attack flag L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ FOR( i = 1; i < tmp1; i++ ) { - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat +#else + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ +#endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -2615,9 +2671,11 @@ static Word16 attack_det_ivas_fx( /* o : attack flag Word64 W_tmp; Word16 q_diff; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif att_3lsub_pos = ATT_3LSUB_POS; @@ -2635,7 +2693,11 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat +#else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ +#endif } finc[i] = L_tmp; @@ -3762,7 +3824,11 @@ static void spec_analysis_fx( test(); IF( GT_16( peak_idx[k], valey_idx[i] ) && LT_16( peak_idx[k], valey_idx[i + 1] ) ) { +#ifdef ISSUE_1796_replace_shl_o p2v[k] = sub_o( shl_sat( peak[k], 1 ), add_o( valley[i], valley[i + 1], &Overflow ), &Overflow ); +#else + p2v[k] = sub_o( shl_o( peak[k], 1, &Overflow ), add_o( valley[i], valley[i + 1], &Overflow ), &Overflow ); +#endif move16(); k = add( k, 1 ); } diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 598745ebd..38a36083e 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -50,9 +50,11 @@ void stat_noise_uv_enc_fx( Word16 noisiness = 0; move16(); Word16 num, den, expn, expd; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif test(); test(); @@ -65,12 +67,20 @@ void stat_noise_uv_enc_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ +#else num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ +#endif expd = norm_l( LepsP[1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ +#else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ +#endif + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -123,9 +133,11 @@ void stat_noise_uv_enc_ivas_fx( Word16 noisiness = 0; move16(); Word16 num, den, expn, expd; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif test(); test(); @@ -138,12 +150,20 @@ void stat_noise_uv_enc_ivas_fx( *-----------------------------------------------------------------*/ /* epsP[2] is located in LepsP[0] and epsP[16] in LepsP[1] */ expn = sub( norm_l( LepsP[0] ), 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( LepsP[0], expn ) ); /*expn-16*/ +#else num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ +#endif expd = norm_l( LepsP[1] ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( LepsP[1], expd ) ); /*expd-16*/ +#else den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ - num = div_s( num, den ); /*expn-expd+15*/ - num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ +#endif + num = div_s( num, den ); /*expn-expd+15*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 2b2c809a9..280624b4f 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -303,9 +303,11 @@ void swb_bwe_enc_ivas_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 fb_band_begin; Word16 q_new_input_hp; @@ -408,7 +410,11 @@ void swb_bwe_enc_ivas_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat +#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); +#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -542,8 +548,12 @@ void swb_bwe_enc_ivas_fx( exp1 = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, exp1 ); exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat +#else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE { @@ -623,9 +633,11 @@ void swb_bwe_enc_fx( Word16 fb_ener_adjust_fx; Word16 ener_adjust_quan_fx = 0; move16(); +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -683,7 +695,11 @@ void swb_bwe_enc_fx( *----------------------------------------------------------------------*/ /* tilt returned in Q24 goto to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat +#else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); +#endif /*---------------------------------------------------------------------* * SWB BWE encoding * FB BWE encoding @@ -805,8 +821,12 @@ void swb_bwe_enc_fx( L_tmp = L_shl( L_tmp, exp1 ); // exp = 31 - exp1 - ( 30 - exp ); exp = add( 31 - 30, sub( exp, exp1 ) ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ +#ifdef ISSUE_1867_replace_overflow_libenc + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat +#else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE { @@ -1007,9 +1027,11 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class Word16 sharplimit; Word16 numsharp, num, den; Word16 numharmonic, tmp, expn, expd, scale; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -1046,25 +1068,45 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class { IF( hBWE_FD->prev_global_gain_fx == 0 ) { - gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ +#ifdef ISSUE_1867_replace_overflow_libenc + gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat +#else + gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { expn = norm_l( fGain ); +#ifdef ISSUE_1867_replace_overflow_libenc + num = extract_h( L_shl( fGain, expn ) ); +#else num = extract_h( L_shl_o( fGain, expn, &Overflow ) ); +#endif expn = sub( sub( 30, expn ), shl( Q_shb, 1 ) ); expd = norm_l( hBWE_FD->prev_global_gain_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = extract_h( L_shl( hBWE_FD->prev_global_gain_fx, expd ) ); +#else den = extract_h( L_shl_o( hBWE_FD->prev_global_gain_fx, expd, &Overflow ) ); +#endif expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); +#ifdef ISSUE_1796_replace_shl_o num = shl_sat( num, scale ); +#else + num = shl_o( num, scale, &Overflow ); +#endif expn = sub( expn, scale ); tmp = div_s( num, den ); expn = sub( expn, expd ); +#ifdef ISSUE_1796_replace_shl_o gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ +#else + gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ +#endif } test(); IF( EQ_16( hBWE_FD->prev_mode, TRANSIENT ) ) @@ -1153,9 +1195,13 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class move16(); } expd = norm_s( den ); - tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ - L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ + tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ + L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ +#ifdef ISSUE_1867_replace_overflow_libenc + sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat +#else sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ +#endif } ELSE { @@ -1164,7 +1210,11 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class } test(); +#ifdef ISSUE_1796_replace_shl_o IF( GT_16( sharp, 4608 ) && GT_16( peak, shl_sat( 1, add( Q_syn, 3 ) ) ) ) +#else + IF( GT_16( sharp, 4608 ) && GT_16( peak, shl_o( 1, add( Q_syn, 3 ), &Overflow ) ) ) +#endif { k = add( k, 1 ); move16(); @@ -1351,9 +1401,11 @@ static void vqWithCand_w_fx( const Word16 *p_E_ROM_dico; Word16 dist, temp1; Word32 L_dist, L_tmp; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif IF( flag ) { @@ -1370,14 +1422,22 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat +#else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ - L_dist = L_mult( dist, w[0] ); /*Q22 */ - L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ - L_dist = L_shr( L_dist, 10 ); /*Q5 */ +#endif + L_dist = L_mult( dist, w[0] ); /*Q22 */ + L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ + L_dist = L_shr( L_dist, 10 ); /*Q5 */ FOR( j = 1; j < dim; j++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat +#else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); +#endif L_tmp = L_mult( temp1, w[j] ); /*Q22 */ L_tmp = Mult_32_16( L_tmp, temp1 ); /*Q15 */ L_dist = L_add( L_dist, L_shr( L_tmp, 10 ) ); /*Q5 */ @@ -1652,9 +1712,11 @@ static void msvq_interpol_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2], tmp; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Extract target vector */ @@ -1695,13 +1757,21 @@ static void msvq_interpol_fx( /* Extract vector for odd position */ FOR( n_band = 0; n_band < DIM11; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat +#else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); +#endif move16(); } FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat +#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ +#endif tmp = shr( tmp, 1 ); quant_tmp2[n_band] = sub( env_temp12[n_band], tmp ); move16(); /*Q8 */ @@ -1724,7 +1794,11 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat +#else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); +#endif tmp = shr( tmp, 1 ); quant_select[( n_band << 1 ) + 1] = add( tmp, quant_tmp2[n_band] ); move16(); /*Q8 */ @@ -1784,9 +1858,11 @@ static void msvq_interpol_2_fx( Word16 quant_select[SWB_FENV], w_env11[SWB_FENV / 2], w_env12[SWB_FENV / 2]; Word32 L_tmp, distCand[N_CAND], L_dist, L_minDist; Word16 synth_energy[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Extract target vector */ FOR( n_band = 0; n_band < DIM11 - 1; n_band++ ) @@ -1844,9 +1920,17 @@ static void msvq_interpol_2_fx( move16(); FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat +#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); +#endif tmp_q = shr( tmp_q, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat +#else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); +#endif move16(); } @@ -1867,9 +1951,17 @@ static void msvq_interpol_2_fx( move16(); /*Q8 */ FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { +#ifdef ISSUE_1867_replace_overflow_libenc + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat +#else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); +#endif tmp_q = shr( tmp_q, 1 ); +#ifdef ISSUE_1867_replace_overflow_libenc + quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat +#else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); +#endif } L_dist = L_deposit_l( 0 ); @@ -1931,9 +2023,11 @@ static void calculate_Tonality_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2039,7 +2133,11 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2060,7 +2158,11 @@ static void calculate_Tonality_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2089,9 +2191,11 @@ static void calculate_Tonality_ivas_fx( Word16 org_spec[80], gen_spec[80]; Word32 L_log_gm_org, L_log_gm_gen; Word16 l_shift; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* to reduce dynamic range of original spectrum */ @@ -2197,7 +2301,11 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_org, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_org = s_max( 0, s_min( *SFM_org, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2218,7 +2326,11 @@ static void calculate_Tonality_ivas_fx( L_tmp2 = Mpy_32_16_1( L_log_gm_gen, inv_len ); /* Q14 */ L_tmp = L_sub( L_tmp1, L_tmp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat +#else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ +#endif move16(); *SFM_gen = s_max( 0, s_min( *SFM_gen, 24547 ) ); move16(); /*0.0001 and 5.993 in Q12 */ @@ -2606,9 +2718,11 @@ static Word16 SWB_BWE_encoding_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; @@ -2651,7 +2765,11 @@ static Word16 SWB_BWE_encoding_fx( } /* tilt returned in Q24 go to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat +#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); +#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -2755,7 +2873,11 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { @@ -2767,7 +2889,11 @@ static Word16 SWB_BWE_encoding_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat +#else + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { @@ -3051,9 +3177,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( Word16 SWB_tenv_tmp_fx[SWB_TENV]; Word16 max_fx; Word16 energy_factor_fx[SWB_FENV], w_env_fx[SWB_FENV]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif Word16 inner_frame; Word16 q_shift; @@ -3114,7 +3242,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( } /* tilt returned in Q24 go to Q11 */ +#ifdef ISSUE_1867_replace_overflow_libenc + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat +#else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); +#endif test(); test(); IF( EQ_16( IsTransient, 1 ) && ( GT_16( tilt_fx, 16384 ) || GT_16( st_fx->clas, 1 ) ) ) @@ -3219,7 +3351,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( expn = sub( sub( 30, expn ), sub( shl( Q_insig_lp, 1 ), 7 ) ); expd = norm_l( WB_tenv_syn_fx ); +#ifdef ISSUE_1867_replace_overflow_libenc + den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat +#else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); +#endif expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); scale = shr( sub( den, num ), 15 ); @@ -3232,7 +3368,11 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat +#else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ +#endif } ELSE { @@ -3242,8 +3382,12 @@ static Word16 SWB_BWE_encoding_ivas_fx( IF( LT_16( Rat_tenv_fx, 8192 ) ) { - L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ - Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ + L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ +#ifdef ISSUE_1867_replace_overflow_libenc + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat +#else + Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ +#endif } ELSE IF( GT_16( Rat_tenv_fx, 16384 ) ) { diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index f510a1cb6..d7cebe322 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -117,9 +117,11 @@ void swb_bwe_enc_hr_fx( #else Word32 L_t_audio_tmp_fx[L_FRAME48k]; #endif +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; @@ -767,12 +769,12 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, temp2 ); +#ifdef ISSUE_1867_replace_overflow_libenc + t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat #else - L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); -#endif t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); +#endif move16(); } diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 3c92c7f89..2dedbfbeb 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -698,9 +698,11 @@ static void gethar_noisegn_fx( Word16 temp_lo, temp_hi; Word16 Qg; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*Generate HF noise*/ genhf_noise_fx( noise_flr_fx, Qss, L_xSynth_har, QsL, sspectra_fx, bands, har_bands, har_freq_est2, pos_max_hfe2, pul_res_fx, pk_sf_fx, fLenLow, @@ -782,9 +784,14 @@ static void gethar_noisegn_fx( exp = sub( exp, Qsqrt ); L_temp = L_Comp( exp, frac ); - L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ + L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ +#ifdef ISSUE_1867_replace_overflow_libenc + L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat + g_fx = round_fx_sat( L_temp ); //??sat +#else L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); +#endif } gqlevs_fx = 4; diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 394c9e87d..ea9dc53d1 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -5404,9 +5404,6 @@ static void EstimateSHBGainShape_fx( return; } -#ifdef ISSUE_1867_replace_overflow_libenc -#undef ISSUE_1867_replace_overflow_libenc -#endif /*==========================================================================*/ /* FUNCTION :static short closest_centroid_fx () */ /*--------------------------------------------------------------------------*/ -- GitLab From 4231bf22e28c3bbf0bc8862494110d54fdabc815 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 10:51:47 +0200 Subject: [PATCH 71/80] try to fix and update remaining files --- lib_enc/scale_enc_fx.c | 6 +----- lib_enc/set_impulse_fx.c | 6 +----- lib_enc/speech_music_classif_fx.c | 8 ++++++-- lib_enc/swb_bwe_enc_fx.c | 8 -------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index f0508b67c..13a5bda09 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -86,7 +86,7 @@ void Preemph_scaled( Word16 mu, shift, QVal; Word32 L_tmp, L_maxloc; Word16 Q_min; -#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -104,11 +104,7 @@ void Preemph_scaled( QVal = shl_sat( 1, sub( 15, bits ) ); //?sat #else Overflow = 0; -#ifdef ISSUE_1796_replace_shl_o QVal = shl_sat( 1, sub( 15, bits ) ); -#else - QVal = shl_o( 1, sub( 15, bits ), &Overflow ); -#endif #endif BASOP_SATURATE_WARNING_ON_EVS mu = shr( Preemph_factor, bits ); /* Q15 --> Q(15-bits) */ diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index 76a4b1afb..ba62825f8 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -226,11 +226,7 @@ void set_impulse_fx( num = div_s( num, den ); -#ifdef ISSUE_1867_replace_overflow_libenc - krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ //??sat -#else - krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ -#endif + krit_fx = shr_sat( num, sub( sub( shl_sat( exp_num, 1 ), exp_den ), 2 ) ); /* Q18 */ IF( GT_16( krit_fx, krit_max_fx ) ) { diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 4f809d827..d1c736c68 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1548,14 +1548,18 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ +#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ +#else + L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ +#endif FOR( i = 1; i < att_3lsub_pos; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1571,7 +1575,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 280624b4f..05b5ae65a 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -1093,20 +1093,12 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class expd = sub( sub( 30, expd ), shl( st_fx->prev_Q_shb, 1 ) ); scale = shr( sub( den, num ), 15 ); -#ifdef ISSUE_1796_replace_shl_o num = shl_sat( num, scale ); -#else - num = shl_o( num, scale, &Overflow ); -#endif expn = sub( expn, scale ); tmp = div_s( num, den ); expn = sub( expn, expd ); -#ifdef ISSUE_1796_replace_shl_o gain_tmp = shl_sat( tmp, sub( expn, 1 ) ); /*Q14 */ -#else - gain_tmp = shl_o( tmp, sub( expn, 1 ), &Overflow ); /*Q14 */ -#endif } test(); IF( EQ_16( hBWE_FD->prev_mode, TRANSIENT ) ) -- GitLab From b10aa8b115896587e57b4897ea49f09f51141353 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 11:07:26 +0200 Subject: [PATCH 72/80] try to fix and update remaining files --- lib_enc/speech_music_classif_fx.c | 8 ++++---- lib_enc/swb_bwe_enc_fx.c | 4 ---- lib_enc/tcx_utils_enc_fx.c | 2 +- lib_enc/vad_fx.c | 2 +- lib_enc/voiced_enc_fx.c | 4 ++-- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index d1c736c68..a1509d29d 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1548,11 +1548,7 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ -#ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ -#else - L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ -#endif FOR( i = 1; i < att_3lsub_pos; i++ ) { @@ -3828,10 +3824,14 @@ static void spec_analysis_fx( test(); IF( GT_16( peak_idx[k], valey_idx[i] ) && LT_16( peak_idx[k], valey_idx[i + 1] ) ) { +#ifdef ISSUE_1867_replace_overflow_libenc + p2v[k] = sub_sat( shl_sat( peak[k], 1 ), add_sat( valley[i], valley[i + 1] ) ); +#else #ifdef ISSUE_1796_replace_shl_o p2v[k] = sub_o( shl_sat( peak[k], 1 ), add_o( valley[i], valley[i + 1], &Overflow ), &Overflow ); #else p2v[k] = sub_o( shl_o( peak[k], 1, &Overflow ), add_o( valley[i], valley[i + 1], &Overflow ), &Overflow ); +#endif #endif move16(); k = add( k, 1 ); diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 05b5ae65a..a91e73cd3 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -1202,11 +1202,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class } test(); -#ifdef ISSUE_1796_replace_shl_o IF( GT_16( sharp, 4608 ) && GT_16( peak, shl_sat( 1, add( Q_syn, 3 ) ) ) ) -#else - IF( GT_16( sharp, 4608 ) && GT_16( peak, shl_o( 1, add( Q_syn, 3 ), &Overflow ) ) ) -#endif { k = add( k, 1 ); move16(); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 46efa66cf..331dc9a91 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2504,7 +2504,7 @@ void tcx_noise_factor_ivas_fx( Word16 att; /* noise level attenuation factor for transient windows */ Word32 xMax; Word16 exp_spQ[N_MAX]; -#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 2ac2118da..cd61ab598 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -702,7 +702,7 @@ Word16 wb_vad_fx( Word32 L_accum_ener_H; Word16 vad_bwidth_fx; Word16 last_7k2_coder_type; -#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 93a8a10b8..4be3eb939 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -122,7 +122,7 @@ ivas_error ppp_voiced_encoder_fx( Word32 low_band_en_fx; Word32 curr_Engy, prev_Engy; Word16 temp_Fs; -#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -1375,7 +1375,7 @@ static Word32 DTFS_freq_corr_fx( Word16 exp, tmp; Word32 L_tmp; Word16 Q_num, Q_den; -#if !defined( ISSUE_1867_replace_overflow_libenc ) && !defined( ISSUE_1796_replace_shl_o ) +#if !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); -- GitLab From 759ee21f05773858f06d41b7187446085955b859 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 11:23:24 +0200 Subject: [PATCH 73/80] clang patch --- lib_enc/speech_music_classif_fx.c | 4 ++-- lib_enc/swb_bwe_enc_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index a1509d29d..d8cc74e56 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1555,7 +1555,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1571,7 +1571,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat #else - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index a91e73cd3..ff3161ffb 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -1413,7 +1413,7 @@ static void vqWithCand_w_fx( #ifdef ISSUE_1867_replace_overflow_libenc dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat #else - dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ + dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ #endif L_dist = L_mult( dist, w[0] ); /*Q22 */ L_dist = Mult_32_16( L_dist, dist ); /*Q15 */ -- GitLab From c57f2d947a7c8e03db3823fe9ecd81ca3f3ec82f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 09:39:02 +0000 Subject: [PATCH 74/80] corrected macros --- lib_enc/find_tar_fx.c | 2 +- lib_enc/find_tilt_fx.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 2b7f3910b..f7071f5ae 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -185,7 +185,7 @@ void find_targets_ivas_fx( Word32 h1_32[6 * L_SUBFR]; Word16 sf; Word64 Ltmp64; -#ifndef BASOP_NOGLOB_DECLARE_LOCAL +#ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 4c3c3c914..a00881f1f 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -223,11 +223,7 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_hpE ); /* exp(e_tmp + e_hpE) */ e_tmp = sub( e_tmp, e_hpE ); -#ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#else - ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ -#endif } ELSE IF( lp_E == 0 ) { -- GitLab From 407c1071ae4c4645a947efc21eab8e5e7a44ed01 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 10:10:09 +0000 Subject: [PATCH 75/80] small fixes --- lib_enc/hvq_enc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 209277092..1ee79eef0 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -155,7 +155,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits #ifdef ISSUE_1867_replace_overflow_libenc noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat #else - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index ea9dc53d1..9c1ccba6f 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -13,6 +13,7 @@ #include "stl.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------* * Local constants *-----------------------------------------------------------------*/ @@ -4824,7 +4825,6 @@ static void EstimateSHBFrameGain_fx( return; } - static void EstimateSHBFrameGain_ivas_fx( const Word16 length, /* i : SHB overlap length */ const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ @@ -5077,6 +5077,7 @@ static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ) return ( sum ); } + static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ) { Word16 i, j; @@ -5404,6 +5405,7 @@ static void EstimateSHBGainShape_fx( return; } + /*==========================================================================*/ /* FUNCTION :static short closest_centroid_fx () */ /*--------------------------------------------------------------------------*/ -- GitLab From ee7a4775d8a6222dccc74dbb0cbe5ead7d200fde Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 12:20:31 +0200 Subject: [PATCH 76/80] clang patch & fix warning --- lib_enc/find_tar_fx.c | 2 ++ lib_enc/hvq_enc_fx.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index f7071f5ae..52baaaad7 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -185,9 +185,11 @@ void find_targets_ivas_fx( Word32 h1_32[6 * L_SUBFR]; Word16 sf; Word64 Ltmp64; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); +#endif #endif /*------------------------------------------------------------------------* * Find the target vector for excitation search: diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 1ee79eef0..189a85aec 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -123,7 +123,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits #ifdef ISSUE_1867_replace_overflow_libenc pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat #else - pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ + pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif } @@ -310,7 +310,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits #ifdef ISSUE_1867_replace_overflow_libenc pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat #else - pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ + pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif } -- GitLab From e7f781c4181fd1af3fd828bf8db230438d7e0a0c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 12:27:14 +0200 Subject: [PATCH 77/80] erase all //??sat comments --- lib_com/stat_noise_uv_mod_fx.c | 4 +- lib_enc/acelp_core_switch_enc_fx.c | 4 +- lib_enc/acelp_enc_util_fx.c | 4 +- lib_enc/analy_sp_fx.c | 2 +- lib_enc/ari_hm_enc_fx.c | 2 +- lib_enc/arith_coder_enc_fx.c | 2 +- lib_enc/avq_cod_fx.c | 2 +- lib_enc/bass_psfilter_enc_fx.c | 24 +++--- lib_enc/bw_detect_fx.c | 6 +- lib_enc/cng_enc_fx.c | 30 +++---- lib_enc/cod2t32_fx.c | 18 ++-- lib_enc/cod_ace_fx.c | 6 +- lib_enc/core_enc_ol_fx.c | 20 ++--- lib_enc/corr_xh_fx.c | 16 ++-- lib_enc/detect_transient_fx.c | 26 +++--- lib_enc/dtx_fx.c | 14 ++-- lib_enc/enc_acelp_fx.c | 50 +++++------ lib_enc/enc_acelpx_fx.c | 14 ++-- lib_enc/enc_amr_wb_fx.c | 10 +-- lib_enc/enc_gen_voic_fx.c | 48 +++++------ lib_enc/enc_gen_voic_rf_fx.c | 24 +++--- lib_enc/enc_higher_acelp_fx.c | 8 +- lib_enc/enc_pit_exc_fx.c | 38 ++++----- lib_enc/enc_tran_fx.c | 40 ++++----- lib_enc/energy_fx.c | 2 +- lib_enc/find_tar_fx.c | 10 +-- lib_enc/find_tilt_fx.c | 24 +++--- lib_enc/find_uv_fx.c | 24 +++--- lib_enc/gain_enc_fx.c | 26 +++--- lib_enc/gaus_enc_fx.c | 8 +- lib_enc/gp_clip_fx.c | 6 +- lib_enc/gs_enc_fx.c | 4 +- lib_enc/guided_plc_enc_fx.c | 6 +- lib_enc/hf_cod_amrwb_fx.c | 4 +- lib_enc/hq_classifier_enc_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 50 +++++------ lib_enc/hvq_enc_fx.c | 6 +- lib_enc/igf_enc_fx.c | 10 +-- lib_enc/ivas_tcx_core_enc_fx.c | 2 +- lib_enc/lsf_enc_fx.c | 18 ++-- lib_enc/lsf_msvq_ma_enc_fx.c | 4 +- lib_enc/mdct_classifier_fx.c | 6 +- lib_enc/multi_harm_fx.c | 16 ++-- lib_enc/nelp_enc_fx.c | 20 ++--- lib_enc/nois_est_fx.c | 40 ++++----- lib_enc/normalizecoefs_fx.c | 2 +- lib_enc/pit_enc_fx.c | 10 +-- lib_enc/pitch_ol2_fx.c | 26 +++--- lib_enc/pitch_ol_fx.c | 16 ++-- lib_enc/ppp_enc_fx.c | 30 +++---- lib_enc/pvq_encode_fx.c | 12 +-- lib_enc/q_gain2p_fx.c | 12 +-- lib_enc/qlpc_stoch_fx.c | 4 +- lib_enc/scale_enc_fx.c | 16 ++-- lib_enc/set_impulse_fx.c | 16 ++-- lib_enc/speech_music_classif_fx.c | 28 +++---- lib_enc/swb_bwe_enc_fx.c | 52 ++++++------ lib_enc/swb_bwe_enc_hr_fx.c | 2 +- lib_enc/swb_bwe_enc_lr_fx.c | 4 +- lib_enc/swb_tbe_enc_fx.c | 128 ++++++++++++++--------------- lib_enc/tcx_ltp_enc_fx.c | 20 ++--- lib_enc/tcx_utils_enc_fx.c | 6 +- lib_enc/tns_base_enc_fx.c | 4 +- lib_enc/transition_enc_fx.c | 12 +-- lib_enc/vad_fx.c | 26 +++--- lib_enc/vad_param_updt_fx.c | 4 +- lib_enc/vbr_average_rate_fx.c | 2 +- lib_enc/vlpc_2st_cod_fx.c | 2 +- lib_enc/voiced_enc_fx.c | 58 ++++++------- 69 files changed, 597 insertions(+), 597 deletions(-) diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 23ebe81b4..bd67e400f 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -168,7 +168,7 @@ void stat_noise_uv_mod_fx( { exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ #ifdef ISSUE_1836_replace_overflow_libcom - exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ //??Sat + exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ #else exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15 */ #endif @@ -197,7 +197,7 @@ void stat_noise_uv_mod_fx( tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); #ifdef ISSUE_1836_replace_overflow_libcom - tmp_res = shl_sat( tmp_res, tmp_shift ); //??Sat + tmp_res = shl_sat( tmp_res, tmp_shift ); #else tmp_res = shl_o( tmp_res, tmp_shift, &Overflow ); #endif diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 3b3d1db95..75f4d08b6 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -848,7 +848,7 @@ static void bwe_switch_enc_fx( q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ #else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ #endif @@ -997,7 +997,7 @@ static void bwe_switch_enc_ivas_fx( q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ //??sat + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ #else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ #endif diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 642e870be..65a54ac2d 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -178,7 +178,7 @@ void E_ACELP_conv( } L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Q0 */ //??sat //??sat + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Q0 */ #else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */ #endif @@ -210,7 +210,7 @@ void E_ACELP_conv_ivas_fx( } L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */ #ifdef ISSUE_1867_replace_overflow_libenc - cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/ //??sat //??sat + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/ #else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/ #endif diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index fa91cec99..00199070a 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -952,7 +952,7 @@ static void find_enr( /* normalization - corresponds to FFT normalization by 2/L_FFT */ BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ #ifdef ISSUE_1867_replace_overflow_libenc - *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ //??sat + *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ #else *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ #endif diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 7d1f2246e..8bee83310 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -460,7 +460,7 @@ Word16 SearchPeriodicityIndex_fx( tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp3 = div_s( round_fx_sat( L_shl( tmp32, tmp ) ), round_fx_sat( L_shl( AbsTotal, tmp2 ) ) ); //??sat //??sat + 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 ) ); #endif diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index b1aba7701..9013c5c41 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -75,7 +75,7 @@ static Word16 tcx_arith_estimate_scale( } #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r( round_fx_sat( L_shl( abs_spectrum[k], s1 ) ), envelope[k] ); //??sat + 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] ); #endif diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index fc3cb985b..7436076a2 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -54,7 +54,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor 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] ); //??sat + 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 ); #endif diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index 1c2bf9089..2227e4c83 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -156,14 +156,14 @@ Word16 bass_pf_enc_fx( { 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] ); //??sat - tmp16 = mac_r_sat( tmp32, gain, syn[i + i_subfr] ); /* Q0 */ //??sat + 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 */ //??sat + lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ - tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat - ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat + 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 ); tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */ @@ -183,13 +183,13 @@ Word16 bass_pf_enc_fx( { 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 */ //??sat - tmp16 = round_fx_sat( tmp32 ); //??sat + 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 */ //??sat + lp_error = L_mac_sat( lp_error, tmp16, 0x1000 ); /* Q13 */ - tmp16 = round_fx_sat( L_shl_sat( lp_error, s1 ) ); /* Q0+s1-3 */ //??sat - ener2 = L_mac0_sat( ener2, tmp16, tmp16 ); /* Q0+(s1-3)*2 */ //??sat + 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 */ tmp16 = round_fx_o( tmp32, &Overflow ); @@ -260,7 +260,7 @@ Word16 bass_pf_enc_fx( 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*/ //??sat + 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*/ #endif @@ -278,7 +278,7 @@ Word16 bass_pf_enc_fx( move16(); #ifdef ISSUE_1867_replace_overflow_libenc - error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ //??sat + 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*/ #endif diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 38274d667..ae27e5724 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -131,7 +131,7 @@ void bw_detect_fx( } L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ //??sat + 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 */ #endif @@ -304,7 +304,7 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - spect[i] = round_fx_sat( L_shr_sat( spect32[i], Q_dct ) ); //??sat //??sat + 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 @@ -346,7 +346,7 @@ void bw_detect_fx( FOR( j = 0; j < bin_width; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); //??sat + sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); #else sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); #endif diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 836fb2604..dbd48cfe7 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -638,7 +638,7 @@ void CNG_enc_fx( { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - dist = add_sat( dist, dev ); /*Q15 */ //??sat + dist = add_sat( dist, dev ); /*Q15 */ #else dist = add_o( dist, dev, &Overflow ); /*Q15 */ #endif @@ -772,9 +772,9 @@ void CNG_enc_fx( { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat + 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_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ @@ -1059,7 +1059,7 @@ void CNG_enc_fx( L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ #else L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ #endif @@ -1958,9 +1958,9 @@ void CNG_enc_ivas_fx( { /* env[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( *ptR, *ptR ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_new+1 */ //??sat - L_tmp = L_add_sat( L_tmp, L_tmp ); /* 2*Q_new+1 */ //??sat + 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_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ @@ -2269,7 +2269,7 @@ void CNG_enc_ivas_fx( L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ //??sat + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ #else L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ #endif @@ -2562,7 +2562,7 @@ static Word16 shb_DTX_fx( FOR( i = 0; i < st_fx->L_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k[i], syn_12k8_16k[i] ); //??sat + 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 ); #endif @@ -2575,7 +2575,7 @@ static Word16 shb_DTX_fx( exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); #ifdef ISSUE_1867_replace_overflow_libenc - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat + 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 */ #endif @@ -2598,7 +2598,7 @@ static Word16 shb_DTX_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat + 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 */ #endif @@ -3034,7 +3034,7 @@ static Word16 shb_DTX_ivas_fx( FOR( i = 0; i < st->L_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - wb_ener_fx = L_mac_sat( wb_ener_fx, syn_12k8_16k_fx[i], syn_12k8_16k_fx[i] ); // ( Q0 + Q0 + Q1 ) --> Q1 due to left shift in L_mac //??sat + 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 #endif @@ -3048,7 +3048,7 @@ static Word16 shb_DTX_ivas_fx( wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); #ifdef ISSUE_1867_replace_overflow_libenc - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ //??sat //??sat + 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 */ #endif @@ -3076,7 +3076,7 @@ static Word16 shb_DTX_ivas_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - log_shb_ener_fx = sub_sat( round_fx_sat( L_shl_sat( shb_ener_fx, 10 ) ), att_fx ); /* log_shb_ener_fx in Q8 */ //??sat //??sat //??sat + 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 */ #endif diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index 2c36dff14..2a2016118 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -66,7 +66,7 @@ void acelp_2t32_fx( 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 ); //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -74,7 +74,7 @@ void acelp_2t32_fx( *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); //??sat + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -119,10 +119,10 @@ void acelp_2t32_fx( 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) //??sat - L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat - *p0 = round_fx_sat( L_cor ); // Q(9) //??sat - L_cor = L_mac_sat( L_cor, *ptr_h1++, *ptr_h2++ ); //??sat + *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) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); @@ -136,7 +136,7 @@ void acelp_2t32_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - *p1 = round_fx_sat( L_cor ); // Q9 //??sat + *p1 = round_fx_sat( L_cor ); // Q9 #else *p1 = round_fx_o( L_cor, &Overflow ); // Q9 #endif @@ -243,9 +243,9 @@ void acelp_2t32_fx( { ps2 = add( ps1, dn_p[i1] ); #ifdef ISSUE_1867_replace_overflow_libenc - alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); //??sat //??sat + alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); sq = mult( ps2, ps2 ); - s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); //??sat + s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); #else alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); sq = mult( ps2, ps2 ); diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index cfc29cf68..9a3a227cb 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -354,7 +354,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Ltmp = L_shl( Ltmp, Q_new_p5 ); 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 ) ); //??sat + exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); #else exc2[i] = round_fx_sat( L_shl_o( Ltmp, 1, &Overflow ) ); #endif @@ -363,8 +363,8 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); Ltmp = L_add_sat( Ltmp, Ltmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here */ //??sat - exc[i + i_subfr] = round_fx_sat( Ltmp ); //??sat + 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 */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index cdf7f0362..84ceed3f4 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -556,7 +556,7 @@ void core_encode_openloop_fx( 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 ); //??sat + 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 ); #endif @@ -781,8 +781,8 @@ static void closest_centroid_rf( FOR( j = 0; j < length; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = sub_sat( data[j], quantizer[tmpL + j] ); //??sat - L_tmp = L_mult_sat( tmp, tmp ); //??sat + 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 ); L_tmp = L_mult_o( tmp, tmp, &Overflow ); @@ -1120,7 +1120,7 @@ void core_acelp_tcx20_switching_fx( 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] ); //??sat + 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 ); #endif @@ -1142,7 +1142,7 @@ void core_acelp_tcx20_switching_fx( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */ //??sat //??sat + 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 */ #endif @@ -1180,11 +1180,11 @@ void core_acelp_tcx20_switching_fx( 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] ); //??sat + 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 ) ); //??sat - tmp16 = sub_sat( st->wspeech_enc[i + j], tmp16 ); //??sat - noise = L_mac0_sat( noise, tmp16, tmp16 ); //??sat + 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 ); @@ -1245,7 +1245,7 @@ void core_acelp_tcx20_switching_fx( if ( ( GT_16( snr_acelp, snr_tcx ) ) && ( 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*/ ) || //??sat + ( 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*/ ) || #endif diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index 062707247..f17ade3e5 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -50,7 +50,7 @@ void corr_xh_fx( 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*/ //??sat + 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*/ #endif @@ -64,8 +64,8 @@ void corr_xh_fx( /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat - L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat + 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_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ @@ -126,8 +126,8 @@ void corr_hh_ivas_fx( /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat - L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat + 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_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ @@ -180,7 +180,7 @@ void corr_xh_ivas_fx( 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 //??sat + 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 #endif @@ -194,8 +194,8 @@ void corr_xh_ivas_fx( /* tot += 3*max / 8 */ L_maxloc = L_shr( L_maxloc, 2 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tot = L_add_sat( L_tot, L_maxloc ); /* +max/4 */ //??sat - L_tot = L_add_sat( L_tot, L_shr( L_maxloc, 1 ) ); /* +max/8 */ //??sat + 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_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 3a6ba1dcc..cce34c066 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -72,7 +72,7 @@ static void hp_filter_fx( /*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 */ //??sat + 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 */ #endif @@ -82,9 +82,9 @@ static void hp_filter_fx( { /*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 */ //??sat - L_tmp = L_mac_sat( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/ ); /*Q_new+16 */ //??sat - y[i] = round_fx_sat( L_tmp ); /*Q_new */ //??sat + 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_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */ @@ -166,7 +166,7 @@ Word16 detect_transient_fx( { /*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 */ //??sat + 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 */ #endif @@ -189,13 +189,13 @@ Word16 detect_transient_fx( { 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 ) ); //??sat + Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); #else Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow ); #endif 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*/ //??sat + 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*/ #endif @@ -203,8 +203,8 @@ Word16 detect_transient_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E_in_fx = L_add_sat( E_in_fx, Energy_in_fx[blk + 1] ); /*Q0*/ //??sat - E_out_fx = L_add_sat( E_out_fx, Energy_fx ); /*Q0*/ //??sat + 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_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/ @@ -233,7 +233,7 @@ Word16 detect_transient_fx( { /*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 */ //??sat + 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 */ #endif @@ -243,7 +243,7 @@ Word16 detect_transient_fx( { /*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 */ //??sat + 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 */ #endif @@ -263,7 +263,7 @@ Word16 detect_transient_fx( 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*/ //??sat + Energy = L_add_sat( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) ); /*2Q_new - shift*/ #endif test(); IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) @@ -306,7 +306,7 @@ Word16 detect_transient_fx( /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*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 */ //??sat + 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 */ #endif diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index d2d7b01a4..ea63e275f 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -464,7 +464,7 @@ void dtx_ivas_fx( 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*/ //??sat + 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*/ #endif @@ -940,7 +940,7 @@ void dtx_fx( 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*/ //??sat + 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*/ #endif @@ -1422,7 +1422,7 @@ void dtx_hangover_control_fx( 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 */ //??sat + 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 */ #endif @@ -1442,14 +1442,14 @@ void dtx_hangover_control_fx( 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 */ //??sat + 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 */ #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 */ //??sat + 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 */ #endif @@ -1463,7 +1463,7 @@ void dtx_hangover_control_fx( 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 */ //??sat + 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 */ #endif @@ -1480,7 +1480,7 @@ void dtx_hangover_control_fx( { 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 */ //??sat + Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */ #else Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ #endif diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index d05508bb5..4c287b461 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -78,14 +78,14 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac 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*/ //??sat + 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*/ #endif } #ifdef ISSUE_1867_replace_overflow_libenc - corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ //??sat + corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ #else corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ #endif @@ -95,7 +95,7 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac if ( sign[dn] > 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = add_sat( p0[j], corr ); /*Q9*/ //??sat + corr = add_sat( p0[j], corr ); /*Q9*/ #else corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ #endif @@ -103,7 +103,7 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac if ( sign[dn] < 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = sub_sat( p0[j], corr ); /*Q9*/ //??sat + corr = sub_sat( p0[j], corr ); /*Q9*/ #else corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ #endif @@ -139,13 +139,13 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac 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 */ //??sat + 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 */ #endif } #ifdef ISSUE_1867_replace_overflow_libenc - corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ //??sat + corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ #else corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ #endif @@ -155,11 +155,11 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac #ifdef ISSUE_1867_replace_overflow_libenc if ( sign[pos] > 0 ) { - corr = add_sat( *p0++, corr ); /*Q9*/ //??sat + corr = add_sat( *p0++, corr ); /*Q9*/ } if ( sign[pos] < 0 ) { - corr = sub_sat( *p0++, corr ); /*Q9*/ //??sat + corr = sub_sat( *p0++, corr ); /*Q9*/ } #else if ( sign[pos] > 0 ) @@ -237,7 +237,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* move16(); 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 ) //??sat //??sat //??sat + 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 ) #endif @@ -261,7 +261,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* /*alp1 = alp0 + cor_x[x2];*/ #ifdef ISSUE_1867_replace_overflow_libenc - alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ //??sat + alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ #else alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/ #endif @@ -277,8 +277,8 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* /*alp2 = alp1 + (*p1++) + (*p2++);*/ #ifdef ISSUE_1867_replace_overflow_libenc - alp2 = L_mac_sat( alp1, *p1++, _1_ ); /*Qx+12+1*/ //??sat - alp2_16 = mac_r_sat( alp2, *p2++, _1_ ); /*Q6*/ //??sat + 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_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ @@ -589,14 +589,14 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Compute scalar product t1: */ #ifdef ISSUE_1867_replace_overflow_libenc - yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/ //??sat + 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*/ #endif /* Compute scalar product t0: */ #ifdef ISSUE_1867_replace_overflow_libenc - xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/ //??sat + 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*/ #endif @@ -642,7 +642,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Compute scalar product */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/ //??sat + 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*/ #endif @@ -656,7 +656,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn exp_tmp = sub( exp_tmp, 1 ); 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*/ //??sat //??sat + 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*/ #endif @@ -779,13 +779,13 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, if ( Q15_flag == 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/ //??sat + 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*/ #endif } #ifdef ISSUE_1867_replace_overflow_libenc - x2[i] = msu_r_sat( L_tmp, y[i], gain ); /*Q_xn*/ //??sat + 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*/ #endif @@ -837,7 +837,7 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ //??sat + 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*/ #endif @@ -858,8 +858,8 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 Lcor = L_shr( Lcor, i ); #ifdef ISSUE_1867_replace_overflow_libenc - k_dn = round_fx_sat( Lval ); /*Q15 - e_dn*/ //??sat - k_cn = round_fx_sat( Lcor ); /*Q15 - e_cn*/ //??sat + 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_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ @@ -884,7 +884,7 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ #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*/ //??sat //??sat + 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*/ #endif @@ -1228,7 +1228,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const 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*/ //??sat + 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*/ #endif @@ -1382,7 +1382,7 @@ 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*/ 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*/ //??sat + 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*/ #endif @@ -1497,7 +1497,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ //??sat + y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ #else y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 52c01fed2..7527a4602 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -170,7 +170,7 @@ static void E_ACELP_2pulse_searchx_fx( 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 ) //??sat //??sat //??sat + 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 ) #endif @@ -214,7 +214,7 @@ static void E_ACELP_2pulse_searchx_fx( 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 */ //??sat + 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 */ #endif @@ -229,7 +229,7 @@ static void E_ACELP_2pulse_searchx_fx( 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 */ //??sat + 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 */ #endif @@ -245,7 +245,7 @@ static void E_ACELP_2pulse_searchx_fx( /*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 */ //??sat + 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 */ #endif @@ -327,7 +327,7 @@ static void E_ACELP_1pulse_searchx_fx( ik = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) //??sat + 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 ) #endif @@ -355,7 +355,7 @@ static void E_ACELP_1pulse_searchx_fx( /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(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 */ //??sat + 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 */ #endif @@ -370,7 +370,7 @@ static void E_ACELP_1pulse_searchx_fx( /*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 */ //??sat + 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 */ #endif diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 3825fd04e..07878dc16 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -193,8 +193,8 @@ void encod_amr_wb_fx( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ @@ -205,7 +205,7 @@ void encod_amr_wb_fx( FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ //??sat //??sat + exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ #else exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/ #endif @@ -236,8 +236,8 @@ void encod_amr_wb_fx( L_tmp = L_shl_sat( L_tmp, 5 ); /*Q15*/ L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ //??sat - exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ //??sat + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ + exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ #else L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index ca5209509..323f11575 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -284,7 +284,7 @@ void encod_gen_voic_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif @@ -340,8 +340,8 @@ void encod_gen_voic_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ //??sat + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #else Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ @@ -382,8 +382,8 @@ void encod_gen_voic_fx( { /* Contribution from AVQ layer */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ //??sat - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ //??sat + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ #else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/ Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ @@ -391,8 +391,8 @@ void encod_gen_voic_fx( /* Compute exc2 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ //??sat - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ #else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */ exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ @@ -404,8 +404,8 @@ void encod_gen_voic_fx( Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ //??sat - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ //??sat //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ #else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ @@ -424,10 +424,10 @@ void encod_gen_voic_fx( /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ //??sat - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ //??sat + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */ @@ -742,8 +742,8 @@ void encod_gen_voic_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); //??sat + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); #else Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -799,8 +799,8 @@ void encod_gen_voic_ivas_fx( { /* Contribution from AVQ layer */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); //??sat - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); //??sat + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); #else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); @@ -808,8 +808,8 @@ void encod_gen_voic_ivas_fx( /* Compute exc2 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); //??sat - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); #else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); @@ -821,8 +821,8 @@ void encod_gen_voic_ivas_fx( Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ //??sat - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); //??sat //??sat + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); #else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); @@ -843,10 +843,10 @@ void encod_gen_voic_ivas_fx( /*gcode16 in Qnew*/ Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ //??sat - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ //??sat - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/ diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 9a644cd74..1f5beed74 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -444,13 +444,13 @@ void coder_acelp_rf_fx( /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat - Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ //??sat + Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ + Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ /* Add Gaussian contribution*/ Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ - Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ //??sat - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ //??sat - hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ //??sat //??sat //??sat + Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ + hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ #else Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */ @@ -476,15 +476,15 @@ void coder_acelp_rf_fx( /* code in Q9, gain_pit in Q14; exc Q_new */ Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ //??sat - exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ //??sat //??sat + Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ + Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ + exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ move16(); Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ - Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ //??sat - exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat + Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ + exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ #else Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index b946b4c39..298800736 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -86,7 +86,7 @@ void transf_cdbk_enc_fx( IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); #else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); #endif @@ -185,7 +185,7 @@ void transf_cdbk_enc_fx( e_corr = sub( 14 + 4, e_den ); Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ #ifdef ISSUE_1867_replace_overflow_libenc - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ #else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ #endif @@ -444,7 +444,7 @@ void transf_cdbk_enc_ivas_fx( IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); //??sat //??sat + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); #else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); #endif @@ -542,7 +542,7 @@ void transf_cdbk_enc_ivas_fx( e_corr = sub( 14 + 4, e_den ); Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ #ifdef ISSUE_1867_replace_overflow_libenc - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ //??sat //??sat + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ #else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index aa03ce277..42a3a292f 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -298,7 +298,7 @@ void enc_pit_exc_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ //??sat //??sat + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif @@ -381,12 +381,12 @@ void enc_pit_exc_fx( { Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ //??sat + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ //??sat - Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ //??sat - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ //??sat - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ #else Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); @@ -418,10 +418,10 @@ void enc_pit_exc_fx( /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ //??sat - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -885,12 +885,12 @@ void enc_pit_exc_ivas_fx( { Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); // Q_new+14+shift //??sat + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift //??sat - Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift //??sat - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 //??sat - hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ //??sat + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ #else Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); @@ -920,10 +920,10 @@ void enc_pit_exc_ivas_fx( /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ //??sat - Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ //??sat + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 004fda87b..b5a3a037a 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -231,8 +231,8 @@ Word16 encod_tran_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); //??sat + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -286,10 +286,10 @@ Word16 encod_tran_fx( /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ #else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -309,11 +309,11 @@ Word16 encod_tran_fx( { L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat - tmp_fx = round_fx_sat( L_tmp ); //??sat - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ + tmp_fx = round_fx_sat( L_tmp ); + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ move16(); #else L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ @@ -635,8 +635,8 @@ Word16 encod_tran_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ //??sat - gcode16 = round_fx_sat( Lgcode ); //??sat + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -690,10 +690,10 @@ Word16 encod_tran_ivas_fx( /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ //??sat - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ //??sat - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ //??sat - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ //??sat + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ #else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -713,12 +713,12 @@ Word16 encod_tran_ivas_fx( { L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ //??sat - tmp_fx = round_fx_sat( L_tmp ); //??sat + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ + tmp_fx = round_fx_sat( L_tmp ); - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ //??sat + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ #else L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index 1ea294f9d..988b3a29d 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -122,7 +122,7 @@ void est_energy_fx( tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */ s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } - frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ //??sat + frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ move32(); } diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index 52baaaad7..ee37b3af2 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -135,7 +135,7 @@ void find_targets_fx( Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ } #ifdef ISSUE_1867_replace_overflow_libenc - h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ //??sat + h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ #else h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ #endif @@ -266,7 +266,7 @@ void find_targets_ivas_fx( FOR( j = 1; j <= i; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif @@ -279,7 +279,7 @@ void find_targets_ivas_fx( FOR( j = 1; j <= M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif @@ -290,14 +290,14 @@ void find_targets_ivas_fx( FOR( i = M + 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ #endif FOR( j = 2; j <= M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ //??sat + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index a00881f1f..6533f7071 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -111,8 +111,8 @@ void find_tilt_fx( Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); /* Q31 */ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); /* Q31 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ //??sat - mean_voi = round_fx_sat( Ltmp ); /* Q15 */ //??sat + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ + mean_voi = round_fx_sat( Ltmp ); /* Q15 */ #else Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ @@ -163,7 +163,7 @@ void find_tilt_fx( IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ //??sat + lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ #else lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */ #endif @@ -172,8 +172,8 @@ void find_tilt_fx( pt_E++; } #ifdef ISSUE_1867_replace_overflow_libenc - f1 = add_sat( f1, f0 ); //??sat - f2 = add_sat( f2, f0 ); //??sat + f1 = add_sat( f1, f0 ); + f2 = add_sat( f2, f0 ); #else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); @@ -192,7 +192,7 @@ void find_tilt_fx( e_tmp = sub( e_tmp, e_cnt ); #ifdef ISSUE_1867_replace_overflow_libenc - lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ //??sat //??sat + lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ #else lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif @@ -237,7 +237,7 @@ void find_tilt_fx( IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( ee[i], 3 ); //??sat + Ltmp = L_shl_sat( ee[i], 3 ); #else Ltmp = L_shl_o( ee[i], 3, &Overflow ); #endif @@ -373,8 +373,8 @@ void find_tilt_ivas_fx( Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 //??sat - mean_voi = round_fx_sat( Ltmp ); // Q15 //??sat + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 + mean_voi = round_fx_sat( Ltmp ); // Q15 #else Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 @@ -431,8 +431,8 @@ void find_tilt_ivas_fx( pt_E++; } #ifdef ISSUE_1867_replace_overflow_libenc - f1 = add_sat( f1, f0 ); //??sat - f2 = add_sat( f2, f0 ); //??sat + f1 = add_sat( f1, f0 ); + f2 = add_sat( f2, f0 ); #else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); @@ -505,7 +505,7 @@ void find_tilt_ivas_fx( IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ //??sat + Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ #else Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ #endif diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 09bef73ea..ce764dd63 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -201,7 +201,7 @@ Word16 find_uv_fx( /* o : coding type */ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef ISSUE_1867_replace_overflow_libenc - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ #else mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ #endif @@ -231,7 +231,7 @@ Word16 find_uv_fx( /* o : coding type */ dE2_th = 21 << 10; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #else if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif @@ -314,7 +314,7 @@ Word16 find_uv_fx( /* o : coding type */ if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ #ifdef ISSUE_1867_replace_overflow_libenc - ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ //??sat + ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ #else ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ #endif @@ -394,8 +394,8 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ @@ -428,7 +428,7 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #endif @@ -740,7 +740,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef ISSUE_1867_replace_overflow_libenc - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ //??sat //??sat + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ #else mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ #endif @@ -770,7 +770,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ dE2_th = 21 << 10; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ //??sat + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #else if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif @@ -856,7 +856,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) - /* normalized correlation is low */ //??sat + /* normalized correlation is low */ #else IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ @@ -938,8 +938,8 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ //??sat + IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ @@ -978,7 +978,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ //??sat + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #endif diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 5a6752091..ee55f1d9a 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -98,7 +98,7 @@ void Es_pred_enc_fx( { tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ #ifdef ISSUE_1867_replace_overflow_libenc - ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); //??sat + ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); #else ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow ); #endif @@ -184,7 +184,7 @@ void Es_pred_enc_fx( FOR( i = 1; i < size; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); //??sat + tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); #else tmp16_2 = abs_s( sub_o( mean_ener_code16, qua_table[i], &Overflow ) ); #endif @@ -412,7 +412,7 @@ void gain_enc_mless_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -441,7 +441,7 @@ void gain_enc_mless_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); //??sat + *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); #else *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); #endif @@ -475,7 +475,7 @@ void gain_enc_mless_fx( push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ //??sat + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ #else *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ #endif @@ -706,7 +706,7 @@ void gain_enc_SQ_fx( exp1 = add( exp_coeff[0], exp_coeff[2] ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ //??sat + L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ #else L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ #endif @@ -752,7 +752,7 @@ void gain_enc_SQ_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ #else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif @@ -761,7 +761,7 @@ void gain_enc_SQ_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ //??sat //??sat + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -785,7 +785,7 @@ void gain_enc_SQ_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ //??sat + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ #else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif @@ -912,7 +912,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Ltmp = Pow2( 14, frac_gain ); /* Put 14 as exponent */ exp_gain = sub( exp_gain, 14 ); /* Retreive exponent of wtmp */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); //??sat + *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); #else *gain = L_shl_o( Ltmp, add( 16, exp_gain ), &Overflow ); #endif @@ -1235,7 +1235,7 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat + L_tmp1 = L_sub_sat( L_tmp, dist_min ); #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -2009,7 +2009,7 @@ void gain_enc_amr_wb_fx( L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat + L_tmp1 = L_sub_sat( L_tmp, dist_min ); #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -2036,7 +2036,7 @@ void gain_enc_amr_wb_fx( L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ //??sat + L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ #else L_tmp = L_shl_o( L_tmp, add( exp_gcode0, 4 ), &Overflow ); /* Q12 -> Q16 */ #endif diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 9b324a1a0..3de426846 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -101,7 +101,7 @@ Word16 gaus_encode_fx( * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ #ifdef ISSUE_1867_replace_overflow_libenc - gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ //??sat //??sat + gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ #else gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ #endif @@ -433,8 +433,8 @@ void gauss2v_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); #ifdef ISSUE_1867_replace_overflow_libenc - cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); //??sat //??sat - eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); //??sat //??sat + cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); + eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); #else cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); @@ -608,7 +608,7 @@ void gauss2v_fx( /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ //??sat + *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ #else *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */ #endif diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index b5a3ac956..5d32a390a 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -145,14 +145,14 @@ Word16 gp_clip_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - ener = L_mac_sat( 1L, xn[0], xn[0] ); //??sat + ener = L_mac_sat( 1L, xn[0], xn[0] ); #else ener = L_mac_o( 1L, xn[0], xn[0], &Overflow ); #endif FOR( i = 1; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - ener = L_mac_sat( ener, xn[i], xn[i] ); //??sat + ener = L_mac_sat( ener, xn[i], xn[i] ); #else ener = L_mac_o( ener, xn[i], xn[i], &Overflow ); #endif @@ -368,7 +368,7 @@ Word16 Mode2_gp_clip_fx( FOR( i = 0; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - wener = L_mac0_sat( wener, xn[i], xn[i] ); //??sat + wener = L_mac0_sat( wener, xn[i], xn[i] ); #else wener = L_mac0_o( wener, xn[i], xn[i], &Overflow ); #endif diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index ea73820e8..424564fcb 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1344,7 +1344,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/ ener_max = L_max( ener_max, L_tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - ener_mean = L_add_sat( ener_mean, L_tmp ); //??sat + ener_mean = L_add_sat( ener_mean, L_tmp ); #else ener_mean = L_add_o( ener_mean, L_tmp, &Overflow ); #endif @@ -1356,7 +1356,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ { exp1 = norm_l( ener_mean ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); #else tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow ); #endif diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index c46f6f070..dcaa15469 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -168,7 +168,7 @@ static void coderLookAheadInnovation( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); //??sat + max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); #else max_ps_tmp = L_shl_o( max_ps, sub( max_ps_e, ps_e ), &Overflow ); #endif @@ -464,7 +464,7 @@ void updateSpecPowDiffuseIdx_fx( FOR( k = 1; k < 4; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); //??sat + st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); #else st->mean_gc[1] = L_add_o( st->mean_gc[1], st->gain_code[k], &Overflow ); #endif @@ -475,7 +475,7 @@ void updateSpecPowDiffuseIdx_fx( /* Suppress saturation warning in threshold comparison. */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) //??sat + if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) #else if ( LT_32( st->mean_gc[1], L_add_o( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ), &Overflow ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) #endif diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index 7d2f7afcf..7e49055f0 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -113,7 +113,7 @@ void hf_cod_fx( L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ #ifdef ISSUE_1867_replace_overflow_libenc - scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ //??sat + scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ #else scale_fx = round_fx( Isqrt( L_shl_o( L_tmp, sub( q2, 26 ), &Overflow ) ) ); /*Q13 */ #endif @@ -193,7 +193,7 @@ void hf_cod_fx( L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ #ifdef ISSUE_1867_replace_overflow_libenc - HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ //??sat + HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ #else HF_calc_gain_fx = round_fx_o( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ), &Overflow ); /*Q10 */ #endif diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 1185bb75e..b738dc8f3 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -811,7 +811,7 @@ void hvq_classifier_ivas_fx( move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ //??sat + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ #else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); /* Q6 */ #endif @@ -1249,7 +1249,7 @@ void hvq_classifier_fx( /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); //??sat + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); #else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); #endif diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index b0d9bbba8..4c90d2762 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -610,7 +610,7 @@ void hq_lr_enc_fx( } L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ //??sat + L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ #else L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( 12, exp ), &Overflow ); /*Q(13+exp-15 +12-exp +4 = 14) */ #endif @@ -631,7 +631,7 @@ void hq_lr_enc_fx( } L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ //??sat + L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ #else L_tmp2 = L_shl_o( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ), &Overflow ); /*Q(13+exp-15 +13-exp +3 = 14) */ #endif @@ -658,7 +658,7 @@ void hq_lr_enc_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat + L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ #else L_tmp = L_shl_o( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ #endif @@ -685,7 +685,7 @@ void hq_lr_enc_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ //??sat + L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ #else L_tmp = L_shl_o( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ), &Overflow ); /*Q(13+exp-15 +19-exp +3 = 20) */ #endif @@ -768,7 +768,7 @@ void hq_lr_enc_fx( FOR( i = 0; i < bands_fx; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ #else Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ #endif @@ -804,7 +804,7 @@ void hq_lr_enc_fx( { Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -877,7 +877,7 @@ void hq_lr_enc_fx( tmp = sub( tmp, lowband ); L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ #else tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ #endif @@ -942,7 +942,7 @@ void hq_lr_enc_fx( IF( GE_16( i, lowband ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -950,7 +950,7 @@ void hq_lr_enc_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1489,7 +1489,7 @@ void hq_lr_enc_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1617,7 +1617,7 @@ void hq_lr_enc_ivas_fx( } Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ //??sat + L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ #else L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ #endif @@ -1668,7 +1668,7 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1714,7 +1714,7 @@ void hq_lr_enc_ivas_fx( Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ //??sat + L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ #else L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ #endif @@ -1742,7 +1742,7 @@ void hq_lr_enc_ivas_fx( FOR( i = 0; i < bands; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ //??sat + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ #else Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ #endif @@ -1782,7 +1782,7 @@ void hq_lr_enc_ivas_fx( { Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1819,7 +1819,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); /*Q0 */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ #else tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ #endif @@ -1862,7 +1862,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ //??sat + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ #else tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ #endif @@ -1891,7 +1891,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ //??sat + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ #else tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ #endif @@ -1934,7 +1934,7 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1942,7 +1942,7 @@ void hq_lr_enc_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ //??sat + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1971,7 +1971,7 @@ void hq_lr_enc_ivas_fx( FOR( i = 0; i < lowband; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ //??sat + tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ #else tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ #endif @@ -3555,7 +3555,7 @@ static Word16 p2a_threshold_quant_fx( L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ #ifdef ISSUE_1867_replace_overflow_libenc - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ #else p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ #endif @@ -3680,7 +3680,7 @@ static Word16 p2a_threshold_quant_ivas_fx( L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ #ifdef ISSUE_1867_replace_overflow_libenc - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ //??sat //??sat + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ #else p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ #endif @@ -3826,7 +3826,7 @@ static void mdct_spectrum_fine_gain_enc_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); #ifdef ISSUE_1867_replace_overflow_libenc - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ #else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ #endif @@ -3994,7 +3994,7 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); #ifdef ISSUE_1867_replace_overflow_libenc - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ //??sat + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ #else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ #endif diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 189a85aec..027671004 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -121,7 +121,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits } #ifdef ISSUE_1867_replace_overflow_libenc - pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ #else pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif @@ -153,7 +153,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc - noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ //??sat + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #endif @@ -308,7 +308,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits } #ifdef ISSUE_1867_replace_overflow_libenc - pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ //??sat + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ #else pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index d2455a2af..ae1aac153 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -221,8 +221,8 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< } #ifdef ISSUE_1867_replace_overflow_libenc - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); //??sat - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); //??sat //??sat + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); #else BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyTileR[sfb], &Overflow ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyC[sfb], &Overflow ), sfbEnergyC_exp[sfb], round_fx_o( sfbEnergyTileC[sfb], &Overflow ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); @@ -255,7 +255,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - gain = round_fx_sat( L_shl( L_tmp, shift ) ); //??sat + gain = round_fx_sat( L_shl( L_tmp, shift ) ); #else gain = round_fx_o( L_shl_o( L_tmp, shift, &Overflow ), &Overflow ); #endif @@ -454,8 +454,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou /* negate because the negated may be 1 larger in abs, */ /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */ #ifdef ISSUE_1867_replace_overflow_libenc - highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); //??sat - L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); //??sat + highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); + L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); #else highPassEner_Ovfl = L_shl_o( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ), &Overflow ); L_tmp = L_add_o( pPowerSpectrum[i - 1], highPassEner_Ovfl, &Overflow ); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 773985f02..f146d03e5 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -1244,7 +1244,7 @@ Word16 ivas_acelp_tcx20_switching_fx( if ( ( GT_32( snr_acelp, tcx_snr ) ) && ( LT_32( snr_acelp, L_add( tcx_snr, 131072 /*2.0f Q16*/ ) ) ) && #ifdef ISSUE_1867_replace_overflow_libenc - ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || //??sat + ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || #else ( LT_32( L_add_o( st->prevTempFlatness_32fx, currFlatness, &Overflow ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || #endif diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index cf4c31982..9e0e6408a 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -787,7 +787,7 @@ static Word16 qlsf_Mode_Select_fx( pred_pow2[i] = shl( pred1[i], cs ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ //??sat //??sat + En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ #else En = L_mac_o( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i], &Overflow ); /* 2.56*2.56 at Q-4 */ #endif @@ -2001,7 +2001,7 @@ static void first_VQstages( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif @@ -2197,7 +2197,7 @@ static void first_VQstages_ivas_fx( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif @@ -3411,7 +3411,7 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( yy_fx[i] = shl( yy_fx[i], cs ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); //??sat //??sat + temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); #else temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i], &Overflow ); #endif @@ -3443,7 +3443,7 @@ static void FFT_Mid_Interpol_16k_fx( { /* Interpolation */ #ifdef ISSUE_1867_replace_overflow_libenc - Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); //??sat + Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); #else Bin_Ener_mid[i] = L_shr( L_add_o( Bin_Ener_old[i], Bin_Ener[i], &Overflow ), 1 ); #endif @@ -3628,8 +3628,8 @@ static void lsf_mid_enc_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat( tmp, tmp ); //??sat - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat + tmp = mult_r_sat( tmp, tmp ); + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); #else tmp = mult_ro( tmp, tmp, &Overflow ); err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); @@ -3821,8 +3821,8 @@ static void lsf_mid_enc_ivas_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat( tmp, tmp ); //??sat - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); //??sat //??sat + tmp = mult_r_sat( tmp, tmp ); + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); #else tmp = mult_ro( tmp, tmp, &Overflow ); err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 9c00bd44b..229bd9958 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1634,14 +1634,14 @@ void midlsf_enc_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat( tmp, tmp ); //??sat + tmp = mult_r_sat( tmp, tmp ); #else tmp = mult_ro( tmp, tmp, &Overflow ); #endif err = L_mac( err, tmp, wghts[j] ); } #ifdef ISSUE_1867_replace_overflow_libenc - err = L_shl_sat( err, 2 ); //??sat + err = L_shl_sat( err, 2 ); #else err = L_shl_o( err, 2, &Overflow ); #endif diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index e9e130ca1..5560fe29d 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -359,7 +359,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) //??sat + IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) #else IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) #endif @@ -457,7 +457,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) #else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) #endif @@ -1006,7 +1006,7 @@ Word16 mdct_classifier_ivas_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) //??sat //??sat + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) #else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) #endif diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 81a788c05..f0152a93b 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -215,7 +215,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity { /* include the last peak point (new minimum) to the corr. sum */ #ifdef ISSUE_1867_replace_overflow_libenc - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); #else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); #endif @@ -270,9 +270,9 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity k++; } #ifdef ISSUE_1867_replace_overflow_libenc - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); #else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); @@ -564,7 +564,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni { /* include the last peak point (new minimum) to the corr. sum */ #ifdef ISSUE_1867_replace_overflow_libenc - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); #else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); #endif @@ -619,9 +619,9 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni k++; } #ifdef ISSUE_1867_replace_overflow_libenc - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); //??sat - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); //??sat - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); //??sat + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); #else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 2d4ea5cd0..bc775783c 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -425,7 +425,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ #else E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif @@ -445,7 +445,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ #else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ #endif @@ -465,7 +465,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ #else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ #endif @@ -485,7 +485,7 @@ void nelp_encoder_fx( FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif @@ -513,7 +513,7 @@ void nelp_encoder_fx( FOR( j = (Word16) ( i * lag ); j < L_FRAME; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif @@ -1194,7 +1194,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ //??sat + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ #else E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif @@ -1213,7 +1213,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ //??sat + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ #else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ #endif @@ -1233,7 +1233,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ //??sat + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ #else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ #endif @@ -1252,7 +1252,7 @@ void nelp_encoder_ivas_fx( FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif @@ -1280,7 +1280,7 @@ void nelp_encoder_ivas_fx( FOR( j = i_mult( i, lag ); j < L_FRAME; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ //??sat + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 2494bdb20..296bef2eb 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -110,7 +110,7 @@ static Word16 noise_est_ln_q8_fx( L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */ #else - L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ //??sat + L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ #endif if ( flag_add1p0 == 0 ) { @@ -688,7 +688,7 @@ void noise_est_down_fx( FOR( i = min_band; i <= max_band; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ //??sat + totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ #else totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ #endif @@ -716,7 +716,7 @@ void noise_est_down_fx( FOR( i = 0; i < NB_BANDS; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); //??sat + Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); #else Ltmp = L_add_o( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ), &Overflow ); #endif @@ -1118,8 +1118,8 @@ void noise_est_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat - wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); #else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); @@ -1177,7 +1177,7 @@ void noise_est_fx( { Lnum = L_max( *pt1, *pt2 ); /* Don't need if anymore */ #ifdef ISSUE_1867_replace_overflow_libenc - Lsum_den = L_add_sat( Lsum_den, Lnum ); //??sat + Lsum_den = L_add_sat( Lsum_den, Lnum ); #else Lsum_den = L_add_o( Lsum_den, Lnum, &Overflow ); #endif @@ -1297,7 +1297,7 @@ void noise_est_fx( Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ #ifdef ISSUE_1867_replace_overflow_libenc - alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ #else alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif @@ -1337,8 +1337,8 @@ void noise_est_fx( tmp_Q = add( Q_new, Q_SCALE ); Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ //??sat - L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat + L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ + L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ #else L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ @@ -1384,7 +1384,7 @@ void noise_est_fx( Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ //??sat + L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ #else L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif @@ -1420,7 +1420,7 @@ void noise_est_fx( log_enr16 = noise_est_ln_q8_fx( enr[i], 0, tmp_Q ); wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); #ifdef ISSUE_1867_replace_overflow_libenc - *non_staX = add_sat( *non_staX, wtmp ); //??sat + *non_staX = add_sat( *non_staX, wtmp ); #else *non_staX = add_o( *non_staX, wtmp, &Overflow ); #endif @@ -1440,7 +1440,7 @@ void noise_est_fx( move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( hNoiseEst->bckr_fx[i], 1, tmp_Q ); #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif @@ -1453,7 +1453,7 @@ void noise_est_fx( move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( E_MIN_FX, 1, tmp_Q ); #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif @@ -1570,7 +1570,7 @@ void noise_est_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); - /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ //??sat //??sat + /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #else epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #endif @@ -1740,7 +1740,7 @@ void noise_est_fx( Ltmp = L_mult( st_fx->voicing_fx[0], 16384 ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 ); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); //??sat + cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); #else cor_tmp = mac_ro( Ltmp, corr_shift, MAX_16, &Overflow ); #endif @@ -2468,8 +2468,8 @@ void noise_est_ivas_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); //??sat - wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); //??sat + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); #else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); @@ -2686,7 +2686,7 @@ void noise_est_ivas_fx( /* alpha = 0.064f * ftemp + 0.75f; */ Ltmp = Madd_32_16( 12582912 /* 0.75 in Q24*/, 137438953, tmp ); // Q24 #ifdef ISSUE_1867_replace_overflow_libenc - alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ //??sat //??sat + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ #else alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif @@ -2843,7 +2843,7 @@ void noise_est_ivas_fx( IF( LT_16( ini_frame, 100 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ), &Overflow ); /* Q8 */ #endif @@ -2869,7 +2869,7 @@ void noise_est_ivas_fx( tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ } #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ //??sat + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif diff --git a/lib_enc/normalizecoefs_fx.c b/lib_enc/normalizecoefs_fx.c index 4e9783f67..3e2181cf3 100644 --- a/lib_enc/normalizecoefs_fx.c +++ b/lib_enc/normalizecoefs_fx.c @@ -58,7 +58,7 @@ void normalizecoefs_fx( move32(); } #ifdef ISSUE_1867_replace_overflow_libenc - *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ //??sat //??sat + *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ #else *pcoefs16++ = round_fx_o( L_shl_o( *pcoefs++, 16 - k, &Overflow ), &Overflow ); /* Q12 */ #endif diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index f49abac12..74712802c 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -992,7 +992,7 @@ void norm_corr_ivas_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); // (Q_new - 1) + (Q_new - h_e) + 1 //??sat + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); // (Q_new - 1) + (Q_new - h_e) + 1 #else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); // (Q_new - 1) + (Q_new - h_e) + 1 #endif @@ -1083,14 +1083,14 @@ void norm_corr_fx( /* Compute rounded down 1/sqrt(energy of xn[]) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( 1, xn[0], xn[0] ); //??sat + L_tmp = L_mac_sat( 1, xn[0], xn[0] ); #else L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); #endif FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); //??sat + L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); #else L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); #endif @@ -1113,7 +1113,7 @@ void norm_corr_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); //??sat + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); #else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); #endif @@ -1128,7 +1128,7 @@ void norm_corr_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); //??sat + L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); #else L_tmp = L_mac_o( L_tmp, excf[i], excf[i], &Overflow ); #endif diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 2e30ff54b..bf363009f 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -85,8 +85,8 @@ void pitch_ol2_fx( FOR( t = t_min; t <= t_max; t++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - t0 = L_shl_sat( *pt_cor_32++, exp3 ); //??sat - *pt_cor_fx++ = round_fx_sat( t0 ); //??sat + t0 = L_shl_sat( *pt_cor_32++, exp3 ); + *pt_cor_fx++ = round_fx_sat( t0 ); #else t0 = L_shl_o( *pt_cor_32++, exp3, &Overflow ); *pt_cor_fx++ = round_fx_o( t0, &Overflow ); @@ -197,7 +197,7 @@ void pitch_ol2_fx( R2 = L_shl( R2, exp_R2 ); #ifdef ISSUE_1867_replace_overflow_libenc - R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); //??sat //??sat //??sat + R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); #else R1 = L_mult_o( round_fx_o( R1, &Overflow ), round_fx_o( R2, &Overflow ), &Overflow ); #endif @@ -211,7 +211,7 @@ void pitch_ol2_fx( R1 = Isqrt_lc( R1, &exp_R1 ); #ifdef ISSUE_1867_replace_overflow_libenc - R1 = L_mult( R0, round_fx_sat( R1 ) ); //??sat + R1 = L_mult( R0, round_fx_sat( R1 ) ); #else R1 = L_mult( R0, round_fx_o( R1, &Overflow ) ); #endif @@ -219,7 +219,7 @@ void pitch_ol2_fx( exp_R0 = sub( add( exp_R0, exp_R1 ), exp3 ); #ifdef ISSUE_1867_replace_overflow_libenc - *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ //??sat //??sat + *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ #else *voicing_fr_fx = round_fx_o( L_shl_o( R1, exp_R0, &Overflow ), &Overflow ); /*Q15*/ #endif @@ -318,7 +318,7 @@ void StableHighPitchDetect_fx( diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -331,7 +331,7 @@ void StableHighPitchDetect_fx( diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -341,7 +341,7 @@ void StableHighPitchDetect_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); #else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); #endif @@ -422,7 +422,7 @@ void StableHighPitchDetect_fx( cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; #ifdef ISSUE_1867_replace_overflow_libenc - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ #else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ #endif @@ -553,7 +553,7 @@ void StableHighPitchDetect_ivas_fx( diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -566,7 +566,7 @@ void StableHighPitchDetect_ivas_fx( diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); //??sat + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -576,7 +576,7 @@ void StableHighPitchDetect_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); //??sat //??sat + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); #else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); #endif @@ -666,7 +666,7 @@ void StableHighPitchDetect_ivas_fx( cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); #ifdef ISSUE_1867_replace_overflow_libenc - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ //??sat //??sat + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ #else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ #endif diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 78f59ac14..a73cdc19a 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -740,7 +740,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); //??sat + enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); #else enr1 = add_o( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1, &Overflow ); #endif @@ -780,7 +780,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); //??sat + enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); #else enr1 = add_o( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1, &Overflow ); #endif @@ -879,7 +879,7 @@ void pitch_ol_fx( pitch_tmp[i] = pitchX[i][ind]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); #else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); #endif @@ -897,7 +897,7 @@ void pitch_ol_fx( pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); #else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); #endif @@ -1728,7 +1728,7 @@ void pitch_ol_ivas_fx( Ltmp = Mpy_32_16_1( enr1, cor_buf[ind] ); #ifdef ISSUE_1867_replace_overflow_libenc - corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 //??sat + corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 #else corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 @@ -1776,7 +1776,7 @@ void pitch_ol_ivas_fx( Ltmp = Mpy_32_16_1( enr1, cor_buf[ind1 + len_x] ); #ifdef ISSUE_1867_replace_overflow_libenc - corX[i][j + NSECT] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ) ) ); // Q15 //??sat + corX[i][j + NSECT] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ) ) ); // Q15 #else corX[i][j + NSECT] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ), &Overflow ) ); // Q15 #endif @@ -1857,7 +1857,7 @@ void pitch_ol_ivas_fx( pitch_tmp[i] = pitchX[i][ind]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); //??sat + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); #else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); #endif @@ -1875,7 +1875,7 @@ void pitch_ol_ivas_fx( pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); //??sat + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); #else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); #endif diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index a662ee328..6ab85d45e 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -666,9 +666,9 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat - corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat - temp = add_sat( temp, temp1 ); //??sat + corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); + corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); + temp = add_sat( temp, temp1 ); #else corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); @@ -684,8 +684,8 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X } #ifdef ISSUE_1867_replace_overflow_libenc - temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat - wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat + temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ + wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #else temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ @@ -694,7 +694,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X IF( GE_16( Qmaxcorr, Qcorr ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ //??sat //??sat + diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ #else diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ #endif @@ -702,7 +702,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ //??sat //??sat + diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ #else diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ #endif @@ -713,7 +713,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X fshift_fx = n; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat + maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ #else maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif @@ -801,9 +801,9 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc - Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ //??sat - Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat - Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat + Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ + Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ + Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ #else Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ @@ -831,8 +831,8 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc - Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat - Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat + Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ + Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ #else Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ @@ -852,7 +852,7 @@ static void LPCPowSpect_fx( Lacc = L_mult0( dh, dl ); #ifdef ISSUE_1867_replace_overflow_libenc - Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat + Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ #else Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif @@ -887,7 +887,7 @@ static void LPCPowSpect_fx( } Ltemp = L_deposit_h( tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); //??sat //??sat + out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); #else out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); #endif diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index f055bbd89..85fff0ef4 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -88,8 +88,8 @@ static Word16 one_pulse_search( FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ //??sat //??sat - corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ //??sat + L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ + corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ #else L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ @@ -369,8 +369,8 @@ void pvq_encode_ivas_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat - xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ #else L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ @@ -584,8 +584,8 @@ void pvq_encode_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat - xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ #else L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ diff --git a/lib_enc/q_gain2p_fx.c b/lib_enc/q_gain2p_fx.c index ae1530e73..d87ca122b 100644 --- a/lib_enc/q_gain2p_fx.c +++ b/lib_enc/q_gain2p_fx.c @@ -168,7 +168,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ //??sat //??sat + *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ #else *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ #endif @@ -384,7 +384,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat + L_tmp1 = L_sub_sat( L_tmp, dist_min ); #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -408,7 +408,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ //??sat + L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ #else L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ #endif @@ -418,7 +418,7 @@ static Word16 gain_enc( /* o : quantization pitch index /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); #ifdef ISSUE_1867_replace_overflow_libenc - *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); //??sat + *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); #else *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); #endif @@ -616,7 +616,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif @@ -633,7 +633,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 36d33e996..96fe6a924 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -444,7 +444,7 @@ void Unified_weighting_fx( FOR( i = 95; i < 127; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ //??sat + L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ #else L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ #endif @@ -529,7 +529,7 @@ void Unified_weighting_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ //??sat //??sat + L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ #else L_tmp = L_shl_o( L_deposit_l( sub_o( w_fft_fx[i], min_fx, &Overflow ) ), 13, &Overflow ); /* Q21 */ #endif diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 13a5bda09..6337a7f5e 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -123,7 +123,7 @@ void Preemph_scaled( * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); #else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); #endif @@ -177,7 +177,7 @@ void Preemph_scaled( { L_tmp = L_mult( new_speech[i], QVal ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); //??sat + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); #else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); #endif @@ -247,12 +247,12 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled FOR( i = 0; i < NB_BANDS; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); //??sat - bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); //??sat - ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); //??sat - ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); //??sat - st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); //??sat - st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); //??sat + enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); + bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); + ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); + ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); + st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); + st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); #else enrO[i] = L_max( L_shl_o( enrO[i], Q_exp, &Overflow ), e_min_scaled ); bckr[i] = L_max( L_shl_o( bckr[i], Q_exp, &Overflow ), e_min_scaled ); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index ba62825f8..e5dc9579a 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -122,8 +122,8 @@ void set_impulse_fx( FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 //??sat - Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 //??sat + Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 + Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 #else Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 @@ -132,7 +132,7 @@ void set_impulse_fx( rr_fx[start1] = Lrr; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - dd_fx[start1] = round_fx_sat( Ldd ); // Q11 //??sat + dd_fx[start1] = round_fx_sat( Ldd ); // Q11 #else dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 #endif @@ -150,8 +150,8 @@ void set_impulse_fx( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); #ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 //??sat - Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 //??sat + Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 + Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 #else Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 @@ -161,8 +161,8 @@ void set_impulse_fx( gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); #ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 //??sat - Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 //??sat + Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 + Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 #else Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 @@ -201,7 +201,7 @@ void set_impulse_fx( { /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ #ifdef ISSUE_1867_replace_overflow_libenc - rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 //??sat + rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 #else rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 #endif diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index d8cc74e56..8f660240b 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -797,14 +797,14 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sum_PS = L_add_sat( sum_PS, PS[i] ); //??sat + sum_PS = L_add_sat( sum_PS, PS[i] ); #else sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); #endif } exp1 = norm_l( sum_PS ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); //??sat + tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); #else tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); #endif @@ -816,7 +816,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); //??sat + tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); #else tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); #endif @@ -881,7 +881,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { exp1 = norm_l( L_add( dPS[i], 336 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); //??sat //??sat + tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); #else tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); #endif @@ -942,7 +942,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /**pFV = pSF[0] * *pFV + pSF[1];*/ #ifdef ISSUE_1867_replace_overflow_libenc - *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); //??sat //??sat + *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); #else *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); #endif @@ -977,7 +977,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); //??sat + xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); #else xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -997,7 +997,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); //??sat + xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); #else xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -1016,7 +1016,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); //??sat + xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); #else xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -1034,7 +1034,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ #ifdef ISSUE_1867_replace_overflow_libenc - lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat + lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ #else lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif @@ -1046,7 +1046,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ #ifdef ISSUE_1867_replace_overflow_libenc - lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ //??sat + lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ #else lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif @@ -1524,7 +1524,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ #else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ #endif @@ -1553,7 +1553,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( i = 1; i < att_3lsub_pos; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ //??sat //??sat + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ #else L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #endif @@ -1569,7 +1569,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( i = 1; i < tmp1; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ //??sat //??sat + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ #else L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #endif @@ -2694,7 +2694,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ //??sat + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ #else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ #endif diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index ff3161ffb..5cf653f62 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -411,7 +411,7 @@ void swb_bwe_enc_ivas_fx( /* tilt returned in Q24 goto to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); #else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); #endif @@ -550,7 +550,7 @@ void swb_bwe_enc_ivas_fx( exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ #else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -696,7 +696,7 @@ void swb_bwe_enc_fx( /* tilt returned in Q24 goto to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); //??sat //??sat + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); #else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); #endif @@ -823,7 +823,7 @@ void swb_bwe_enc_fx( exp = add( 31 - 30, sub( exp, exp1 ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ //??sat //??sat + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ #else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -1069,7 +1069,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class IF( hBWE_FD->prev_global_gain_fx == 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ //??sat //??sat + gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ #else gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ #endif @@ -1190,7 +1190,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ //??sat //??sat + sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ #else sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ #endif @@ -1411,7 +1411,7 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ //??sat + dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ #else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ #endif @@ -1422,7 +1422,7 @@ static void vqWithCand_w_fx( FOR( j = 1; j < dim; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); //??sat + temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); #else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); #endif @@ -1746,7 +1746,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM11; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); //??sat + quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); #else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); #endif @@ -1756,7 +1756,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ //??sat + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ #else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ #endif @@ -1783,7 +1783,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); //??sat + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); #else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); #endif @@ -1909,13 +1909,13 @@ static void msvq_interpol_2_fx( FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); #else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); #endif tmp_q = shr( tmp_q, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); //??sat + quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); #else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); #endif @@ -1940,13 +1940,13 @@ static void msvq_interpol_2_fx( FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); //??sat + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); #else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); #endif tmp_q = shr( tmp_q, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc - quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); //??sat + quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); #else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); #endif @@ -2122,7 +2122,7 @@ static void calculate_Tonality_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2147,7 +2147,7 @@ static void calculate_Tonality_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2290,7 +2290,7 @@ static void calculate_Tonality_ivas_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2315,7 +2315,7 @@ static void calculate_Tonality_ivas_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ //??sat //??sat + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2754,7 +2754,7 @@ static Word16 SWB_BWE_encoding_fx( /* tilt returned in Q24 go to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); #else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); #endif @@ -2862,7 +2862,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ #endif @@ -2878,7 +2878,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -3231,7 +3231,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( /* tilt returned in Q24 go to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); //??sat //??sat + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); #else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); #endif @@ -3340,7 +3340,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expd = norm_l( WB_tenv_syn_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); //??sat + den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); #else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); #endif @@ -3357,7 +3357,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ #endif @@ -3372,7 +3372,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ //??sat //??sat + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index d7cebe322..54528e2b4 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -771,7 +771,7 @@ void swb_bwe_enc_hr_fx( L_tmp = L_mult( temp, t_audio_fx[i] ); L_tmp = L_shr_sat( L_tmp, temp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - t_audio_fx[i] = round_fx_sat( L_tmp ); //??sat + t_audio_fx[i] = round_fx_sat( L_tmp ); #else t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); #endif diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 2dedbfbeb..bdb956283 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -786,8 +786,8 @@ static void gethar_noisegn_fx( L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ //??sat - g_fx = round_fx_sat( L_temp ); //??sat + L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ + g_fx = round_fx_sat( L_temp ); #else L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 9c1ccba6f..b1561ba51 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1217,8 +1217,8 @@ void wb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat - tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); + tmp = round_fx_sat( L_tmp ); /* Q15 */ #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ @@ -1389,7 +1389,7 @@ void wb_tbe_enc_ivas_fx( { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); #ifdef ISSUE_1867_replace_overflow_libenc - hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); //??sat + hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); #else hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); #endif @@ -1881,8 +1881,8 @@ void wb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); //??sat - tmp = round_fx_sat( L_tmp ); /* Q15 */ //??sat + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); + tmp = round_fx_sat( L_tmp ); /* Q15 */ #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ @@ -2540,8 +2540,8 @@ void swb_tbe_enc_fx( FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ //??sat - curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ //??sat + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ + curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ #else prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ curr_pow_fx = L_mac0_o( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], &Overflow ); /* 2*Q_bwe_exc */ @@ -2581,7 +2581,7 @@ void swb_tbe_enc_fx( { tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -2589,7 +2589,7 @@ void swb_tbe_enc_fx( Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -2602,7 +2602,7 @@ void swb_tbe_enc_fx( { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -2610,7 +2610,7 @@ void swb_tbe_enc_fx( Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -2845,7 +2845,7 @@ void swb_tbe_enc_fx( L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ #else tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif @@ -3901,7 +3901,7 @@ void swb_tbe_enc_ivas_fx( { L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -3923,7 +3923,7 @@ void swb_tbe_enc_ivas_fx( { tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -3931,7 +3931,7 @@ void swb_tbe_enc_ivas_fx( L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -3944,7 +3944,7 @@ void swb_tbe_enc_ivas_fx( { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ //??sat + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -3952,7 +3952,7 @@ void swb_tbe_enc_ivas_fx( L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ //??sat //??sat + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -4465,7 +4465,7 @@ void swb_tbe_enc_ivas_fx( L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ //??sat //??sat + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ #else tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif @@ -4739,10 +4739,10 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ #else sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ @@ -4754,9 +4754,9 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ @@ -4768,10 +4768,10 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ #else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ @@ -4788,8 +4788,8 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -4798,8 +4798,8 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat + sig = shl_sat( oriSHB[i], scaling ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = shl_sat( oriSHB[i], scaling ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -4808,8 +4808,8 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -4965,10 +4965,10 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ #else sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ @@ -4980,9 +4980,9 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ #else oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ @@ -4994,10 +4994,10 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ //??sat - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ //??sat - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ //??sat + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ #else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ @@ -5014,8 +5014,8 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -5024,8 +5024,8 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat + sig = shl_sat( oriSHB[i], scaling ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = shl_sat( oriSHB[i], scaling ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -5034,8 +5034,8 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); //??sat - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ //??sat + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -5277,9 +5277,9 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ @@ -5291,9 +5291,9 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ @@ -5305,9 +5305,9 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ //??sat + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ @@ -5360,8 +5360,8 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ //??sat //??sat - L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ //??sat + subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ #else subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ @@ -5381,7 +5381,7 @@ static void EstimateSHBGainShape_fx( { L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ //??sat //??sat + subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ #else subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ #endif @@ -5394,7 +5394,7 @@ static void EstimateSHBGainShape_fx( { L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ //??sat //??sat + subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ #else subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ #endif @@ -7059,7 +7059,7 @@ static void first_VQstages_fx( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ //??sat + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif @@ -7593,7 +7593,7 @@ void fb_tbe_enc_fx( Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ //??sat //??sat + temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ #else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ #endif diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 7c5c0e620..64677b26c 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -525,7 +525,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra s2 = sub( s2, tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); #else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif @@ -535,7 +535,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra /* Quantize gain */ #ifdef ISSUE_1867_replace_overflow_libenc - g = shr( sub_sat( g, 0x1000 ), 13 ); //??sat + g = shr( sub_sat( g, 0x1000 ), 13 ); #else g = shr( sub_o( g, 0x1000, &Overflow ), 13 ); #endif @@ -586,7 +586,7 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec s2 = sub( s2, tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); //??sat //??sat + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); #else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif @@ -810,14 +810,14 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); //??sat //??sat //??sat + speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); #else speech_ltp[n] = sub_o( speech[n], mult_ro( *gain, mult_ro( alpha, pred_speech[n], &Overflow ), &Overflow ), &Overflow ); #endif move16(); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - alpha = add_sat( alpha, step ); //??sat + alpha = add_sat( alpha, step ); #else alpha = add_o( alpha, step, &Overflow ); #endif @@ -872,7 +872,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); //??sat //??sat //??sat + speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); #else speech_ltp[n] = add_o( sub_o( speech[n], mult_ro( *gain, pred_speech[n], &Overflow ), &Overflow ), zir[n], &Overflow ); #endif @@ -894,7 +894,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = L_subfr; n < L_frame; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); //??sat + speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); #else speech_ltp[n] = sub_o( speech[n], mult( *gain, pred_speech[n] ), &Overflow ); #endif @@ -1239,7 +1239,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); //??sat //??sat //??sat + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); #else speech_ltp_fx[n] = sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, mult_ro( alpha_fx, pred_speech_fx[n], &Overflow ), &Overflow ), &Overflow ); #endif @@ -1293,7 +1293,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); //??sat //??sat //??sat + speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); #else speech_ltp_fx[n] = add_o( sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, pred_speech_fx[n], &Overflow ), &Overflow ), zir_fx[n], &Overflow ); #endif @@ -1315,7 +1315,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = L_subfr; n < L_frame; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); //??sat + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); #else speech_ltp_fx[n] = sub_o( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ), &Overflow ); #endif diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 331dc9a91..adb3f8b7f 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -299,7 +299,7 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 move32(); BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ #ifdef ISSUE_1867_replace_overflow_libenc - threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); //??sat + threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); #else threshold = L_shl_o( threshold, sub( 28, powerSpec_e ), &Overflow ); #endif @@ -308,7 +308,7 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 { /* compensate for bad side-lobe attenuation with asymmetric windows */ #ifdef ISSUE_1867_replace_overflow_libenc - threshold = L_shl_sat( threshold, 1 ); //??sat + threshold = L_shl_sat( threshold, 1 ); #else threshold = L_shl_o( threshold, 1, &Overflow ); #endif @@ -2759,7 +2759,7 @@ void tcx_noise_factor_ivas_fx( s = add( add( exp_sqErrorNrg, -15 ), s ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp4 = L_shl_sat( tmp4, s ); //??sat + tmp4 = L_shl_sat( tmp4, s ); #else tmp4 = L_shl_o( tmp4, s, &Overflow ); #endif diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index 568f312f1..fc2a41a58 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -128,7 +128,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); #else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); #endif @@ -499,7 +499,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); //??sat + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); #else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); #endif diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 89509ba6a..ba92b3d13 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2218,7 +2218,7 @@ static void gain_trans_enc_fx( gscale = 7; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ //??sat + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ #else gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ #endif @@ -2226,7 +2226,7 @@ static void gain_trans_enc_fx( IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ //??sat + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ #else gain_trans = extract_h( L_shl_o( gain_trans32, 16 - 3, &Overflow ) ); /* Q4 */ #endif @@ -2263,7 +2263,7 @@ static void gain_trans_enc_fx( { /*exc[i] *= (*gain_trans);*/ #ifdef ISSUE_1867_replace_overflow_libenc - exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); //??sat //??sat + exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); #else exc[i] = round_fx_o( L_shl_o( L_mult( exc[i], gain_trans ), tmp16, &Overflow ), &Overflow ); #endif @@ -2373,7 +2373,7 @@ void tc_classif_enc_fx( FOR( i = 1; i < len; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_sum = L_mac0_sat( L_sum, res[i], res[i] ); //??sat + L_sum = L_mac0_sat( L_sum, res[i], res[i] ); #else L_sum = L_mac0_o( L_sum, res[i], res[i], &Overflow ); #endif @@ -2390,8 +2390,8 @@ void tc_classif_enc_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( GT_32( temp2, L_shl_sat( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && //??sat - LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) //??sat + IF( GT_32( temp2, L_shl_sat( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && + LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) #else IF( GT_32( temp2, L_shl_o( L_temp2, ( 31 - exp2 ) - ( 31 - exp ), &Overflow ) ) && LT_32( aver, L_shl_o( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ), &Overflow ) ) ) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index cd61ab598..951d3b840 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -223,7 +223,7 @@ static void sign_thr_snr_acc_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); - /* Q4 */ //??sat + /* Q4 */ #else *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif @@ -1053,7 +1053,7 @@ Word16 wb_vad_fx( IF( LT_16( i, 2 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta1 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta1 ); /*Q13 */ #else tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ #endif @@ -1061,7 +1061,7 @@ Word16 wb_vad_fx( ELSE IF( LT_16( i, 7 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta2 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta2 ); /*Q13 */ #else tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ #endif @@ -1069,7 +1069,7 @@ Word16 wb_vad_fx( ELSE IF( LT_16( i, 18 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta3 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta3 ); /*Q13 */ #else tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ #endif @@ -1077,7 +1077,7 @@ Word16 wb_vad_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta4 ); /*Q13 */ //??sat + tmp = add_sat( tmp, delta4 ); /*Q13 */ #else tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ #endif @@ -1089,7 +1089,7 @@ Word16 wb_vad_fx( if ( LT_16( i, 7 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ //??sat + tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #else tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #endif @@ -1177,7 +1177,7 @@ Word16 wb_vad_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ #else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif @@ -1185,7 +1185,7 @@ Word16 wb_vad_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ //??sat + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ #else L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif @@ -1283,7 +1283,7 @@ Word16 wb_vad_fx( } /*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ //??sat + hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ #else hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/ #endif @@ -1401,7 +1401,7 @@ Word16 wb_vad_fx( move16(); L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ //??sat + tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #else tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #endif @@ -2445,7 +2445,7 @@ Word16 wb_vad_ivas_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ //??sat + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ #else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif @@ -2453,7 +2453,7 @@ Word16 wb_vad_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ //??sat + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ #else L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ #endif @@ -2471,7 +2471,7 @@ Word16 wb_vad_ivas_fx( } } /* end of band loop */ #ifdef ISSUE_1867_replace_overflow_libenc - L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 //??sat + L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 #else L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 #endif diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index da724a781..f581c2244 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -168,8 +168,8 @@ void vad_param_updt_fx( L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ //??sat - voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ //??sat + L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ + voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ #else L_tmp = L_mac_o( L_tmp, corr_shift_temp[i], 32767, &Overflow ); /*Q15 */ voice_tmp = round_fx_o( L_tmp, &Overflow ); /*Q15 */ diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index cc3d04437..8989c782d 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -261,7 +261,7 @@ void update_average_rate_fx( /*st->sum_of_rates += (hSC_VBR->core_brate / 1000.0f) * 10; */ L_tmp = L_shl( Mult_32_16( core_brate_fx, 20972 ), 7 ); /*Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); //??sat + hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); #else hSC_VBR->sum_of_rates_fx = L_add_o( hSC_VBR->sum_of_rates_fx, L_tmp, &Overflow ); #endif diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index 18713437c..e480092a3 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -60,7 +60,7 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits FOR( i = 1; i < M; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ //??sat + L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ #else L_tmp = L_mac_o( L_tmp, x[i], x[i], &Overflow ); /*10Q21*/ #endif diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 4be3eb939..7206ae674 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -566,7 +566,7 @@ ivas_error ppp_voiced_encoder_fx( /* 5 in Q11, 0.65 in Q15 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q31 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) //??sat + if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) #else if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 31, Qtmp ), &Overflow ) ), 21299 ) ) ) #endif @@ -581,7 +581,7 @@ ivas_error ppp_voiced_encoder_fx( /*3 in Q11, 1.2 in Q14 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q14 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) //??sat + if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) #else if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 30, Qtmp ), &Overflow ) ), 19661 ) ) ) #endif @@ -600,7 +600,7 @@ ivas_error ppp_voiced_encoder_fx( /* if (res_enratio < 0.025) */ #ifdef ISSUE_1867_replace_overflow_libenc IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) - /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat + /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #else IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif @@ -620,7 +620,7 @@ ivas_error ppp_voiced_encoder_fx( { /* if ( res_enratio < 0.092f) */ #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ //??sat + if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #else if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif @@ -633,7 +633,7 @@ ivas_error ppp_voiced_encoder_fx( /* if (min(res_enratio, sp_enratio) < 0.075 && tmp < -0.5f)) : 2458 = 0.075 in Q15 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) //??sat + if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) #else if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) @@ -774,7 +774,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); //??sat + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); #else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); #endif @@ -802,7 +802,7 @@ ivas_error ppp_voiced_encoder_fx( Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_NQ_FX->Q, 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ //??sat + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #endif @@ -911,7 +911,7 @@ ivas_error ppp_voiced_encoder_fx( FOR( x_fx = 0; x_fx < 160; x_fx++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); //??sat + energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); #else energy_impz_fx = L_add_o( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ), &Overflow ); #endif @@ -929,7 +929,7 @@ ivas_error ppp_voiced_encoder_fx( move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_Q_E_FX->Q, 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ //??sat + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ #else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ #endif @@ -997,7 +997,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); /* tmp in Q15 */ exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ //??sat + Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ #else Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ #endif @@ -1037,7 +1037,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ //??sat + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ #else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ #endif @@ -1109,7 +1109,7 @@ ivas_error ppp_voiced_encoder_fx( frac = Log2_norm_lc( L_tmp ); L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ //??sat + Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ #else Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ #endif @@ -1310,7 +1310,7 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ { /* acc = L_sub(acc, L_mult(memory[j], coef[j])); */ #ifdef ISSUE_1867_replace_overflow_libenc - acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ //??sat + acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ #else acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ #endif @@ -1319,10 +1319,10 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ } /* acc = L_sub(acc, L_mult(memory[0], coef[0])); */ #ifdef ISSUE_1867_replace_overflow_libenc - acc = L_msu_sat( acc, buf[0], b[0] ); //??sat - acc = L_shl_sat( acc, 3 ); //??sat - *y++ = round_fx_sat( acc ); //??sat - buf[0] = round_fx_sat( acc ); //??sat + acc = L_msu_sat( acc, buf[0], b[0] ); + acc = L_shl_sat( acc, 3 ); + *y++ = round_fx_sat( acc ); + buf[0] = round_fx_sat( acc ); #else acc = L_msu_o( acc, buf[0], b[0], &Overflow ); acc = L_shl_o( acc, 3, &Overflow ); @@ -1416,8 +1416,8 @@ static Word32 DTFS_freq_corr_fx( FOR( k = lk; k < hk; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ //??sat - corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ //??sat + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ #else corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ); /* Q(1) */ corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ); /* Q(1) */ @@ -1432,7 +1432,7 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ //??sat //??sat + E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ #else E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ #endif @@ -1450,7 +1450,7 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ //??sat //??sat + E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ #else E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ #endif @@ -1464,7 +1464,7 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ //??sat //??sat + E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ #else E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ #endif @@ -1485,7 +1485,7 @@ static Word32 DTFS_freq_corr_fx( expa = norm_l( Num ); #ifdef ISSUE_1867_replace_overflow_libenc - fraca = extract_h( L_shl_sat( Num, expa ) ); //??sat + fraca = extract_h( L_shl_sat( Num, expa ) ); #else fraca = extract_h( L_shl_o( Num, expa, &Overflow ) ); #endif @@ -1494,7 +1494,7 @@ static Word32 DTFS_freq_corr_fx( expb = norm_l( Den ); #ifdef ISSUE_1867_replace_overflow_libenc - fracb = round_fx_sat( L_shl( Den, expb ) ); //??sat + fracb = round_fx_sat( L_shl( Den, expb ) ); #else fracb = round_fx_o( L_shl_o( Den, expb, &Overflow ), &Overflow ); #endif @@ -1563,7 +1563,7 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) FOR( k = 0; k < lag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); //??sat + corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); #else corr = L_mac_o( corr, x1[k], x2[( k - j + lag ) % lag], &Overflow ); #endif @@ -1643,8 +1643,8 @@ static Word32 DTFS_getEngy_band_fx( FOR( k = lk; k < hk; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ //??sat - en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); #else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); /* 2*X1.Q+1 */ en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); @@ -1661,8 +1661,8 @@ static Word32 DTFS_getEngy_band_fx( IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && ( hband == X_fx.upper_cut_off_freq_fx ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); //??sat - en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); //??sat + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); #else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); -- GitLab From 196ac34f6b11402db3c9d50926bd7358526fe04b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 13:19:21 +0200 Subject: [PATCH 78/80] fix warning --- lib_enc/speech_music_classif_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 8f660240b..9f71a8a66 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -3738,9 +3738,11 @@ static void spec_analysis_fx( Word16 peak_idx[65]; Word16 valey_idx[65]; Word16 p2v[65]; +#ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* find spectral peaks */ -- GitLab From 403b817cfdf7b0918da8ebe9259bfed2ff7e16c2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 28 Aug 2025 13:39:38 +0200 Subject: [PATCH 79/80] clang patch --- lib_com/stat_noise_uv_mod_fx.c | 4 +- lib_enc/acelp_core_switch_enc_fx.c | 4 +- lib_enc/acelp_enc_util_fx.c | 4 +- lib_enc/analy_sp_fx.c | 2 +- lib_enc/ari_hm_enc_fx.c | 2 +- lib_enc/arith_coder_enc_fx.c | 2 +- lib_enc/avq_cod_fx.c | 2 +- lib_enc/bass_psfilter_enc_fx.c | 24 +++--- lib_enc/bw_detect_fx.c | 6 +- lib_enc/cng_enc_fx.c | 30 +++---- lib_enc/cod2t32_fx.c | 18 ++-- lib_enc/cod_ace_fx.c | 6 +- lib_enc/core_enc_ol_fx.c | 20 ++--- lib_enc/corr_xh_fx.c | 16 ++-- lib_enc/detect_transient_fx.c | 26 +++--- lib_enc/dtx_fx.c | 14 +-- lib_enc/enc_acelp_fx.c | 50 +++++------ lib_enc/enc_acelpx_fx.c | 14 +-- lib_enc/enc_amr_wb_fx.c | 10 +-- lib_enc/enc_gen_voic_fx.c | 50 +++++------ lib_enc/enc_gen_voic_rf_fx.c | 28 +++--- lib_enc/enc_higher_acelp_fx.c | 8 +- lib_enc/enc_pit_exc_fx.c | 38 ++++----- lib_enc/enc_tran_fx.c | 40 ++++----- lib_enc/energy_fx.c | 2 +- lib_enc/find_tar_fx.c | 10 +-- lib_enc/find_tilt_fx.c | 24 +++--- lib_enc/find_uv_fx.c | 38 ++++----- lib_enc/gain_enc_fx.c | 26 +++--- lib_enc/gaus_enc_fx.c | 8 +- lib_enc/gp_clip_fx.c | 6 +- lib_enc/gs_enc_fx.c | 4 +- lib_enc/guided_plc_enc_fx.c | 6 +- lib_enc/hf_cod_amrwb_fx.c | 4 +- lib_enc/hq_classifier_enc_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 50 +++++------ lib_enc/hvq_enc_fx.c | 6 +- lib_enc/igf_enc_fx.c | 10 +-- lib_enc/ivas_tcx_core_enc_fx.c | 2 +- lib_enc/lsf_enc_fx.c | 18 ++-- lib_enc/lsf_msvq_ma_enc_fx.c | 4 +- lib_enc/mdct_classifier_fx.c | 6 +- lib_enc/multi_harm_fx.c | 16 ++-- lib_enc/nelp_enc_fx.c | 20 ++--- lib_enc/nois_est_fx.c | 42 ++++----- lib_enc/normalizecoefs_fx.c | 2 +- lib_enc/pit_enc_fx.c | 10 +-- lib_enc/pitch_ol2_fx.c | 26 +++--- lib_enc/pitch_ol_fx.c | 16 ++-- lib_enc/ppp_enc_fx.c | 30 +++---- lib_enc/pvq_encode_fx.c | 12 +-- lib_enc/q_gain2p_fx.c | 12 +-- lib_enc/qlpc_stoch_fx.c | 4 +- lib_enc/scale_enc_fx.c | 16 ++-- lib_enc/set_impulse_fx.c | 16 ++-- lib_enc/speech_music_classif_fx.c | 28 +++--- lib_enc/swb_bwe_enc_fx.c | 52 ++++++------ lib_enc/swb_bwe_enc_hr_fx.c | 2 +- lib_enc/swb_bwe_enc_lr_fx.c | 4 +- lib_enc/swb_tbe_enc_fx.c | 132 ++++++++++++++--------------- lib_enc/tcx_ltp_enc_fx.c | 20 ++--- lib_enc/tcx_utils_enc_fx.c | 6 +- lib_enc/tns_base_enc_fx.c | 4 +- lib_enc/transition_enc_fx.c | 12 +-- lib_enc/vad_fx.c | 26 +++--- lib_enc/vad_param_updt_fx.c | 4 +- lib_enc/vbr_average_rate_fx.c | 2 +- lib_enc/vlpc_2st_cod_fx.c | 2 +- lib_enc/voiced_enc_fx.c | 58 ++++++------- 69 files changed, 610 insertions(+), 610 deletions(-) diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index bd67e400f..9b0bae1e5 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -168,7 +168,7 @@ void stat_noise_uv_mod_fx( { exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ #ifdef ISSUE_1836_replace_overflow_libcom - exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ + exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ #else exctilt = mult( shl_o( sub( TILT_COMP_LIM_FX, min_alpha ), 2, &Overflow ), exctilt ); /*Q15 */ #endif @@ -197,7 +197,7 @@ void stat_noise_uv_mod_fx( tmp_den = shl( tmp_den, tmp_shift ); tmp_res = div_s( tmp_nom, tmp_den ); #ifdef ISSUE_1836_replace_overflow_libcom - tmp_res = shl_sat( tmp_res, tmp_shift ); + tmp_res = shl_sat( tmp_res, tmp_shift ); #else tmp_res = shl_o( tmp_res, tmp_shift, &Overflow ); #endif diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 75f4d08b6..dac68df1e 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -848,7 +848,7 @@ static void bwe_switch_enc_fx( q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ #else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ #endif @@ -997,7 +997,7 @@ static void bwe_switch_enc_ivas_fx( q_tmp2 = sub( q_tmp1, q_tmp2 ); /*30-q_tmp2 */ L_tmp1 = L_shl( L_tmp1, sub( q_tmp2, 24 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ + gain_fx = round_fx_sat( Isqrt( L_tmp1 ) ); /*Q12 */ #else gain_fx = round_fx_o( Isqrt( L_tmp1 ), &Overflow ); /*Q12 */ #endif diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 65a54ac2d..ad8e7e6cd 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -178,7 +178,7 @@ void E_ACELP_conv( } 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 */ + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Q0 */ #else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0 */ #endif @@ -210,7 +210,7 @@ void E_ACELP_conv_ivas_fx( } 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*/ + cn2[k] = round_fx_sat( L_shl_sat( L_tmp, 5 ) ); /* Qnew*/ #else cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/ #endif diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 00199070a..666d7865c 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -952,7 +952,7 @@ static void find_enr( /* normalization - corresponds to FFT normalization by 2/L_FFT */ BASOP_SATURATE_WARNING_OFF_EVS; /* saturation seems to have no effect (tested by simulation) */ #ifdef ISSUE_1867_replace_overflow_libenc - *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ + *ptE = L_shl_sat( Ltmp, diff_scaleM2 ); /* Q_new + QSCALE - 2 */ #else *ptE = L_shl_o( Ltmp, diff_scaleM2, &Overflow ); /* Q_new + QSCALE - 2 */ #endif diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 8bee83310..4beac647d 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -460,7 +460,7 @@ Word16 SearchPeriodicityIndex_fx( tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp3 = div_s( round_fx_sat( L_shl( tmp32, tmp ) ), round_fx_sat( L_shl( AbsTotal, tmp2 ) ) ); + 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 ) ); #endif diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 9013c5c41..a9955e6f6 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -75,7 +75,7 @@ static Word16 tcx_arith_estimate_scale( } #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r( round_fx_sat( L_shl( abs_spectrum[k], s1 ) ), envelope[k] ); + 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] ); #endif diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 7436076a2..8433e77ab 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -54,7 +54,7 @@ void AVQ_cod_fx( /* o: comfort noise gain factor 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] ); + 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 ); #endif diff --git a/lib_enc/bass_psfilter_enc_fx.c b/lib_enc/bass_psfilter_enc_fx.c index 2227e4c83..7a056dd13 100644 --- a/lib_enc/bass_psfilter_enc_fx.c +++ b/lib_enc/bass_psfilter_enc_fx.c @@ -156,14 +156,14 @@ Word16 bass_pf_enc_fx( { 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 */ + 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 */ + 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 */ + 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 ); tmp16 = mac_ro( tmp32, gain, syn[i + i_subfr], &Overflow ); /* Q0 */ @@ -183,13 +183,13 @@ Word16 bass_pf_enc_fx( { 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 ); + 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 */ + 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 */ + 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 */ tmp16 = round_fx_o( tmp32, &Overflow ); @@ -260,7 +260,7 @@ Word16 bass_pf_enc_fx( 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*/ + 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*/ #endif @@ -278,7 +278,7 @@ Word16 bass_pf_enc_fx( move16(); #ifdef ISSUE_1867_replace_overflow_libenc - error_in[i] = sub_sat( orig[i + i_subfr], syn[i + i_subfr] ); /*Q0*/ + 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*/ #endif diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index ae27e5724..6ec7c626b 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -131,7 +131,7 @@ void bw_detect_fx( } 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 */ + 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 */ #endif @@ -304,7 +304,7 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - spect[i] = round_fx_sat( L_shr_sat( spect32[i], Q_dct ) ); + 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 @@ -346,7 +346,7 @@ void bw_detect_fx( FOR( j = 0; j < bin_width; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); + sum32 = L_mac0_sat( sum32, *pt1, *pt1 ); #else sum32 = L_mac0_o( sum32, *pt1, *pt1, &Overflow ); #endif diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index dbd48cfe7..37770ce9e 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -638,7 +638,7 @@ void CNG_enc_fx( { dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - dist = add_sat( dist, dev ); /*Q15 */ + dist = add_sat( dist, dev ); /*Q15 */ #else dist = add_o( dist, dev, &Overflow ); /*Q15 */ #endif @@ -772,9 +772,9 @@ void CNG_enc_fx( { /* 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 */ + 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_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ @@ -1059,7 +1059,7 @@ void CNG_enc_fx( L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ #else L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ #endif @@ -1958,9 +1958,9 @@ void CNG_enc_ivas_fx( { /* 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 */ + 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_add_o( L_tmp, L_mult_o( *ptI, *ptI, &Overflow ), &Overflow ); /* 2*Q_new+1 */ @@ -2269,7 +2269,7 @@ void CNG_enc_ivas_fx( L_tmp = L_shl( L_tmp, exp ); /*Q(exp+6)*/ tmp1 = extract_h( L_tmp ); /*Q(exp+6-16)=exp-10*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ + L_tmp = L_mult_sat( tmp1, tmp1 ); /*Q(2*exp - 19)*/ #else L_tmp = L_mult_o( tmp1, tmp1, &Overflow ); /*Q(2*exp - 19)*/ #endif @@ -2562,7 +2562,7 @@ static Word16 shb_DTX_fx( 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] ); + 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 ); #endif @@ -2575,7 +2575,7 @@ static Word16 shb_DTX_fx( exp = sub( 30 - 1, exp ); wb_ener_fx = Mpy_32_16( exp, fra, LG10 ); #ifdef ISSUE_1867_replace_overflow_libenc - log_wb_ener_fx = round_fx_sat( L_shl_sat( wb_ener_fx, 10 ) ); /* log_wb_ener_fx in Q8 */ + 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 */ #endif @@ -2598,7 +2598,7 @@ static Word16 shb_DTX_fx( } #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 */ + 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 */ #endif @@ -3034,7 +3034,7 @@ static Word16 shb_DTX_ivas_fx( 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 + 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 #endif @@ -3048,7 +3048,7 @@ static Word16 shb_DTX_ivas_fx( 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 */ + 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 */ #endif @@ -3076,7 +3076,7 @@ static Word16 shb_DTX_ivas_fx( } #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 */ + 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 */ #endif diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index 2a2016118..156b38ce4 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -66,7 +66,7 @@ void acelp_2t32_fx( 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 ); + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -74,7 +74,7 @@ void acelp_2t32_fx( *p1-- = extract_h( L_cor ); move16(); /*Q9 Q7*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); + L_cor = L_mac_sat( L_cor, *ptr_h1, *ptr_h1 ); #else L_cor = L_mac_o( L_cor, *ptr_h1, *ptr_h1, &Overflow ); #endif @@ -119,10 +119,10 @@ void acelp_2t32_fx( 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++ ); + *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) L_cor = L_mac_o( L_cor, *ptr_h1++, *ptr_h2++, &Overflow ); @@ -136,7 +136,7 @@ void acelp_2t32_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - *p1 = round_fx_sat( L_cor ); // Q9 + *p1 = round_fx_sat( L_cor ); // Q9 #else *p1 = round_fx_o( L_cor, &Overflow ); // Q9 #endif @@ -243,9 +243,9 @@ void acelp_2t32_fx( { ps2 = add( ps1, dn_p[i1] ); #ifdef ISSUE_1867_replace_overflow_libenc - alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); + alp2 = add_sat( alp1, add_sat( *p1++, *p2++ ) ); sq = mult( ps2, ps2 ); - s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); + s = L_msu_sat( L_mult( alpk, sq ), psk, alp2 ); #else alp2 = add_o( alp1, add_o( *p1++, *p2++, &Overflow ), &Overflow ); sq = mult( ps2, ps2 ); diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index 9a3a227cb..5dae2f7f0 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -354,7 +354,7 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Ltmp = L_shl( Ltmp, Q_new_p5 ); 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 ) ); + exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); #else exc2[i] = round_fx_sat( L_shl_o( Ltmp, 1, &Overflow ) ); #endif @@ -363,8 +363,8 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); 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 ); + 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 */ exc[i + i_subfr] = round_fx_o( Ltmp, &Overflow ); diff --git a/lib_enc/core_enc_ol_fx.c b/lib_enc/core_enc_ol_fx.c index 84ceed3f4..020af121c 100644 --- a/lib_enc/core_enc_ol_fx.c +++ b/lib_enc/core_enc_ol_fx.c @@ -556,7 +556,7 @@ void core_encode_openloop_fx( 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 ); + 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 ); #endif @@ -781,8 +781,8 @@ static void closest_centroid_rf( 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 ); + 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 ); L_tmp = L_mult_o( tmp, tmp, &Overflow ); @@ -1120,7 +1120,7 @@ void core_acelp_tcx20_switching_fx( 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] ); + 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 ); #endif @@ -1142,7 +1142,7 @@ void core_acelp_tcx20_switching_fx( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - snr_tcx = round_fx_sat( L_shl_sat( tcx_snr, 8 ) ); /* 7Q8 */ + 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 */ #endif @@ -1180,11 +1180,11 @@ void core_acelp_tcx20_switching_fx( 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] ); + 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 ); + 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 ); @@ -1245,7 +1245,7 @@ void core_acelp_tcx20_switching_fx( if ( ( GT_16( snr_acelp, snr_tcx ) ) && ( 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*/ ) || + ( 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*/ ) || #endif diff --git a/lib_enc/corr_xh_fx.c b/lib_enc/corr_xh_fx.c index f17ade3e5..135d560d1 100644 --- a/lib_enc/corr_xh_fx.c +++ b/lib_enc/corr_xh_fx.c @@ -50,7 +50,7 @@ void corr_xh_fx( 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*/ + 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*/ #endif @@ -64,8 +64,8 @@ void corr_xh_fx( /* tot += 3*max / 8 */ 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 */ + 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_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ @@ -126,8 +126,8 @@ void corr_hh_ivas_fx( /* tot += 3*max / 8 */ 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 */ + 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_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ @@ -180,7 +180,7 @@ void corr_xh_ivas_fx( 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 + 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 #endif @@ -194,8 +194,8 @@ void corr_xh_ivas_fx( /* tot += 3*max / 8 */ 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 */ + 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_shr( L_maxloc, 1 ), &Overflow ); /* +max/8 */ diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index cce34c066..8a9562704 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -72,7 +72,7 @@ static void hp_filter_fx( /*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 */ + 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 */ #endif @@ -82,9 +82,9 @@ static void hp_filter_fx( { /*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 */ + 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_mac_o( L_tmp, y[i - 1], 16158 /*0.4931f in Q15*/, &Overflow ); /*Q_new+16 */ @@ -166,7 +166,7 @@ Word16 detect_transient_fx( { /*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 */ + 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 */ #endif @@ -189,13 +189,13 @@ Word16 detect_transient_fx( { 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 ) ); + Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); #else Energy_fx = L_add_o( Energy_fx, L_mult0( temp16, temp16 ), &Overflow ); #endif 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*/ + 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*/ #endif @@ -203,8 +203,8 @@ Word16 detect_transient_fx( } #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*/ + 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_out_fx = L_add_o( E_out_fx, Energy_fx, &Overflow ); /*Q0*/ @@ -233,7 +233,7 @@ Word16 detect_transient_fx( { /*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 */ + 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 */ #endif @@ -243,7 +243,7 @@ Word16 detect_transient_fx( { /*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 */ + 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 */ #endif @@ -263,7 +263,7 @@ Word16 detect_transient_fx( 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*/ + Energy = L_add_sat( L_shr( L_tmp, shift ), L_shr( L_tmp2, shift ) ); /*2Q_new - shift*/ #endif test(); IF( EQ_16( st_fx->extl, SWB_BWE ) || EQ_16( st_fx->extl, FB_BWE ) ) @@ -306,7 +306,7 @@ Word16 detect_transient_fx( /*EnergyLT = 0.75f*EnergyLT + 0.25f*Energy; */ /*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 */ + 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 */ #endif diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index ea63e275f..e7ac422ad 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -464,7 +464,7 @@ void dtx_ivas_fx( 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*/ + 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*/ #endif @@ -940,7 +940,7 @@ void dtx_fx( 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*/ + 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*/ #endif @@ -1422,7 +1422,7 @@ void dtx_hangover_control_fx( 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 */ + 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 */ #endif @@ -1442,14 +1442,14 @@ void dtx_hangover_control_fx( 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 */ + 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 */ #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 */ + 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 */ #endif @@ -1463,7 +1463,7 @@ void dtx_hangover_control_fx( 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 */ + 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 */ #endif @@ -1480,7 +1480,7 @@ void dtx_hangover_control_fx( { 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 */ + Dlsp = add_sat( Dlsp, S_tmp ); /*Q15 */ #else Dlsp = add_o( Dlsp, S_tmp, &Overflow ); /*Q15 */ #endif diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 4c287b461..2053a1293 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -78,14 +78,14 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac 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*/ + 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*/ #endif } #ifdef ISSUE_1867_replace_overflow_libenc - corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ + corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ #else corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ #endif @@ -95,7 +95,7 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac if ( sign[dn] > 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = add_sat( p0[j], corr ); /*Q9*/ + corr = add_sat( p0[j], corr ); /*Q9*/ #else corr = add_o( p0[j], corr, &Overflow ); /*Q9*/ #endif @@ -103,7 +103,7 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac if ( sign[dn] < 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = sub_sat( p0[j], corr ); /*Q9*/ + corr = sub_sat( p0[j], corr ); /*Q9*/ #else corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/ #endif @@ -139,13 +139,13 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac 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 */ + 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 */ #endif } #ifdef ISSUE_1867_replace_overflow_libenc - corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ + corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/ #else corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/ #endif @@ -155,11 +155,11 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac #ifdef ISSUE_1867_replace_overflow_libenc if ( sign[pos] > 0 ) { - corr = add_sat( *p0++, corr ); /*Q9*/ + corr = add_sat( *p0++, corr ); /*Q9*/ } if ( sign[pos] < 0 ) { - corr = sub_sat( *p0++, corr ); /*Q9*/ + corr = sub_sat( *p0++, corr ); /*Q9*/ } #else if ( sign[pos] > 0 ) @@ -237,7 +237,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* move16(); 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 ) + 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 ) #endif @@ -261,7 +261,7 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* /*alp1 = alp0 + cor_x[x2];*/ #ifdef ISSUE_1867_replace_overflow_libenc - alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ + alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/ #else alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/ #endif @@ -277,8 +277,8 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0* /*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*/ + 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_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/ @@ -589,14 +589,14 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Compute scalar product t1: */ #ifdef ISSUE_1867_replace_overflow_libenc - yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/ + 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*/ #endif /* Compute scalar product t0: */ #ifdef ISSUE_1867_replace_overflow_libenc - xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/ + 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*/ #endif @@ -642,7 +642,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn /* Compute scalar product */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/ + 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*/ #endif @@ -656,7 +656,7 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn exp_tmp = sub( exp_tmp, 1 ); 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*/ + 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*/ #endif @@ -779,13 +779,13 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/, if ( Q15_flag == 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/ + 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*/ #endif } #ifdef ISSUE_1867_replace_overflow_libenc - x2[i] = msu_r_sat( L_tmp, y[i], gain ); /*Q_xn*/ + 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*/ #endif @@ -837,7 +837,7 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ + 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*/ #endif @@ -858,8 +858,8 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ + 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_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/ @@ -884,7 +884,7 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16 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*/ #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*/ + 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*/ #endif @@ -1228,7 +1228,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const 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*/ + 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*/ #endif @@ -1382,7 +1382,7 @@ 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*/ 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*/ + 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*/ #endif @@ -1497,7 +1497,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ + y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/ #else y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/ #endif diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 7527a4602..cd06a4d15 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -170,7 +170,7 @@ static void E_ACELP_2pulse_searchx_fx( 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 ) + 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 ) #endif @@ -214,7 +214,7 @@ static void E_ACELP_2pulse_searchx_fx( 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 */ + 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 */ #endif @@ -229,7 +229,7 @@ static void E_ACELP_2pulse_searchx_fx( 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 */ + 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 */ #endif @@ -245,7 +245,7 @@ static void E_ACELP_2pulse_searchx_fx( /*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 */ + 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 */ #endif @@ -327,7 +327,7 @@ static void E_ACELP_1pulse_searchx_fx( ik = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( mac_r_sat( alp0, cor[tracks[0]], sign[tracks[0]] ) < 0 ) + 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 ) #endif @@ -355,7 +355,7 @@ static void E_ACELP_1pulse_searchx_fx( /* alp1 = alp0 + 2*sign[x]*cor[x]; MAC(1); MULT(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 */ + 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 */ #endif @@ -370,7 +370,7 @@ static void E_ACELP_1pulse_searchx_fx( /*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 */ + 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 */ #endif diff --git a/lib_enc/enc_amr_wb_fx.c b/lib_enc/enc_amr_wb_fx.c index 07878dc16..3dda4ec9f 100644 --- a/lib_enc/enc_amr_wb_fx.c +++ b/lib_enc/enc_amr_wb_fx.c @@ -193,8 +193,8 @@ void encod_amr_wb_fx( gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ @@ -205,7 +205,7 @@ void encod_amr_wb_fx( FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ + exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/ #else exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/ #endif @@ -236,8 +236,8 @@ void encod_amr_wb_fx( L_tmp = L_shl_sat( L_tmp, 5 ); /*Q15*/ L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ - exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q_new+15*/ + exc[i + i_subfr] = round_fx_sat( L_tmp ); /*Q_new*/ #else L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /* saturation can occur here Q_new+15*/ exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow ); /*Q_new*/ diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 323f11575..b425b2c28 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -284,7 +284,7 @@ void encod_gen_voic_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif @@ -340,8 +340,8 @@ void encod_gen_voic_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); /*Q0*/ + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); /*Q0*/ #else Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); /*Q0*/ @@ -382,8 +382,8 @@ void encod_gen_voic_fx( { /* Contribution from AVQ layer */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ #else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/ Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ @@ -391,8 +391,8 @@ void encod_gen_voic_fx( /* Compute exc2 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /* Q16 */ + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ #else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); /* Q16 */ exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ @@ -404,8 +404,8 @@ void encod_gen_voic_fx( Ltmp = L_shl( Ltmp, 5 ); /* Q15 */ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */ #else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */ @@ -424,10 +424,10 @@ void encod_gen_voic_fx( /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code_fx[i] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 */ + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); /* Q0 */ #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */ @@ -742,8 +742,8 @@ void encod_gen_voic_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); + Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); #else Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -799,8 +799,8 @@ void encod_gen_voic_ivas_fx( { /* Contribution from AVQ layer */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); + Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); + Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); #else Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow ); @@ -808,8 +808,8 @@ void encod_gen_voic_ivas_fx( /* Compute exc2 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); + Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); + exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); #else Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow ); exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); @@ -821,8 +821,8 @@ void encod_gen_voic_ivas_fx( Ltmp = L_shl( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); #else Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1 */ /* saturation can occur here Q16*/ exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); @@ -843,10 +843,10 @@ void encod_gen_voic_ivas_fx( /*gcode16 in Qnew*/ Ltmp = L_mult( gcode16, code_fx[i] ); /*Qnew + 9 + 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ - Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ - Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ - exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); + Ltmp = L_shl_sat( Ltmp, 5 ); /*Qnew + 9+ 1+5 */ + Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/ + Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1 */ + exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp ); #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /*Qnew + 9+ 1+5 */ Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/ diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 1f5beed74..cb0fd969e 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -444,13 +444,13 @@ void coder_acelp_rf_fx( /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ Ltmp = Mpy_32_16_1( gain_code, y2[L_SUBFR - 1] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ - Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ + Ltmp = L_shl_sat( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ + Ltmp = L_mac_sat( Ltmp, y1[L_SUBFR - 1], gain_pit ); /* Q15 + Q_xn */ /* Add Gaussian contribution*/ - Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ - Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ - hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ + Ltmp2 = Mpy_32_16_1( gain_code2, y22[L_SUBFR - 1] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, add( 5, Q_xn ) ); /* Q15 + Q_xn */ + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_xn */ + hRF->rf_mem_w0 = sub_sat( xn[L_SUBFR - 1], round_fx_sat( L_shl_sat( Ltmp, 1 ) ) ); /* Q_xn */ #else Ltmp = L_shl_o( Ltmp, add( 5, Q_xn ), &Overflow ); /* Q15 + Q_xn */ Ltmp = L_mac_o( Ltmp, y1[L_SUBFR - 1], gain_pit, &Overflow ); /* Q15 + Q_xn */ @@ -476,15 +476,15 @@ void coder_acelp_rf_fx( /* code in Q9, gain_pit in Q14; exc Q_new */ Ltmp = Mpy_32_16_1( gain_code2, code2[i] ); /* Q10 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ - Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ - exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ + Ltmp = L_shl_sat( Ltmp, Q_new_p5 ); /* Q15 + Q_new */ + Ltmp = L_mac_sat( Ltmp, gain_pit, exc_rf[i + i_subfr] ); /* Q15 + Q_new */ + exc2[i] = round_fx_sat( L_shl_sat( Ltmp, 1 ) ); /* Q_new */ move16(); - Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ - Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ - Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ - exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ + Ltmp2 = Mpy_32_16_1( gain_code_vect[j], code[i] ); /* Q10 */ + Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 ); /* Q15 + Q_new */ + Ltmp = L_add_sat( Ltmp, Ltmp2 ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new*/ + exc_rf[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ #else Ltmp = L_shl_o( Ltmp, Q_new_p5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, gain_pit, exc_rf[i + i_subfr], &Overflow ); /* Q15 + Q_new */ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 298800736..7a88d1619 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -86,7 +86,7 @@ void transf_cdbk_enc_fx( IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); #else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); #endif @@ -185,7 +185,7 @@ void transf_cdbk_enc_fx( e_corr = sub( 14 + 4, e_den ); Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ #ifdef ISSUE_1867_replace_overflow_libenc - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ #else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ #endif @@ -444,7 +444,7 @@ void transf_cdbk_enc_ivas_fx( IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); + gcode16 = round_fx_sat( L_shl_sat( gain_code, Q_new ) ); #else gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); #endif @@ -542,7 +542,7 @@ void transf_cdbk_enc_ivas_fx( e_corr = sub( 14 + 4, e_den ); Ltmp = L_shr( Mult_32_16( Ltmp, m_corr ), e_corr ); /*Q12*/ #ifdef ISSUE_1867_replace_overflow_libenc - stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ + stmp = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); /* Q12 */ #else stmp = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12 */ #endif diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 42a3a292f..0f79d6e02 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -298,7 +298,7 @@ void enc_pit_exc_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #else hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/ #endif @@ -381,12 +381,12 @@ void enc_pit_exc_fx( { Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ - Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ #else Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); @@ -418,10 +418,10 @@ void enc_pit_exc_fx( /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ - Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q_new + Q16*/ + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -885,12 +885,12 @@ void enc_pit_exc_ivas_fx( { Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); // Q_new+14+shift + Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); - Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift - Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift - Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 - hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ + Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); // Q_new-1+15+shift + Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift + Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); // Q_new+15 + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ #else Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift Ltmp = L_negate( Ltmp ); @@ -920,10 +920,10 @@ void enc_pit_exc_ivas_fx( /* code in Q9, gain_pit in Q14 */ Ltmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ - Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ + Ltmp = L_shl_sat( Ltmp, 5 ); /* Q15 + Q_new */ + Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + Ltmp = L_shl_sat( Ltmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc[i + i_subfr] = round_fx_sat( Ltmp ); /* Q_new */ #else Ltmp = L_shl_o( Ltmp, 5, &Overflow ); /* Q15 + Q_new */ Ltmp = L_mac_o( Ltmp, exc[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index b5a3a037a..e04d42331 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -231,8 +231,8 @@ Word16 encod_tran_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -286,10 +286,10 @@ Word16 encod_tran_fx( /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ #else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -309,11 +309,11 @@ Word16 encod_tran_fx( { L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ - tmp_fx = round_fx_sat( L_tmp ); - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ + tmp_fx = round_fx_sat( L_tmp ); + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ move16(); #else L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ @@ -635,8 +635,8 @@ Word16 encod_tran_ivas_fx( gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ - gcode16 = round_fx_sat( Lgcode ); + Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ + gcode16 = round_fx_sat( Lgcode ); #else Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); @@ -690,10 +690,10 @@ Word16 encod_tran_ivas_fx( /* code in Q9, gain_pit in Q14 */ L_tmp = L_mult( gcode16, code[i] ); /* Q10 + Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ - exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ + L_tmp = L_shl_sat( L_tmp, 5 ); /* Q15 + Q_new */ + L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr], gain_pit ); /* Q15 + Q_new */ + L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here Q16 + Q_new */ + exc_fx[i + i_subfr] = round_fx_sat( L_tmp ); /* Q_new */ #else L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q15 + Q_new */ L_tmp = L_mac_o( L_tmp, exc_fx[i + i_subfr], gain_pit, &Overflow ); /* Q15 + Q_new */ @@ -713,12 +713,12 @@ Word16 encod_tran_ivas_fx( { L_tmp = L_mult( gain_preQ, code_preQ[i] ); /* Q2 + Q10 -> Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ - tmp_fx = round_fx_sat( L_tmp ); + L_tmp = L_shl_sat( L_tmp, tmp1_fx ); /* Q16 + Q_exc */ + tmp_fx = round_fx_sat( L_tmp ); - exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ + exc2_fx[i + i_subfr] = add_sat( exc2_fx[i + i_subfr], tmp_fx ); /* Q_exc */ move16(); - exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ + exc_fx[i + i_subfr] = add_sat( exc_fx[i + i_subfr], tmp_fx ); /* Q_exc */ #else L_tmp = L_shl_o( L_tmp, tmp1_fx, &Overflow ); /* Q16 + Q_exc */ tmp_fx = round_fx_o( L_tmp, &Overflow ); diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index 988b3a29d..308c7cc5d 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -122,7 +122,7 @@ void est_energy_fx( tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */ s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } - frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ + frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ move32(); } diff --git a/lib_enc/find_tar_fx.c b/lib_enc/find_tar_fx.c index ee37b3af2..0fec2c424 100644 --- a/lib_enc/find_tar_fx.c +++ b/lib_enc/find_tar_fx.c @@ -135,7 +135,7 @@ void find_targets_fx( Ltmp = L_msu( Ltmp, Aqs[j], h1[i - j] ); /* Q27 */ } #ifdef ISSUE_1867_replace_overflow_libenc - h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ + h1[i] = round_fx( L_shl_sat( Ltmp, s ) ); /* Q11 + s */ #else h1[i] = round_fx( L_shl_o( Ltmp, s, &Overflow ) ); /* Q11 + s */ #endif @@ -266,7 +266,7 @@ void find_targets_ivas_fx( FOR( j = 1; j <= i; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif @@ -279,7 +279,7 @@ void find_targets_ivas_fx( FOR( j = 1; j <= M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif @@ -290,14 +290,14 @@ void find_targets_ivas_fx( FOR( i = M + 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ + Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_sat( h1_32[i - 1], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( 0, Aqs[1], extract_h( L_shl_o( h1_32[i - 1], s, &Overflow ) ) ); /* Q27 */ #endif FOR( j = 2; j <= M; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ + Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_sat( h1_32[i - j], s ) ) ); /* Q27 */ #else Ltmp64 = W_msu_16_16( Ltmp64, Aqs[j], extract_h( L_shl_o( h1_32[i - j], s, &Overflow ) ) ); /* Q27 */ #endif diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 6533f7071..56078ec1e 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -111,8 +111,8 @@ void find_tilt_fx( Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); /* Q31 */ Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); /* Q31 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ - mean_voi = round_fx_sat( Ltmp ); /* Q15 */ + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 ); /* Q31 */ + mean_voi = round_fx_sat( Ltmp ); /* Q15 */ #else Ltmp = L_mac_o( Ltmp, corr_shift, 32767, &Overflow ); /* Q31 */ mean_voi = round_fx_o( Ltmp, &Overflow ); /* Q15 */ @@ -163,7 +163,7 @@ void find_tilt_fx( IF( L_mac0( -(Word32) TH_D_FX * TH_D_FX, tmp, tmp ) < 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ + lp_E = L_add_sat( *pt_E, lp_E ); /* Q_new + QSCALE - 2 */ #else lp_E = L_add_o( *pt_E, lp_E, &Overflow ); /* Q_new + QSCALE - 2 */ #endif @@ -172,8 +172,8 @@ void find_tilt_fx( pt_E++; } #ifdef ISSUE_1867_replace_overflow_libenc - f1 = add_sat( f1, f0 ); - f2 = add_sat( f2, f0 ); + f1 = add_sat( f1, f0 ); + f2 = add_sat( f2, f0 ); #else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); @@ -192,7 +192,7 @@ void find_tilt_fx( e_tmp = sub( e_tmp, e_cnt ); #ifdef ISSUE_1867_replace_overflow_libenc - lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ + lp_E = L_sub_sat( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr ); /* Q_new + QSCALE */ #else lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif @@ -237,7 +237,7 @@ void find_tilt_fx( IF( EQ_16( bwidth, NB ) ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( ee[i], 3 ); + Ltmp = L_shl_sat( ee[i], 3 ); #else Ltmp = L_shl_o( ee[i], 3, &Overflow ); #endif @@ -373,8 +373,8 @@ void find_tilt_ivas_fx( Ltmp = L_mult( voicing[1], 16384 /* 0.5 in Q15 */ ); // Q31 Ltmp = L_mac( Ltmp, voicing[2], 16384 /* 0.5 in Q15 */ ); // Q31 #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 - mean_voi = round_fx_sat( Ltmp ); // Q15 + Ltmp = L_mac_sat( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */ ); // Q31 + mean_voi = round_fx_sat( Ltmp ); // Q15 #else Ltmp = L_mac_o( Ltmp, corr_shift, 32767 /* 1.0f in Q15 */, &Overflow ); // Q31 mean_voi = round_fx_o( Ltmp, &Overflow ); // Q15 @@ -431,8 +431,8 @@ void find_tilt_ivas_fx( pt_E++; } #ifdef ISSUE_1867_replace_overflow_libenc - f1 = add_sat( f1, f0 ); - f2 = add_sat( f2, f0 ); + f1 = add_sat( f1, f0 ); + f2 = add_sat( f2, f0 ); #else f1 = add_o( f1, f0, &Overflow ); f2 = add_o( f2, f0, &Overflow ); @@ -505,7 +505,7 @@ void find_tilt_ivas_fx( IF( bwidth == NB ) /* For NB input, compensate for the missing bands */ { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ + Ltmp = L_shl_sat( ee[i], 3 ); /* Q6 */ #else Ltmp = L_shl_o( ee[i], 3, &Overflow ); /* Q6 */ #endif diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index ce764dd63..401b64cb5 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -201,7 +201,7 @@ Word16 find_uv_fx( /* o : coding type */ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef ISSUE_1867_replace_overflow_libenc - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ #else mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ #endif @@ -231,7 +231,7 @@ Word16 find_uv_fx( /* o : coding type */ dE2_th = 21 << 10; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #else if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 /* 0.68 in Q15 */ ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif @@ -314,7 +314,7 @@ Word16 find_uv_fx( /* o : coding type */ if ( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], L_shl( E_MIN_FX, Q_new ) ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ #ifdef ISSUE_1867_replace_overflow_libenc - ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ + ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) /* normalized correlation is low */ #else ( LT_16( add_o( st_fx->voicing_fx[0], corr_shift, &Overflow ), voi_th ) ) ) ) /* normalized correlation is low */ #endif @@ -394,8 +394,8 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ ( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ @@ -428,7 +428,7 @@ Word16 find_uv_fx( /* o : coding type */ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #endif @@ -740,7 +740,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ /*mean_ee = 1.0f/3.0f * (st->ee_old + ee[0] + ee[1]); */ /* coefficients take into account the position of the window */ #ifdef ISSUE_1867_replace_overflow_libenc - mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ + mean_ee = L_add_sat( L_add_sat( st_fx->ee_old_fx, ee[0] ), ee[1] ); /* Q6 */ #else mean_ee = L_add_o( L_add_o( st_fx->ee_old_fx, ee[0], &Overflow ), ee[1], &Overflow ); /* Q6 */ #endif @@ -770,7 +770,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ dE2_th = 21 << 10; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ + if ( GE_16( add_sat( mean_voi3, corr_shift ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #else if ( GE_16( add_o( mean_voi3, corr_shift, &Overflow ), 22282 ) ) /*( mean_voi3 + corr_shift ) >= 0.68f*/ #endif @@ -856,7 +856,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ ( LT_16( add_sat( st_fx->voicing_fx[0], corr_shift ), voi_th ) ) ) ) - /* normalized correlation is low */ + /* normalized correlation is low */ #else IF( ( EQ_16( st_fx->last_coder_type_raw, UNVOICED ) ) || /* previous frame was unvoiced */ ( ( LT_32( ee[0], ee0_th ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy is concentrated in high frequencies provided that some energy is present in HF */ @@ -938,15 +938,15 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ flag_low_relE ) #else IF( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ @@ -978,7 +978,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #else if ( ( ( LT_16( add_o( mean_voi3, corr_shift, &Overflow ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ #endif diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index ee55f1d9a..e148aeaac 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -98,7 +98,7 @@ void Es_pred_enc_fx( { tmp16 = mult_r( res[i_subfr + i], 8192 /* 1 in Q13 */ ); /* remove 2bits Q_new - 2*/ #ifdef ISSUE_1867_replace_overflow_libenc - ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); + ener_fx = L_mac_sat( ener_fx, tmp16, tmp16 ); #else ener_fx = L_mac_o( ener_fx, tmp16, tmp16, &Overflow ); #endif @@ -184,7 +184,7 @@ void Es_pred_enc_fx( FOR( i = 1; i < size; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); + tmp16_2 = abs_s( sub_sat( mean_ener_code16, qua_table[i] ) ); #else tmp16_2 = abs_s( sub_o( mean_ener_code16, qua_table[i], &Overflow ) ); #endif @@ -412,7 +412,7 @@ void gain_enc_mless_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -441,7 +441,7 @@ void gain_enc_mless_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); + *gain_code = L_shl_sat( L_div, sub( add( exp, exp_div ), 14 ) ); #else *gain_code = L_shl_o( L_div, sub( add( exp, exp_div ), 14 ), &Overflow ); #endif @@ -475,7 +475,7 @@ void gain_enc_mless_fx( push_indice( hBstr, IND_GAIN_CODE, index, nBits2 ); L_tmp = L_mult( gain_code16, gcode0 ); /*Q0*Q0 -> Q1*/ #ifdef ISSUE_1867_replace_overflow_libenc - *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ + *gain_code = L_shl_sat( L_tmp, add( add( expg, exp_gcode0 ), 15 ) ); /*Q16*/ #else *gain_code = L_shl_o( L_tmp, add( add( expg, exp_gcode0 ), 15 ), &Overflow ); /*Q16*/ #endif @@ -706,7 +706,7 @@ void gain_enc_SQ_fx( exp1 = add( exp_coeff[0], exp_coeff[2] ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ + L_tmp2 = L_mult_sat( coeff[4], coeff[4] ); /*Q31*/ #else L_tmp2 = L_mult_o( coeff[4], coeff[4], &Overflow ); /*Q31*/ #endif @@ -752,7 +752,7 @@ void gain_enc_SQ_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ #else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif @@ -761,7 +761,7 @@ void gain_enc_SQ_fx( exp_div = sub( exp_num, exp_den ); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ + *gain_pit = round_fx_sat( L_shl_sat( L_div, add( exp, exp_div ) ) ); /*Q14*/ #else *gain_pit = round_fx_o( L_shl_o( L_div, add( exp, exp_div ), &Overflow ), &Overflow ); /*Q14*/ #endif @@ -785,7 +785,7 @@ void gain_enc_SQ_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ + L_frac_num = L_sub_sat( L_tmp2, L_tmp1 ); /*Q31*/ #else L_frac_num = L_sub_o( L_tmp2, L_tmp1, &Overflow ); /*Q31*/ #endif @@ -912,7 +912,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant Ltmp = Pow2( 14, frac_gain ); /* Put 14 as exponent */ exp_gain = sub( exp_gain, 14 ); /* Retreive exponent of wtmp */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); + *gain = L_shl_sat( Ltmp, add( 16, exp_gain ) ); #else *gain = L_shl_o( Ltmp, add( 16, exp_gain ), &Overflow ); #endif @@ -1235,7 +1235,7 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); + L_tmp1 = L_sub_sat( L_tmp, dist_min ); #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -2009,7 +2009,7 @@ void gain_enc_amr_wb_fx( L_tmp = L_mac( L_tmp, coeff[4], g_pit_cod ); /* 15 - coeff_exp + 13 - 1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); + L_tmp1 = L_sub_sat( L_tmp, dist_min ); #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -2036,7 +2036,7 @@ void gain_enc_amr_wb_fx( L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q0 -> Q12 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ + L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 4 ) ); /* Q12 -> Q16 */ #else L_tmp = L_shl_o( L_tmp, add( exp_gcode0, 4 ), &Overflow ); /* Q12 -> Q16 */ #endif diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 3de426846..08514875c 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -101,7 +101,7 @@ Word16 gaus_encode_fx( * Total excitation for Unvoiced coders *----------------------------------------------------------------*/ #ifdef ISSUE_1867_replace_overflow_libenc - gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ + gcode = round_fx_sat( L_shl_sat( *gain_code, Q_new ) ); /* scaled gain_code with Qnew */ #else gcode = round_fx_o( L_shl_o( *gain_code, Q_new, &Overflow ), &Overflow ); /* scaled gain_code with Qnew */ #endif @@ -433,8 +433,8 @@ void gauss2v_fx( cor2_norm = norm_l( cor2 ); eneri_norm = norm_l( eneri ); #ifdef ISSUE_1867_replace_overflow_libenc - cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); - eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); + cor2_mantissa = round_fx_sat( L_shl_sat( cor2, cor2_norm ) ); + eneri_mantissa = round_fx_sat( L_shl_sat( eneri, eneri_norm ) ); #else cor2_mantissa = round_fx_o( L_shl_o( cor2, cor2_norm, &Overflow ), &Overflow ); eneri_mantissa = round_fx_o( L_shl_o( eneri, eneri_norm, &Overflow ), &Overflow ); @@ -608,7 +608,7 @@ void gauss2v_fx( /* Gain must be output in a 32-bit variable as a Q16 */ /* Compensate for Q_new */ #ifdef ISSUE_1867_replace_overflow_libenc - *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ + *gain = L_shl_sat( Portion, sub( 13, Q_new ) ); /* Q16 */ #else *gain = L_shl_o( Portion, sub( 13, Q_new ), &Overflow ); /* Q16 */ #endif diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index 5d32a390a..05d385fe7 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -145,14 +145,14 @@ Word16 gp_clip_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - ener = L_mac_sat( 1L, xn[0], xn[0] ); + ener = L_mac_sat( 1L, xn[0], xn[0] ); #else ener = L_mac_o( 1L, xn[0], xn[0], &Overflow ); #endif FOR( i = 1; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - ener = L_mac_sat( ener, xn[i], xn[i] ); + ener = L_mac_sat( ener, xn[i], xn[i] ); #else ener = L_mac_o( ener, xn[i], xn[i], &Overflow ); #endif @@ -368,7 +368,7 @@ Word16 Mode2_gp_clip_fx( FOR( i = 0; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - wener = L_mac0_sat( wener, xn[i], xn[i] ); + wener = L_mac0_sat( wener, xn[i], xn[i] ); #else wener = L_mac0_o( wener, xn[i], xn[i], &Overflow ); #endif diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 424564fcb..c666840df 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1344,7 +1344,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ L_tmp = L_mult0( vec[j], vec[j] ); /*2*Qnew*/ ener_max = L_max( ener_max, L_tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - ener_mean = L_add_sat( ener_mean, L_tmp ); + ener_mean = L_add_sat( ener_mean, L_tmp ); #else ener_mean = L_add_o( ener_mean, L_tmp, &Overflow ); #endif @@ -1356,7 +1356,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ { exp1 = norm_l( ener_mean ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); + tmp1 = round_fx_sat( L_shl( ener_mean, exp1 ) ); #else tmp1 = round_fx_o( L_shl( ener_mean, exp1 ), &Overflow ); #endif diff --git a/lib_enc/guided_plc_enc_fx.c b/lib_enc/guided_plc_enc_fx.c index dcaa15469..50932734c 100644 --- a/lib_enc/guided_plc_enc_fx.c +++ b/lib_enc/guided_plc_enc_fx.c @@ -168,7 +168,7 @@ static void coderLookAheadInnovation( BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1867_replace_overflow_libenc - max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); + max_ps_tmp = L_shl_sat( max_ps, sub( max_ps_e, ps_e ) ); #else max_ps_tmp = L_shl_o( max_ps, sub( max_ps_e, ps_e ), &Overflow ); #endif @@ -464,7 +464,7 @@ void updateSpecPowDiffuseIdx_fx( FOR( k = 1; k < 4; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); + st->mean_gc[1] = L_add_sat( st->mean_gc[1], st->gain_code[k] ); #else st->mean_gc[1] = L_add_o( st->mean_gc[1], st->gain_code[k], &Overflow ); #endif @@ -475,7 +475,7 @@ void updateSpecPowDiffuseIdx_fx( /* Suppress saturation warning in threshold comparison. */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) + if ( LT_32( st->mean_gc[1], L_add_sat( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ) ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) #else if ( LT_32( st->mean_gc[1], L_add_o( st->mean_gc[0], Mpy_32_16_r( st->mean_gc[0], 3211 /*0.098 Q15*/ ), &Overflow ) ) || GT_16( min_gp, 13435 /*0.82 Q14*/ ) ) #endif diff --git a/lib_enc/hf_cod_amrwb_fx.c b/lib_enc/hf_cod_amrwb_fx.c index 7e49055f0..9de30e99a 100644 --- a/lib_enc/hf_cod_amrwb_fx.c +++ b/lib_enc/hf_cod_amrwb_fx.c @@ -113,7 +113,7 @@ void hf_cod_fx( L_tmp = L_mult( ener_hf_fx, scale_fx ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ #ifdef ISSUE_1867_replace_overflow_libenc - scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ + scale_fx = round_fx( Isqrt( L_shl_sat( L_tmp, sub( q2, 26 ) ) ) ); /*Q13 */ #else scale_fx = round_fx( Isqrt( L_shl_o( L_tmp, sub( q2, 26 ), &Overflow ) ) ); /*Q13 */ #endif @@ -193,7 +193,7 @@ void hf_cod_fx( L_tmp = L_mult( ener_hf_fx, HF_calc_gain_fx ); /*30-q1+q2 */ q2 = sub( q1, q2 ); /*30-q2 */ #ifdef ISSUE_1867_replace_overflow_libenc - HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ + HF_calc_gain_fx = round_fx_sat( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ) ); /*Q10 */ #else HF_calc_gain_fx = round_fx_o( Isqrt( L_shl_sat( L_tmp, sub( q2, 20 ) ) ), &Overflow ); /*Q10 */ #endif diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index b738dc8f3..c8799784b 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -811,7 +811,7 @@ void hvq_classifier_ivas_fx( move16(); /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); /* Q6 */ #else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); /* Q6 */ #endif @@ -1249,7 +1249,7 @@ void hvq_classifier_fx( /*sharp_dist += (sharp[i]-HVQ_SHARP_THRES); */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); + sharp_dist = add_sat( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ) ); #else sharp_dist = add_o( sharp_dist, sub( sharp[i], HVQ_SHARP_THRES_FX ), &Overflow ); #endif diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 4c90d2762..7dc3000c8 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -610,7 +610,7 @@ void hq_lr_enc_fx( } L_tmp = Mult_32_16( Ep_vari_fx, 3277 ); /*13+15-15=13 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ + L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( 12, exp ) ); /*Q(13+exp-15 +12-exp +4 = 14) */ #else L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( 12, exp ), &Overflow ); /*Q(13+exp-15 +12-exp +4 = 14) */ #endif @@ -631,7 +631,7 @@ void hq_lr_enc_fx( } L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ + L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ #else L_tmp2 = L_shl_o( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ), &Overflow ); /*Q(13+exp-15 +13-exp +3 = 14) */ #endif @@ -658,7 +658,7 @@ void hq_lr_enc_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ + L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ #else L_tmp = L_shl_o( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ #endif @@ -685,7 +685,7 @@ void hq_lr_enc_fx( move16(); } #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ + L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ #else L_tmp = L_shl_o( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ), &Overflow ); /*Q(13+exp-15 +19-exp +3 = 20) */ #endif @@ -768,7 +768,7 @@ void hq_lr_enc_fx( FOR( i = 0; i < bands_fx; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ #else Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ #endif @@ -804,7 +804,7 @@ void hq_lr_enc_fx( { Ep_vari_fx = L_add_sat( Ep_vari_fx, L_abs( L_sub_sat( Ep_tmp_fx[i], Ep_tmp_fx[( i - 1 )] ) ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -877,7 +877,7 @@ void hq_lr_enc_fx( tmp = sub( tmp, lowband ); L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp ); /*Q(15+0-15 = 0) */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ #else tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ #endif @@ -942,7 +942,7 @@ void hq_lr_enc_fx( IF( GE_16( i, lowband ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -950,7 +950,7 @@ void hq_lr_enc_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1489,7 +1489,7 @@ void hq_lr_enc_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1617,7 +1617,7 @@ void hq_lr_enc_ivas_fx( } Mpy_32_16_ss( Ep_avrg_fx, tmp, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ + L_tmp = L_shl_sat( L_tmp, sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ #else L_tmp = L_shl_o( L_tmp, sub( 14, exp ), &Overflow ); /*Q(13+exp-15 +14-exp+2 = 14) */ #endif @@ -1668,7 +1668,7 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1714,7 +1714,7 @@ void hq_lr_enc_ivas_fx( Mpy_32_16_ss( L_tmp, lowband, &L_tmp, &lo ); Mpy_32_16_ss( L_tmp, 18842, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ + L_tmp = L_shl_sat( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ #else L_tmp = L_shl_o( L_tmp, sub( 27, exp ), &Overflow ); /*Q14 0.5 */ #endif @@ -1742,7 +1742,7 @@ void hq_lr_enc_ivas_fx( FOR( i = 0; i < bands; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ + Ep_tmp_fx[i] = L_shl_sat( Ep_tmp_fx[i], 2 ); /* Q15 */ #else Ep_tmp_fx[i] = L_shl_o( Ep_tmp_fx[i], 2, &Overflow ); /* Q15 */ #endif @@ -1782,7 +1782,7 @@ void hq_lr_enc_ivas_fx( { Ep_vari_fx = L_add( Ep_vari_fx, L_abs( L_sub( Ep_tmp_fx[i], Ep_tmp_fx[sub( i, 1 )] ) ) ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1819,7 +1819,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); /*Q0 */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ #else tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ #endif @@ -1862,7 +1862,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); Mpy_32_16_ss( Ep_tmp_fx[i], tmp, &L_tmp, &lo ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); /*Q0 */ #else tmp = extract_h( L_shl_o( L_tmp, 16, &Overflow ) ); /*Q0 */ #endif @@ -1891,7 +1891,7 @@ void hq_lr_enc_ivas_fx( tmp = sub( tmp, lowband ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ + tmp1 = extract_h( L_shl_sat( Ep_avrg_fx, 1 ) ); /*Q0 */ #else tmp1 = extract_h( L_shl_o( Ep_avrg_fx, 1, &Overflow ) ); /*Q0 */ #endif @@ -1934,7 +1934,7 @@ void hq_lr_enc_ivas_fx( IF( sub( i, lowband ) >= 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrg_fx = L_add_sat( Ep_avrg_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrg_fx = L_add_o( Ep_avrg_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1942,7 +1942,7 @@ void hq_lr_enc_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ + Ep_avrgL_fx = L_add_sat( Ep_avrgL_fx, Ep_tmp_fx[i] ); /*Q15 */ #else Ep_avrgL_fx = L_add_o( Ep_avrgL_fx, Ep_tmp_fx[i], &Overflow ); /*Q15 */ #endif @@ -1971,7 +1971,7 @@ void hq_lr_enc_ivas_fx( FOR( i = 0; i < lowband; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ + tmp = extract_h( L_shl_sat( Ep_avrgL_fx, 1 ) ); /*Q0 */ #else tmp = extract_h( L_shl_o( Ep_avrgL_fx, 1, &Overflow ) ); /*Q0 */ #endif @@ -3555,7 +3555,7 @@ static Word16 p2a_threshold_quant_fx( L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ #ifdef ISSUE_1867_replace_overflow_libenc - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ #else p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ #endif @@ -3680,7 +3680,7 @@ static Word16 p2a_threshold_quant_ivas_fx( L_p2a = Mpy_32_16_1( L_tmp, 24660 ); /* 16+13-15 -> Q14 */ #ifdef ISSUE_1867_replace_overflow_libenc - p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ + p2a_fx = round_fx_sat( L_shl_sat( L_p2a, 13 ) ); /* 27 -16 -> 11 */ #else p2a_fx = round_fx_o( L_shl_o( L_p2a, 13, &Overflow ), &Overflow ); /* 27 -16 -> 11 */ #endif @@ -3826,7 +3826,7 @@ static void mdct_spectrum_fine_gain_enc_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); #ifdef ISSUE_1867_replace_overflow_libenc - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ #else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ #endif @@ -3994,7 +3994,7 @@ static void mdct_spectrum_fine_gain_enc_ivas_fx( exp_normn = sub( exp_normn, 1 ); exp_normd = norm_l( L_Eyy ); #ifdef ISSUE_1867_replace_overflow_libenc - gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ + gamma_fx = div_l( L_shl( L_Exy, exp_normn ), round_fx_sat( L_shl( L_Eyy, exp_normd ) ) ); /* Qgamma */ #else gamma_fx = div_l( L_shl_o( L_Exy, exp_normn, &Overflow ), round_fx_o( L_shl_o( L_Eyy, exp_normd, &Overflow ), &Overflow ) ); /* Qgamma */ #endif diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 027671004..60cf0159a 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -121,7 +121,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits } #ifdef ISSUE_1867_replace_overflow_libenc - pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ #else pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif @@ -153,7 +153,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1867_replace_overflow_libenc - noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #endif @@ -308,7 +308,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits } #ifdef ISSUE_1867_replace_overflow_libenc - pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ + pe_mean = L_add_sat( pe_mean, pe ); /* in Q12 and always positive */ #else pe_mean = L_add_o( pe_mean, pe, &Overflow ); /* in Q12 and always positive */ #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index ae1aac153..2a96904e1 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -221,8 +221,8 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< } #ifdef ISSUE_1867_replace_overflow_libenc - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); - BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyTileR[sfb] ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); + BASOP_Util_Divide_MantExp( round_fx_sat( sfbEnergyC[sfb] ), sfbEnergyC_exp[sfb], round_fx_sat( sfbEnergyTileC[sfb] ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); #else BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyTileR[sfb], &Overflow ), sfbEnergyTileR_exp[sfb], width, 15, &gain, &gain_exp ); BASOP_Util_Divide_MantExp( round_fx_o( sfbEnergyC[sfb], &Overflow ), sfbEnergyC_exp[sfb], round_fx_o( sfbEnergyTileC[sfb], &Overflow ), sfbEnergyTileC_exp[sfb], &tmp, &tmp_exp ); @@ -255,7 +255,7 @@ static void IGF_CalculateEnvelope( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< L_tmp = L_add( L_tmp, L_deposit_h( shl( gain_exp, 15 - 6 ) ) ); shift = norm_l( L_tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - gain = round_fx_sat( L_shl( L_tmp, shift ) ); + gain = round_fx_sat( L_shl( L_tmp, shift ) ); #else gain = round_fx_o( L_shl_o( L_tmp, shift, &Overflow ), &Overflow ); #endif @@ -454,8 +454,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou /* negate because the negated may be 1 larger in abs, */ /* so whenever compared to the negation of a maximum possible pPowerspectrum, it is still larger */ #ifdef ISSUE_1867_replace_overflow_libenc - highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); - L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); + highPassEner_Ovfl = L_shl_sat( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ) ); + L_tmp = L_add_sat( pPowerSpectrum[i - 1], highPassEner_Ovfl ); #else highPassEner_Ovfl = L_shl_o( L_negate( highPassEner ), sub( *highPassEner_exp, pPowerSpectrum_exp ), &Overflow ); L_tmp = L_add_o( pPowerSpectrum[i - 1], highPassEner_Ovfl, &Overflow ); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index f146d03e5..c48cb87fe 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -1244,7 +1244,7 @@ Word16 ivas_acelp_tcx20_switching_fx( if ( ( GT_32( snr_acelp, tcx_snr ) ) && ( LT_32( snr_acelp, L_add( tcx_snr, 131072 /*2.0f Q16*/ ) ) ) && #ifdef ISSUE_1867_replace_overflow_libenc - ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || + ( LT_32( L_add_sat( st->prevTempFlatness_32fx, currFlatness ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || #else ( LT_32( L_add_o( st->prevTempFlatness_32fx, currFlatness, &Overflow ), 6815744 /*3.25f Q21*/ ) || EQ_16( stab_fac, 0x7fff ) || #endif diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 9e0e6408a..fa33405b5 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -787,7 +787,7 @@ static Word16 qlsf_Mode_Select_fx( pred_pow2[i] = shl( pred1[i], cs ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ + En = L_mac_sat( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i] ); /* 2.56*2.56 at Q-4 */ #else En = L_mac_o( En, mult( pred_pow2[i], shl_sat( w[i], 2 ) ), pred_pow2[i], &Overflow ); /* 2.56*2.56 at Q-4 */ #endif @@ -2001,7 +2001,7 @@ static void first_VQstages( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif @@ -2197,7 +2197,7 @@ static void first_VQstages_ivas_fx( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif @@ -3411,7 +3411,7 @@ Word32 qlsf_ARSN_tcvq_Enc_16k_fx( yy_fx[i] = shl( yy_fx[i], cs ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); + temp_l = L_mac_sat( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i] ); #else temp_l = L_mac_o( temp_l, mult( yy_fx[i], shl_sat( w_fx[i], 2 ) ), yy_fx[i], &Overflow ); #endif @@ -3443,7 +3443,7 @@ static void FFT_Mid_Interpol_16k_fx( { /* Interpolation */ #ifdef ISSUE_1867_replace_overflow_libenc - Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); + Bin_Ener_mid[i] = L_shr( L_add_sat( Bin_Ener_old[i], Bin_Ener[i] ), 1 ); #else Bin_Ener_mid[i] = L_shr( L_add_o( Bin_Ener_old[i], Bin_Ener[i], &Overflow ), 1 ); #endif @@ -3628,8 +3628,8 @@ static void lsf_mid_enc_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat( tmp, tmp ); - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); + tmp = mult_r_sat( tmp, tmp ); + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); #else tmp = mult_ro( tmp, tmp, &Overflow ); err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); @@ -3821,8 +3821,8 @@ static void lsf_mid_enc_ivas_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat( tmp, tmp ); - err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); + tmp = mult_r_sat( tmp, tmp ); + err = L_mac_sat( err, tmp, shl_sat( wghts[j], 2 ) ); #else tmp = mult_ro( tmp, tmp, &Overflow ); err = L_mac_o( err, tmp, shl_sat( wghts[j], 2 ), &Overflow ); diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index 229bd9958..0cb31e6f0 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -1634,14 +1634,14 @@ void midlsf_enc_fx( /* tmp is usually very small, we can have some extra precision with very rare saturation */ tmp = shl_sat( tmp, 4 ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp = mult_r_sat( tmp, tmp ); + tmp = mult_r_sat( tmp, tmp ); #else tmp = mult_ro( tmp, tmp, &Overflow ); #endif err = L_mac( err, tmp, wghts[j] ); } #ifdef ISSUE_1867_replace_overflow_libenc - err = L_shl_sat( err, 2 ); + err = L_shl_sat( err, 2 ); #else err = L_shl_o( err, 2, &Overflow ); #endif diff --git a/lib_enc/mdct_classifier_fx.c b/lib_enc/mdct_classifier_fx.c index 5560fe29d..790ec7aa8 100644 --- a/lib_enc/mdct_classifier_fx.c +++ b/lib_enc/mdct_classifier_fx.c @@ -359,7 +359,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) + IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_sat( avrg_H1, 1 ) ) ) || ( LT_32( Mult_32_32( L_shl( peak_l, exp ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( L_tmp, exp ), L_shl( avrg_l, exp1 ) ) ) || GT_32( Mult_32_32( L_shl( L_tmp1, exp2 ), L_shl( avrg_h, exp1 ) ), Mult_32_32( L_shl( peak_h, exp2 ), L_shl( avrg_l, exp1 ) ) ) ) ) #else IF( GT_32( Mult_32_16( gain3, 27307 ), gain2 ) || ( GE_32( gain3, Mult_32_16( gain2, 26214 ) ) && GT_32( peak_H1, L_shl_o( avrg_H1, 1, &Overflow ) ) ) || ( LT_32( Mult_32_32( L_shl_o( peak_l, exp, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( L_tmp, exp, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) || GT_32( Mult_32_32( L_shl_o( L_tmp1, exp2, &Overflow ), L_shl_o( avrg_h, exp1, &Overflow ) ), Mult_32_32( L_shl_o( peak_h, exp2, &Overflow ), L_shl_o( avrg_l, exp1, &Overflow ) ) ) ) ) #endif @@ -457,7 +457,7 @@ Word16 mdct_classifier_fx( /* o: MDCT A/B decision test(); test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) #else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) #endif @@ -1006,7 +1006,7 @@ Word16 mdct_classifier_ivas_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) + IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_sat( gain1_tmp, 1 ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_sat( gain2_tmp, 1 ) ) ) ) ) #else IF( ( EQ_16( hTcxEnc->clas_final_old, HQ_CORE ) || EQ_16( hTcxEnc->clas_final_old, TCX_20_CORE ) ) && ( ( GT_32( hTcxEnc->last_gain1, L_shr( gain1_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain1, L_shl_o( gain1_tmp, 1, &Overflow ) ) ) && ( GT_32( hTcxEnc->last_gain2, L_shr( gain2_tmp, 1 ) ) && LT_32( hTcxEnc->last_gain2, L_shl_o( gain2_tmp, 1, &Overflow ) ) ) ) ) #endif diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index f0152a93b..ba68b6852 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -215,7 +215,7 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity { /* include the last peak point (new minimum) to the corr. sum */ #ifdef ISSUE_1867_replace_overflow_libenc - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); #else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); #endif @@ -270,9 +270,9 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity k++; } #ifdef ISSUE_1867_replace_overflow_libenc - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); #else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); @@ -564,7 +564,7 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni { /* include the last peak point (new minimum) to the corr. sum */ #ifdef ISSUE_1867_replace_overflow_libenc - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); #else Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); #endif @@ -619,9 +619,9 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni k++; } #ifdef ISSUE_1867_replace_overflow_libenc - Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); - Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); - Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); + Lcorx2 = L_mac_sat( Lcorx2, S[i], S[i] ); + Lcory2 = L_mac_sat( Lcory2, old_S[i], old_S[i] ); + Lcorxy = L_mac_sat( Lcorxy, S[i], old_S[i] ); #else Lcorx2 = L_mac_o( Lcorx2, S[i], S[i], &Overflow ); Lcory2 = L_mac_o( Lcory2, old_S[i], old_S[i], &Overflow ); diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index bc775783c..9d192500f 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -425,7 +425,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ #else E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif @@ -445,7 +445,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ #else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ #endif @@ -465,7 +465,7 @@ void nelp_encoder_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ #else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ #endif @@ -485,7 +485,7 @@ void nelp_encoder_fx( FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif @@ -513,7 +513,7 @@ void nelp_encoder_fx( FOR( j = (Word16) ( i * lag ); j < L_FRAME; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif @@ -1194,7 +1194,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ + E1_fx = L_mac0_sat( E1_fx, in_fx[i], in_fx[i] ); /*Q(qE1+qE1) */ #else E1_fx = L_mac0_o( E1_fx, in_fx[i], in_fx[i], &Overflow ); /*Q(qE1+qE1) */ #endif @@ -1213,7 +1213,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ + EL1_fx = L_mac0_sat( EL1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qIn) */ #else EL1_fx = L_mac0_o( EL1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qIn) */ #endif @@ -1233,7 +1233,7 @@ void nelp_encoder_ivas_fx( FOR( i = 0; i < L_FRAME; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ + EH1_fx = L_mac0_sat( EH1_fx, filtRes_fx[i], filtRes_fx[i] ); /*Q(2*qEH1) */ #else EH1_fx = L_mac0_o( EH1_fx, filtRes_fx[i], filtRes_fx[i], &Overflow ); /*Q(2*qEH1) */ #endif @@ -1252,7 +1252,7 @@ void nelp_encoder_ivas_fx( FOR( j = (Word16) ( i * lag ); j < (Word16) ( ( i + 1 ) * lag ); j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif @@ -1280,7 +1280,7 @@ void nelp_encoder_ivas_fx( FOR( j = i_mult( i, lag ); j < L_FRAME; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ + Ltemp = L_mac0_sat( Ltemp, in_fx[j], in_fx[j] ); /*Q(2*qGain) */ #else Ltemp = L_mac0_o( Ltemp, in_fx[j], in_fx[j], &Overflow ); /*Q(2*qGain) */ #endif diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 296bef2eb..fb07df485 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -110,7 +110,7 @@ static Word16 noise_est_ln_q8_fx( L_tmp = L_add_o( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ), &Overflow ); /* +1.0f */ #else - L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ + L_tmp = L_add_sat( L_enr, L_shl( (Word32) 1L, q_new_plus_q_scale ) ); /* +1.0f */ #endif if ( flag_add1p0 == 0 ) { @@ -688,9 +688,9 @@ void noise_est_down_fx( FOR( i = min_band; i <= max_band; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ + totalNoise_temp = L_add_sat( totalNoise_temp, bckr[i] ); /*Q_new+QSCALE*/ #else - totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ + totalNoise_temp = L_add_o( totalNoise_temp, bckr[i], &Overflow ); /*Q_new+QSCALE*/ #endif } totalNoise_temp = L_max( totalNoise_temp, L_shl( e_min, 4 ) ); @@ -716,7 +716,7 @@ void noise_est_down_fx( FOR( i = 0; i < NB_BANDS; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); + Ltmp = L_add_sat( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ) ); #else Ltmp = L_add_o( L_shr_r( *pt1, 1 ), L_shr_r( *pt2, 1 ), &Overflow ); #endif @@ -1118,8 +1118,8 @@ void noise_est_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); - wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); #else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); @@ -1177,7 +1177,7 @@ void noise_est_fx( { Lnum = L_max( *pt1, *pt2 ); /* Don't need if anymore */ #ifdef ISSUE_1867_replace_overflow_libenc - Lsum_den = L_add_sat( Lsum_den, Lnum ); + Lsum_den = L_add_sat( Lsum_den, Lnum ); #else Lsum_den = L_add_o( Lsum_den, Lnum, &Overflow ); #endif @@ -1297,7 +1297,7 @@ void noise_est_fx( Ltmp = Mult_32_16( (Word32) 137438953L, tmp ); /* Q31(.064)+Q8+1-16 --> Q24 */ Ltmp = L_mac( Ltmp, 256, 24576 ); /* Q8+Q15(.75)+1 --> Q24 */ #ifdef ISSUE_1867_replace_overflow_libenc - alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ #else alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif @@ -1337,8 +1337,8 @@ void noise_est_fx( tmp_Q = add( Q_new, Q_SCALE ); Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ - L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ + L_tmp_enr = L_add_sat( enr[i], Ltmp ); /* enr scale dynamic */ + L_tmp_ave_enr = L_add_sat( hNoiseEst->ave_enr_fx[i], Ltmp ); /* ave__enr scale dynamic */ #else L_tmp_enr = L_add_o( enr[i], Ltmp, &Overflow ); /* enr scale dynamic */ L_tmp_ave_enr = L_add_o( hNoiseEst->ave_enr_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ @@ -1384,7 +1384,7 @@ void noise_est_fx( Ltmp = L_shl( (Word32) 1L, tmp_Q ); /* 1.0 added in the right dynamic domain */ /*L_tmp_enr = L_add(enr[i] , Ltmp );*/ /* enr scale dynamic , done above */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ + L_tmp_ave_enr2 = L_add_sat( hNoiseEst->ave_enr2_fx[i], Ltmp ); /* ave__enr scale dynamic */ #else L_tmp_ave_enr2 = L_add_o( hNoiseEst->ave_enr2_fx[i], Ltmp, &Overflow ); /* ave__enr scale dynamic */ #endif @@ -1420,7 +1420,7 @@ void noise_est_fx( log_enr16 = noise_est_ln_q8_fx( enr[i], 0, tmp_Q ); wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); #ifdef ISSUE_1867_replace_overflow_libenc - *non_staX = add_sat( *non_staX, wtmp ); + *non_staX = add_sat( *non_staX, wtmp ); #else *non_staX = add_o( *non_staX, wtmp, &Overflow ); #endif @@ -1440,7 +1440,7 @@ void noise_est_fx( move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( hNoiseEst->bckr_fx[i], 1, tmp_Q ); #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif @@ -1453,7 +1453,7 @@ void noise_est_fx( move16(); /* non dynamic init constant in Q8 */ tmp_floor = noise_est_ln_q8_fx( E_MIN_FX, 1, tmp_Q ); #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif @@ -1570,7 +1570,7 @@ void noise_est_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate*/ #ifdef ISSUE_1867_replace_overflow_libenc epsP_0_2 = round_fx_sat( L_shl_sat( Ltmp, 16 ) ); - /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ + /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #else epsP_0_2 = round_fx_o( L_shl_o( Ltmp, 16, &Overflow ), &Overflow ); /* Q12+16 -16 -> Q12 , NB saturation in Q12 sets max value to 7,999 */ #endif @@ -1740,7 +1740,7 @@ void noise_est_fx( Ltmp = L_mult( st_fx->voicing_fx[0], 16384 ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[1], 16384 ); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); + cor_tmp = mac_r_sat( Ltmp, corr_shift, MAX_16 ); #else cor_tmp = mac_ro( Ltmp, corr_shift, MAX_16, &Overflow ); #endif @@ -2468,8 +2468,8 @@ void noise_est_ivas_fx( Ltmp = L_deposit_h( corr_shift ); Ltmp = L_mac( Ltmp, st_fx->voicing_fx[0], 10923 ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); - wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); + Ltmp = L_mac_sat( Ltmp, st_fx->voicing_fx[1], 10923 ); + wtmp = mac_r_sat( Ltmp, st_fx->voicing_fx[2], 10923 ); #else Ltmp = L_mac_o( Ltmp, st_fx->voicing_fx[1], 10923, &Overflow ); wtmp = mac_ro( Ltmp, st_fx->voicing_fx[2], 10923, &Overflow ); @@ -2686,7 +2686,7 @@ void noise_est_ivas_fx( /* alpha = 0.064f * ftemp + 0.75f; */ Ltmp = Madd_32_16( 12582912 /* 0.75 in Q24*/, 137438953, tmp ); // Q24 #ifdef ISSUE_1867_replace_overflow_libenc - alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ + alpha = round_fx_sat( L_shl_sat( Ltmp, 7 ) ); /*Q24 +7 --> Q31 Q15*/ #else alpha = round_fx_o( L_shl_o( Ltmp, 7, &Overflow ), &Overflow ); /*Q24 +7 --> Q31 Q15*/ #endif @@ -2843,7 +2843,7 @@ void noise_est_ivas_fx( IF( LT_16( ini_frame, 100 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, LN_E_MIN_PLUS_ONE_FX ) ), &Overflow ); /* Q8 */ #endif @@ -2869,7 +2869,7 @@ void noise_est_ivas_fx( tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ } #ifdef ISSUE_1867_replace_overflow_libenc - non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ + non_staB = add_sat( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ) ); /* Q8 */ #else non_staB = add_o( non_staB, abs_s( sub( tmp_enr, tmp_floor ) ), &Overflow ); /* Q8 */ #endif diff --git a/lib_enc/normalizecoefs_fx.c b/lib_enc/normalizecoefs_fx.c index 3e2181cf3..1dcf6b6e2 100644 --- a/lib_enc/normalizecoefs_fx.c +++ b/lib_enc/normalizecoefs_fx.c @@ -58,7 +58,7 @@ void normalizecoefs_fx( move32(); } #ifdef ISSUE_1867_replace_overflow_libenc - *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ + *pcoefs16++ = round_fx_sat( L_shl_sat( *pcoefs++, 16 - k ) ); /* Q12 */ #else *pcoefs16++ = round_fx_o( L_shl_o( *pcoefs++, 16 - k, &Overflow ), &Overflow ); /* Q12 */ #endif diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index 74712802c..33dc719e1 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -992,7 +992,7 @@ void norm_corr_ivas_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); // (Q_new - 1) + (Q_new - h_e) + 1 + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); // (Q_new - 1) + (Q_new - h_e) + 1 #else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); // (Q_new - 1) + (Q_new - h_e) + 1 #endif @@ -1083,14 +1083,14 @@ void norm_corr_fx( /* Compute rounded down 1/sqrt(energy of xn[]) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( 1, xn[0], xn[0] ); + L_tmp = L_mac_sat( 1, xn[0], xn[0] ); #else L_tmp = L_mac_o( 1, xn[0], xn[0], &Overflow ); #endif FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); + L_tmp = L_mac_sat( L_tmp, xn[i], xn[i] ); #else L_tmp = L_mac_o( L_tmp, xn[i], xn[i], &Overflow ); #endif @@ -1113,7 +1113,7 @@ void norm_corr_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); + L_tmp = L_mac_sat( L_tmp, xn[i], excf[i] ); #else L_tmp = L_mac_o( L_tmp, xn[i], excf[i], &Overflow ); #endif @@ -1128,7 +1128,7 @@ void norm_corr_fx( FOR( i = 1; i < L_subfr; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); + L_tmp = L_mac_sat( L_tmp, excf[i], excf[i] ); #else L_tmp = L_mac_o( L_tmp, excf[i], excf[i], &Overflow ); #endif diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index bf363009f..88393a514 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -85,8 +85,8 @@ void pitch_ol2_fx( FOR( t = t_min; t <= t_max; t++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - t0 = L_shl_sat( *pt_cor_32++, exp3 ); - *pt_cor_fx++ = round_fx_sat( t0 ); + t0 = L_shl_sat( *pt_cor_32++, exp3 ); + *pt_cor_fx++ = round_fx_sat( t0 ); #else t0 = L_shl_o( *pt_cor_32++, exp3, &Overflow ); *pt_cor_fx++ = round_fx_o( t0, &Overflow ); @@ -197,7 +197,7 @@ void pitch_ol2_fx( R2 = L_shl( R2, exp_R2 ); #ifdef ISSUE_1867_replace_overflow_libenc - R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); + R1 = L_mult_sat( round_fx_sat( R1 ), round_fx_sat( R2 ) ); #else R1 = L_mult_o( round_fx_o( R1, &Overflow ), round_fx_o( R2, &Overflow ), &Overflow ); #endif @@ -211,7 +211,7 @@ void pitch_ol2_fx( R1 = Isqrt_lc( R1, &exp_R1 ); #ifdef ISSUE_1867_replace_overflow_libenc - R1 = L_mult( R0, round_fx_sat( R1 ) ); + R1 = L_mult( R0, round_fx_sat( R1 ) ); #else R1 = L_mult( R0, round_fx_o( R1, &Overflow ) ); #endif @@ -219,7 +219,7 @@ void pitch_ol2_fx( exp_R0 = sub( add( exp_R0, exp_R1 ), exp3 ); #ifdef ISSUE_1867_replace_overflow_libenc - *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ + *voicing_fr_fx = round_fx_sat( L_shl_sat( R1, exp_R0 ) ); /*Q15*/ #else *voicing_fr_fx = round_fx_o( L_shl_o( R1, exp_R0, &Overflow ), &Overflow ); /*Q15*/ #endif @@ -318,7 +318,7 @@ void StableHighPitchDetect_fx( diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -331,7 +331,7 @@ void StableHighPitchDetect_fx( diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -341,7 +341,7 @@ void StableHighPitchDetect_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); #else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); #endif @@ -422,7 +422,7 @@ void StableHighPitchDetect_fx( cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = 31 - ( shl( Q_new, 1 ) + 1 ) - ( 31 - exp ) + 31; #ifdef ISSUE_1867_replace_overflow_libenc - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ #else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ #endif @@ -553,7 +553,7 @@ void StableHighPitchDetect_ivas_fx( diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -566,7 +566,7 @@ void StableHighPitchDetect_ivas_fx( diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #ifdef ISSUE_1867_replace_overflow_libenc BASOP_SATURATE_WARNING_ON_EVS - diff16 = round_fx_sat( diff ); + diff16 = round_fx_sat( diff ); #else BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); @@ -576,7 +576,7 @@ void StableHighPitchDetect_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); + diff16 = round_fx_sat( L_shl_sat( diff, 25 ) ); #else diff16 = round_fx_o( L_shl_o( diff, 25, &Overflow ), &Overflow ); #endif @@ -666,7 +666,7 @@ void StableHighPitchDetect_ivas_fx( cor_max = Mult_32_32( cor_max, L_tmp1 ); exp = add( sub( sub( 31, add( shl( Q_new, 1 ), 1 ) ), sub( 31, exp ) ), 31 ); #ifdef ISSUE_1867_replace_overflow_libenc - cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ + cor_max16 = round_fx_sat( L_shl_sat( cor_max, exp ) ); /*Q15*/ #else cor_max16 = round_fx_o( L_shl_o( cor_max, exp, &Overflow ), &Overflow ); /*Q15*/ #endif diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index a73cdc19a..5f8147e22 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -740,7 +740,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); + enr1 = add_sat( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1 ); #else enr1 = add_o( extract_h( dotp_fx( pt2, pt2, len[j], &enr1_exp ) ), 1, &Overflow ); #endif @@ -780,7 +780,7 @@ void pitch_ol_fx( enr1_exp = 0; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); + enr1 = add_sat( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1 ); #else enr1 = add_o( extract_h( dotp_fx( pt4, pt4, len1[j], &enr1_exp ) ), 1, &Overflow ); #endif @@ -879,7 +879,7 @@ void pitch_ol_fx( pitch_tmp[i] = pitchX[i][ind]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); #else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); #endif @@ -897,7 +897,7 @@ void pitch_ol_fx( pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); #else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); #endif @@ -1728,7 +1728,7 @@ void pitch_ol_ivas_fx( Ltmp = Mpy_32_16_1( enr1, cor_buf[ind] ); #ifdef ISSUE_1867_replace_overflow_libenc - corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 + corX[i][j] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind] ) ) ); // Q15 #else corX[i][j] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind] ), &Overflow ) ); // Q15 @@ -1776,7 +1776,7 @@ void pitch_ol_ivas_fx( Ltmp = Mpy_32_16_1( enr1, cor_buf[ind1 + len_x] ); #ifdef ISSUE_1867_replace_overflow_libenc - corX[i][j + NSECT] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ) ) ); // Q15 + corX[i][j + NSECT] = extract_h( L_shl_sat( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ) ) ); // Q15 #else corX[i][j + NSECT] = extract_h( L_shl_o( Ltmp, add( enr1_exp, cor_buf_exp[ind1 + len_x] ), &Overflow ) ); // Q15 #endif @@ -1857,7 +1857,7 @@ void pitch_ol_ivas_fx( pitch_tmp[i] = pitchX[i][ind]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); + cor_tmp[i] = add_sat( corX[i][ind], corr_shift ); #else cor_tmp[i] = add_o( corX[i][ind], corr_shift, &Overflow ); #endif @@ -1875,7 +1875,7 @@ void pitch_ol_ivas_fx( pitch_tmp[i + NHFR] = pitchX[i][ind1]; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); + cor_tmp[i + NHFR] = add_sat( corX[i][ind1], corr_shift ); #else cor_tmp[i + NHFR] = add_o( corX[i][ind1], corr_shift, &Overflow ); #endif diff --git a/lib_enc/ppp_enc_fx.c b/lib_enc/ppp_enc_fx.c index 6ab85d45e..515182aa8 100644 --- a/lib_enc/ppp_enc_fx.c +++ b/lib_enc/ppp_enc_fx.c @@ -666,9 +666,9 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); - corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); - temp = add_sat( temp, temp1 ); + corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); + corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); + temp = add_sat( temp, temp1 ); #else corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); @@ -684,8 +684,8 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X } #ifdef ISSUE_1867_replace_overflow_libenc - temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ - wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ + temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ + wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #else temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ @@ -694,7 +694,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X IF( GE_16( Qmaxcorr, Qcorr ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ + diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ #else diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ #endif @@ -702,7 +702,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ + diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ #else diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ #endif @@ -713,7 +713,7 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X fshift_fx = n; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ + maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ #else maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif @@ -801,9 +801,9 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc - Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ - Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ - Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ + Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ + Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ + Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ #else Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ @@ -831,8 +831,8 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc - Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ - Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ + Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ + Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ #else Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ @@ -852,7 +852,7 @@ static void LPCPowSpect_fx( Lacc = L_mult0( dh, dl ); #ifdef ISSUE_1867_replace_overflow_libenc - Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ + Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ #else Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif @@ -887,7 +887,7 @@ static void LPCPowSpect_fx( } Ltemp = L_deposit_h( tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); + out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); #else out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); #endif diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 85fff0ef4..fe53cacc3 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -88,8 +88,8 @@ static Word16 one_pulse_search( FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ - corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ + L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ + corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ #else L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ @@ -369,8 +369,8 @@ void pvq_encode_ivas_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ #else L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ @@ -584,8 +584,8 @@ void pvq_encode_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ - xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ #else L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ diff --git a/lib_enc/q_gain2p_fx.c b/lib_enc/q_gain2p_fx.c index d87ca122b..ed1eea4c1 100644 --- a/lib_enc/q_gain2p_fx.c +++ b/lib_enc/q_gain2p_fx.c @@ -168,7 +168,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc - *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ + *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ #else *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ #endif @@ -384,7 +384,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_sub_sat( L_tmp, dist_min ); + L_tmp1 = L_sub_sat( L_tmp, dist_min ); #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif @@ -408,7 +408,7 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ + L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ #else L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ #endif @@ -418,7 +418,7 @@ static Word16 gain_enc( /* o : quantization pitch index /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); #ifdef ISSUE_1867_replace_overflow_libenc - *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); + *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); #else *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); #endif @@ -616,7 +616,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif @@ -633,7 +633,7 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); + tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif diff --git a/lib_enc/qlpc_stoch_fx.c b/lib_enc/qlpc_stoch_fx.c index 96fe6a924..444f188f6 100644 --- a/lib_enc/qlpc_stoch_fx.c +++ b/lib_enc/qlpc_stoch_fx.c @@ -444,7 +444,7 @@ void Unified_weighting_fx( FOR( i = 95; i < 127; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ + L_tmp = L_add_sat( L_tmp, Bin_Ener_160_fx[i] ); /* Q_ener */ #else L_tmp = L_add_o( L_tmp, Bin_Ener_160_fx[i], &Overflow ); /* Q_ener */ #endif @@ -529,7 +529,7 @@ void Unified_weighting_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ + L_tmp = L_shl_sat( L_deposit_l( sub_sat( w_fft_fx[i], min_fx ) ), 13 ); /* Q21 */ #else L_tmp = L_shl_o( L_deposit_l( sub_o( w_fft_fx[i], min_fx, &Overflow ) ), 13, &Overflow ); /* Q21 */ #endif diff --git a/lib_enc/scale_enc_fx.c b/lib_enc/scale_enc_fx.c index 6337a7f5e..ab0492e6e 100644 --- a/lib_enc/scale_enc_fx.c +++ b/lib_enc/scale_enc_fx.c @@ -123,7 +123,7 @@ void Preemph_scaled( * finds the max of preemphasized signal */ L_tmp = L_mult( new_speech[i], QVal ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); #else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); #endif @@ -177,7 +177,7 @@ void Preemph_scaled( { L_tmp = L_mult( new_speech[i], QVal ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); + L_tmp = L_msu_sat( L_tmp, new_speech[i - 1], mu ); #else L_tmp = L_msu_o( L_tmp, new_speech[i - 1], mu, &Overflow ); #endif @@ -247,12 +247,12 @@ Word32 Scale_mem_pre_proc( /* o : Min energy scaled FOR( i = 0; i < NB_BANDS; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); - bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); - ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); - ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); - st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); - st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); + enrO[i] = L_max( L_shl_sat( enrO[i], Q_exp ), e_min_scaled ); + bckr[i] = L_max( L_shl_sat( bckr[i], Q_exp ), e_min_scaled ); + ave_enr[i] = L_max( L_shl_sat( ave_enr[i], Q_exp ), e_min_scaled ); + ave_enr2[i] = L_max( L_shl_sat( ave_enr2[i], Q_exp ), e_min_scaled ); + st_fr_bands1[i] = L_max( L_shl_sat( st_fr_bands1[i], Q_exp ), e_min_scaled ); + st_fr_bands2[i] = L_max( L_shl_sat( st_fr_bands2[i], Q_exp ), e_min_scaled ); #else enrO[i] = L_max( L_shl_o( enrO[i], Q_exp, &Overflow ), e_min_scaled ); bckr[i] = L_max( L_shl_o( bckr[i], Q_exp, &Overflow ), e_min_scaled ); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index e5dc9579a..68aadc1da 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -122,8 +122,8 @@ void set_impulse_fx( FOR( i = 0; i < L_SUBFR; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 - Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 + Lrr = L_mac_sat( Lrr, gh_fx[i], gh_fx[i] ); // Q27 + Ldd = L_mac_sat( Ldd, gh_fx[i], xn_fx[i] ); // Q27 #else Lrr = L_mac_o( Lrr, gh_fx[i], gh_fx[i], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[i], xn_fx[i], &Overflow ); // Q27 @@ -132,7 +132,7 @@ void set_impulse_fx( rr_fx[start1] = Lrr; move32(); #ifdef ISSUE_1867_replace_overflow_libenc - dd_fx[start1] = round_fx_sat( Ldd ); // Q11 + dd_fx[start1] = round_fx_sat( Ldd ); // Q11 #else dd_fx[start1] = round_fx_o( Ldd, &Overflow ); // Q11 #endif @@ -150,8 +150,8 @@ void set_impulse_fx( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[j] ); // Q13 move16(); #ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 - Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 + Lrr = L_mac_sat( Lrr, gh_fx[j], gh_fx[j] ); // Q27 + Ldd = L_mac_sat( Ldd, gh_fx[j], xn_fx[j] ); // Q27 #else Lrr = L_mac_o( Lrr, gh_fx[j], gh_fx[j], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[j], xn_fx[j], &Overflow ); // Q27 @@ -161,8 +161,8 @@ void set_impulse_fx( gh_fx[0] = mult_r( Glottal_cdbk_fx[m * L_IMPULSE + L_IMPULSE2 - i], h_orig_fx[0] ); // Q13 move16(); #ifdef ISSUE_1867_replace_overflow_libenc - Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 - Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 + Lrr = L_mac_sat( Lrr, gh_fx[0], gh_fx[0] ); // Q27 + Ldd = L_mac_sat( Ldd, gh_fx[0], xn_fx[0] ); // Q27 #else Lrr = L_mac_o( Lrr, gh_fx[0], gh_fx[0], &Overflow ); // Q27 Ldd = L_mac_o( Ldd, gh_fx[0], xn_fx[0], &Overflow ); // Q27 @@ -201,7 +201,7 @@ void set_impulse_fx( { /*rr[i] = rr[i+1] + gh[L_SUBFR+L_IMPULSE2-1-i]*gh[L_SUBFR+L_IMPULSE2-1-i];*/ #ifdef ISSUE_1867_replace_overflow_libenc - rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 + rr_fx[i] = L_mac_sat( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i] ); // Q27 #else rr_fx[i] = L_mac_o( rr_fx[i + 1], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], gh_fx[L_SUBFR + L_IMPULSE2 - 1 - i], &Overflow ); // Q27 #endif diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 9f71a8a66..76f2467a3 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -797,14 +797,14 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis FOR( i = LOWEST_FBIN; i < HIGHEST_FBIN; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sum_PS = L_add_sat( sum_PS, PS[i] ); + sum_PS = L_add_sat( sum_PS, PS[i] ); #else sum_PS = L_add_o( sum_PS, PS[i], &Overflow ); #endif } exp1 = norm_l( sum_PS ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); + tmp1 = round_fx_sat( L_shl( sum_PS, exp1 ) ); #else tmp1 = round_fx_o( L_shl( sum_PS, exp1 ), &Overflow ); #endif @@ -816,7 +816,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /*dPS[i] = (float)fabs(PS_norm[i] - st->past_PS[i]);*/ exp2 = norm_l( PS[i] ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); + tmp2 = round_fx_sat( L_shl( PS[i], exp2 ) ); #else tmp2 = round_fx_o( L_shl( PS[i], exp2 ), &Overflow ); #endif @@ -881,7 +881,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { exp1 = norm_l( L_add( dPS[i], 336 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); + tmp1 = round_fx_sat( L_shl_sat( L_add( dPS[i], 336 ), exp1 ) ); #else tmp1 = round_fx_o( L_shl_o( L_add( dPS[i], 336 ), exp1, &Overflow ), &Overflow ); #endif @@ -942,7 +942,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /**pFV = pSF[0] * *pFV + pSF[1];*/ #ifdef ISSUE_1867_replace_overflow_libenc - *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); + *pFV = round_fx_sat( L_shl_sat( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i] ) ); #else *pFV = round_fx_o( L_shl_o( L_mac( pSF_a[i], *pFV, pSF_m[i] ), ishift[i], &Overflow ), &Overflow ); #endif @@ -977,7 +977,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /* xm[p] = FV[p] - m_speech[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); + xm[p] = sub_sat( FV[p], m_speech_fx[k * N_FEATURES + p] ); #else xm[p] = sub_o( FV[p], m_speech_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -997,7 +997,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /*xm[p] = FV[p] - m_noise[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); + xm[p] = sub_sat( FV[p], m_noise_fx[k * N_FEATURES + p] ); #else xm[p] = sub_o( FV[p], m_noise_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -1016,7 +1016,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis { /*xm[p] = FV[p] - m_music[k*N_FEATURES+p];*/ #ifdef ISSUE_1867_replace_overflow_libenc - xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); + xm[p] = sub_sat( FV[p], m_music_fx[k * N_FEATURES + p] ); #else xm[p] = sub_o( FV[p], m_music_fx[k * N_FEATURES + p], &Overflow ); #endif @@ -1034,7 +1034,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis /* calculate log-probability */ /*log(0.0001)-0.5f * N_FEATURES * LOG_PI2 in Q9 */ #ifdef ISSUE_1867_replace_overflow_libenc - lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ + lps = extract_h( L_shl_sat( L_sub( max_s, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ #else lps = extract_h( L_shl_o( L_sub( max_s, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif @@ -1046,7 +1046,7 @@ static Word16 sp_mus_classif_gmm_fx( /* o : decis lpn = (float)log(pyn) - 0.5f * N_FEATURES * (float)log(2*PI); */ #ifdef ISSUE_1867_replace_overflow_libenc - lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ + lpn = extract_h( L_shl_sat( L_sub( max_n, LOG_PROB_CONST ), 16 - 1 ) ); /*Q9 */ #else lpn = extract_h( L_shl_o( L_sub( max_n, LOG_PROB_CONST ), 16 - 1, &Overflow ) ); /*Q9 */ #endif @@ -1524,7 +1524,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ #else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ #endif @@ -1553,7 +1553,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( i = 1; i < att_3lsub_pos; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i], Qx ) ); /*Qx */ #else L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #endif @@ -1569,7 +1569,7 @@ static Word16 attack_det_fx( /* o : attack flag FOR( i = 1; i < tmp1; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ + L_tmp = L_add_sat( L_tmp, L_shr_sat( finc[i + attack], Qx ) ); /*Qx */ #else L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #endif @@ -2694,7 +2694,7 @@ static Word16 attack_det_ivas_fx( /* o : attack flag FOR( j = 1; j < ATT_SEG_LEN; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ + L_tmp = L_mac0_sat( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j] ); /*2*Qx */ #else L_tmp = L_mac0_o( L_tmp, inp[i * ATT_SEG_LEN + j], inp[i * ATT_SEG_LEN + j], &Overflow ); /*2*Qx */ #endif diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 5cf653f62..b8936db2b 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -411,7 +411,7 @@ void swb_bwe_enc_ivas_fx( /* tilt returned in Q24 goto to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); #else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); #endif @@ -550,7 +550,7 @@ void swb_bwe_enc_ivas_fx( exp = sub( sub( 31, exp1 ), sub( 30, exp ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ #else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -696,7 +696,7 @@ void swb_bwe_enc_fx( /* tilt returned in Q24 goto to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); + tilt_nb_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3 ) ); #else tilt_nb_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( old_input_lp_fx, Q_slb_speech, st_fx->L_frame ), 3, &Overflow ), &Overflow ); #endif @@ -823,7 +823,7 @@ void swb_bwe_enc_fx( exp = add( 31 - 30, sub( exp, exp1 ) ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*31-exp */ #ifdef ISSUE_1867_replace_overflow_libenc - fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ + fb_ener_adjust_fx = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /*Q15 */ #else fb_ener_adjust_fx = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -1069,7 +1069,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class IF( hBWE_FD->prev_global_gain_fx == 0 ) { #ifdef ISSUE_1867_replace_overflow_libenc - gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ + gain_tmp = round_fx_sat( L_shl_sat( fGain, 30 ) ); /*Q14 */ #else gain_tmp = round_fx_o( L_shl_o( fGain, 30, &Overflow ), &Overflow ); /*Q14 */ #endif @@ -1190,7 +1190,7 @@ static Word16 FD_BWE_class_fx( /* o : FD BWE class tmp = div_s( shl( 1, sub( 14, expd ) ), den ); /*Q(29-expd-Q_syn) */ L_tmp = L_mult( tmp, peak ); /*Q(30-expd) */ #ifdef ISSUE_1867_replace_overflow_libenc - sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ + sharp = round_fx_sat( L_shl_sat( L_tmp, sub( expd, 4 ) ) ); /*Q10 */ #else sharp = round_fx_o( L_shl_o( L_tmp, sub( expd, 4 ), &Overflow ), &Overflow ); /*Q10 */ #endif @@ -1411,7 +1411,7 @@ static void vqWithCand_w_fx( FOR( i = 0; i < E_ROM_dico_size; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ + dist = sub_sat( x[0], *p_E_ROM_dico++ ); /*Q8 */ #else dist = sub_o( x[0], *p_E_ROM_dico++, &Overflow ); /*Q8 */ #endif @@ -1422,7 +1422,7 @@ static void vqWithCand_w_fx( FOR( j = 1; j < dim; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); + temp1 = sub_sat( x[j], *p_E_ROM_dico++ ); #else temp1 = sub_o( x[j], *p_E_ROM_dico++, &Overflow ); #endif @@ -1746,7 +1746,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM11; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); + quant_tmp[n_band] = add_sat( quant_tmp1[n_band], quant_tmp2[n_band] ); #else quant_tmp[n_band] = add_o( quant_tmp1[n_band], quant_tmp2[n_band], &Overflow ); #endif @@ -1756,7 +1756,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); /*Q8 */ #else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); /*Q8 */ #endif @@ -1783,7 +1783,7 @@ static void msvq_interpol_fx( FOR( n_band = 0; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); + tmp = add_sat( quant_tmp[n_band], quant_tmp[n_band + 1] ); #else tmp = add_o( quant_tmp[n_band], quant_tmp[n_band + 1], &Overflow ); #endif @@ -1909,13 +1909,13 @@ static void msvq_interpol_2_fx( FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); #else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); #endif tmp_q = shr( tmp_q, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc - quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); + quant_tmp2[n_band] = sub_sat( env_temp12[n_band], tmp_q ); #else quant_tmp2[n_band] = sub_o( env_temp12[n_band], tmp_q, &Overflow ); #endif @@ -1940,13 +1940,13 @@ static void msvq_interpol_2_fx( FOR( n_band = 1; n_band < DIM12 - 1; n_band++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); + tmp_q = add_sat( quant_tmp[n_band - 1], quant_tmp[n_band] ); #else tmp_q = add_o( quant_tmp[n_band - 1], quant_tmp[n_band], &Overflow ); #endif tmp_q = shr( tmp_q, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc - quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); + quant_select[( n_band << 1 ) - 1] = add_sat( quant_tmp2[n_band], tmp_q ); #else quant_select[( n_band << 1 ) - 1] = add_o( quant_tmp2[n_band], tmp_q, &Overflow ); #endif @@ -2122,7 +2122,7 @@ static void calculate_Tonality_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2147,7 +2147,7 @@ static void calculate_Tonality_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2290,7 +2290,7 @@ static void calculate_Tonality_ivas_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ + *SFM_org = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_org = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2315,7 +2315,7 @@ static void calculate_Tonality_ivas_fx( L_tmp = L_sub( L_tmp1, L_tmp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ + *SFM_gen = round_fx_sat( L_shl_sat( L_tmp, 14 ) ); /*Q12 */ #else *SFM_gen = round_fx_o( L_shl_o( L_tmp, 14, &Overflow ), &Overflow ); /*Q12 */ #endif @@ -2754,7 +2754,7 @@ static Word16 SWB_BWE_encoding_fx( /* tilt returned in Q24 go to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); #else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); #endif @@ -2862,7 +2862,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ #endif @@ -2878,7 +2878,7 @@ static Word16 SWB_BWE_encoding_fx( L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif @@ -3231,7 +3231,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( /* tilt returned in Q24 go to Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); + tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); #else tilt_fx = round_fx_o( L_shl_o( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3, &Overflow ), &Overflow ); #endif @@ -3340,7 +3340,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( expd = norm_l( WB_tenv_syn_fx ); #ifdef ISSUE_1867_replace_overflow_libenc - den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); + den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); #else den = round_fx_o( L_shl( WB_tenv_syn_fx, expd ), &Overflow ); #endif @@ -3357,7 +3357,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( L_tmp = Isqrt_lc( L_tmp, &expn ); /*31-expn */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, sub( expn, 1 ) ) ); /*Q14 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, sub( expn, 1 ), &Overflow ), &Overflow ); /*Q14 */ #endif @@ -3372,7 +3372,7 @@ static Word16 SWB_BWE_encoding_ivas_fx( { L_tmp = L_mult( Rat_tenv_fx, 19661 ); /*Q29 */ #ifdef ISSUE_1867_replace_overflow_libenc - Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ + Rat_tenv_fx = round_fx_sat( L_shl_sat( L_tmp, 2 ) ); /*Q15 */ #else Rat_tenv_fx = round_fx_o( L_shl_o( L_tmp, 2, &Overflow ), &Overflow ); /*Q15 */ #endif diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index 54528e2b4..6541b30fa 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -771,7 +771,7 @@ void swb_bwe_enc_hr_fx( L_tmp = L_mult( temp, t_audio_fx[i] ); L_tmp = L_shr_sat( L_tmp, temp2 ); #ifdef ISSUE_1867_replace_overflow_libenc - t_audio_fx[i] = round_fx_sat( L_tmp ); + t_audio_fx[i] = round_fx_sat( L_tmp ); #else t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); #endif diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index bdb956283..ad178ab55 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -786,8 +786,8 @@ static void gethar_noisegn_fx( L_temp = Mpy_32_16_1( L_temp, 19728 ); /* log(2)/log(10)=.30102999566398119521 = 19728.3(Q16) Q(0+16+1)=Q17 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ - g_fx = round_fx_sat( L_temp ); + L_temp = L_shl_sat( L_temp, 13 ); /* Q17+13=30 30-16=14 */ + g_fx = round_fx_sat( L_temp ); #else L_temp = L_shl_o( L_temp, 13, &Overflow ); /* Q17+13=30 30-16=14 */ g_fx = round_fx_o( L_temp, &Overflow ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index b1561ba51..490d80aae 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -1217,8 +1217,8 @@ void wb_tbe_enc_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); - tmp = round_fx_sat( L_tmp ); /* Q15 */ + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); + tmp = round_fx_sat( L_tmp ); /* Q15 */ #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ @@ -1389,7 +1389,7 @@ void wb_tbe_enc_ivas_fx( { L_tmp = L_mult( hb_old_speech[i], ola_win_shb_switch_fold_fx[j] ); #ifdef ISSUE_1867_replace_overflow_libenc - hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); + hb_old_speech[i] = mac_r_sat( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j] ); #else hb_old_speech[i] = mac_ro( L_tmp, hb_speech[k], ola_win_shb_switch_fold_fx[L_SUBFR16k - 4 - j], &Overflow ); #endif @@ -1881,8 +1881,8 @@ void wb_tbe_enc_ivas_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), voicingBufAvg_fx ); /* (14-exp) */ L_tmp = L_mult( pitBufAvg_fx, tmp ); /* (21-exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); - tmp = round_fx_sat( L_tmp ); /* Q15 */ + L_tmp = L_shl_sat( L_tmp, add( exp, 10 ) ); + tmp = round_fx_sat( L_tmp ); /* Q15 */ #else L_tmp = L_shl_o( L_tmp, add( exp, 10 ), &Overflow ); tmp = round_fx_o( L_tmp, &Overflow ); /* Q15 */ @@ -2540,8 +2540,8 @@ void swb_tbe_enc_fx( FOR( i = 0; i < L_SHB_LAHEAD + 10; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ - curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ + prev_pow_fx = L_mac0_sat( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i] ); /* 2*Q_bwe_exc */ + curr_pow_fx = L_mac0_sat( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10] ); /* 2*Q_bwe_exc */ #else prev_pow_fx = L_mac0_o( prev_pow_fx, shaped_shb_excitation_fx[i], shaped_shb_excitation_fx[i], &Overflow ); /* 2*Q_bwe_exc */ curr_pow_fx = L_mac0_o( curr_pow_fx, shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], shaped_shb_excitation_fx[i + L_SHB_LAHEAD + 10], &Overflow ); /* 2*Q_bwe_exc */ @@ -2581,7 +2581,7 @@ void swb_tbe_enc_fx( { tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -2589,7 +2589,7 @@ void swb_tbe_enc_fx( Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -2602,7 +2602,7 @@ void swb_tbe_enc_fx( { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -2610,7 +2610,7 @@ void swb_tbe_enc_fx( Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -2845,7 +2845,7 @@ void swb_tbe_enc_fx( L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ #else tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif @@ -3901,7 +3901,7 @@ void swb_tbe_enc_ivas_fx( { L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q(16-exp+Q_bwe_exc) */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -3923,7 +3923,7 @@ void swb_tbe_enc_ivas_fx( { tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -3931,7 +3931,7 @@ void swb_tbe_enc_ivas_fx( L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -3944,7 +3944,7 @@ void swb_tbe_enc_ivas_fx( { tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), tmp ); /* Q31-exp */ #else L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ #endif @@ -3952,7 +3952,7 @@ void swb_tbe_enc_ivas_fx( L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ #ifdef ISSUE_1867_replace_overflow_libenc - shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ #else shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ #endif @@ -4465,7 +4465,7 @@ void swb_tbe_enc_ivas_fx( L_tmp = Mult_32_16( L_tmp, pitBufAvg_fx ); /* Q13 * Q10 + 1 -16 => Q8 */ L_tmp = Mult_32_16( L_tmp, tmp ); /* Q8 + (14 - exp) - 15 => Q7 - exp */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ + tmp = round_fx_sat( L_shl_sat( L_tmp, 31 - ( 7 - exp ) ) ); /* Q15 */ #else tmp = round_fx_o( L_shl_o( L_tmp, 31 - ( 7 - exp ), &Overflow ), &Overflow ); /* Q15 */ #endif @@ -4739,10 +4739,10 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB */ #else sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ @@ -4754,9 +4754,9 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ - sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ @@ -4768,10 +4768,10 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB */ #else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ @@ -4788,8 +4788,8 @@ static void EstimateSHBFrameGain_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -4798,8 +4798,8 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ + sig = shl_sat( oriSHB[i], scaling ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = shl_sat( oriSHB[i], scaling ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -4808,8 +4808,8 @@ static void EstimateSHBFrameGain_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -4965,10 +4965,10 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ + sig = mult_r_sat( oriSHB[i], win_shb[i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_orisHB*/ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[i] ) ); /*Q_synSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_synSHB - 2*/ #else sig = mult_ro( oriSHB[i], win_shb[i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_orisHB*/ @@ -4980,9 +4980,9 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ - sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ + oriNrg = L_mac0_sat( oriNrg, oriSHB[i], oriSHB[i] ); /* 2*Q_oriSHB */ + sig = round_fx_sat( mod_syn[i] ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ #else oriNrg = L_mac0_o( oriNrg, oriSHB[i], oriSHB[i], &Overflow ); /* 2*Q_oriSHB */ sig = round_fx_o( mod_syn[i], &Overflow ); /* Q_oriSHB */ @@ -4994,10 +4994,10 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ - sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ + sig = mult_r_sat( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i] ); /* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB */ + sig = round_fx_sat( Mult_32_16( mod_syn[i], win_shb[l_frame + l_shb_lahead - 1 - i] ) ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2*Q_oriSHB - 2*/ #else sig = mult_ro( oriSHB[i], win_shb[l_frame + l_shb_lahead - 1 - i], &Overflow ); /* Q_oriSHB */ oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB */ @@ -5014,8 +5014,8 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( i = 0; i < l_shb_lahead; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -5024,8 +5024,8 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < l_frame; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = shl_sat( oriSHB[i], scaling ); - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ + sig = shl_sat( oriSHB[i], scaling ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = shl_sat( oriSHB[i], scaling ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -5034,8 +5034,8 @@ static void EstimateSHBFrameGain_ivas_fx( FOR( ; i < tmp; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ + sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2*Q_oriSHB + 2*scaling */ #else sig = mult_r( shl_sat( oriSHB[i], scaling ), win_shb[l_frame + l_shb_lahead - 1 - i] ); oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2*Q_oriSHB + 2*scaling */ @@ -5277,9 +5277,9 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + k], subwin[k + 1] ); /* Q_oriSHB */ @@ -5291,9 +5291,9 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[length + j + k], 32767 ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ - sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ + sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[length + j + k], 32767 ); /* Q_oriSHB */ @@ -5305,9 +5305,9 @@ static void EstimateSHBGainShape_fx( { sig = mult_r( oriSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ #ifdef ISSUE_1867_replace_overflow_libenc - oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ + oriNrg = L_mac0_sat( oriNrg, sig, sig ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ - synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ + synNrg = L_mac0_sat( synNrg, sig, sig ); /* 2* Q_oriSHB */ #else oriNrg = L_mac0_o( oriNrg, sig, sig, &Overflow ); /* 2* Q_oriSHB */ sig = mult_r( synSHB[j + join_length + k], subwin[length - k - 1] ); /* Q_oriSHB */ @@ -5360,8 +5360,8 @@ static void EstimateSHBGainShape_fx( FOR( i = 0; i < num_gains; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ - L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ + subgain[i] = round_fx_sat( L_shl_sat( L_subgain[i], sub( norm[i], n_max + 1 ) ) ); /* Q(14-n_max) */ + L_sum_gain = L_mac0_sat( L_sum_gain, subgain[i], subgain[i] ); /* Q(28-2*n_max) */ #else subgain[i] = round_fx_o( L_shl_o( L_subgain[i], sub( norm[i], n_max + 1 ), &Overflow ), &Overflow ); /* Q(14-n_max) */ L_sum_gain = L_mac0_o( L_sum_gain, subgain[i], subgain[i], &Overflow ); /* Q(28-2*n_max) */ @@ -5381,7 +5381,7 @@ static void EstimateSHBGainShape_fx( { L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ + subgain[i] = s_max( round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ), 3277 /*0.1f Q15*/ ); /* Q15 */ #else subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ #endif @@ -5394,7 +5394,7 @@ static void EstimateSHBGainShape_fx( { L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ #ifdef ISSUE_1867_replace_overflow_libenc - subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ + subgain[i] = round_fx_sat( L_shl_sat( L_tmp, add( n, n_max + 1 ) ) ); /* Q15 */ #else subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ #endif @@ -7059,7 +7059,7 @@ static void first_VQstages_fx( FOR( j = 0; j < N; j++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ + L_tmp1 = L_shl_sat( L_mult0( u[j], w[j] ), 7 ); /*x2.56 + Q8 + Q7 */ #else L_tmp1 = L_shl_o( L_mult0( u[j], w[j] ), 7, &Overflow ); /*x2.56 + Q8 + Q7 */ #endif @@ -7593,7 +7593,7 @@ void fb_tbe_enc_fx( Copy( tmp_vec + L_FRAME48k - Sample_Delay_HP, hBWE_TD->old_input_fhb_fx, Sample_Delay_HP ); temp2 = sum2_fx_mod( input_fhb, L_FRAME48k / 2 ); /* Q11 */ #ifdef ISSUE_1867_replace_overflow_libenc - temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ + temp2 = L_add_sat( temp2, L_shl_sat( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); /* Q11 */ #else temp2 = L_add_o( temp2, L_shl_o( hBWE_TD->prev_fb_energy_fx, sub( sub( add( exp_temp, exp_temp ), 6 ), hBWE_TD->prev_fb_energy_fx_Q ), &Overflow ), &Overflow ); /* Q11 */ #endif diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 64677b26c..a3d8620a4 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -525,7 +525,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra s2 = sub( s2, tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); #else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif @@ -535,7 +535,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra /* Quantize gain */ #ifdef ISSUE_1867_replace_overflow_libenc - g = shr( sub_sat( g, 0x1000 ), 13 ); + g = shr( sub_sat( g, 0x1000 ), 13 ); #else g = shr( sub_o( g, 0x1000, &Overflow ), 13 ); #endif @@ -586,7 +586,7 @@ static void tcx_ltp_find_gain_ivas_fx( Word16 *speech /*Qx*/, Word16 *pred_speec s2 = sub( s2, tmp ); #ifdef ISSUE_1867_replace_overflow_libenc - g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); + g = divide1616( round_fx_sat( corr ), round_fx_sat( ener ) ); #else g = divide1616( round_fx_o( corr, &Overflow ), round_fx_o( ener, &Overflow ) ); #endif @@ -810,14 +810,14 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); + speech_ltp[n] = sub_sat( speech[n], mult_r_sat( *gain, mult_r_sat( alpha, pred_speech[n] ) ) ); #else speech_ltp[n] = sub_o( speech[n], mult_ro( *gain, mult_ro( alpha, pred_speech[n], &Overflow ), &Overflow ), &Overflow ); #endif move16(); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - alpha = add_sat( alpha, step ); + alpha = add_sat( alpha, step ); #else alpha = add_o( alpha, step, &Overflow ); #endif @@ -872,7 +872,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); + speech_ltp[n] = add_sat( sub_sat( speech[n], mult_r_sat( *gain, pred_speech[n] ) ), zir[n] ); #else speech_ltp[n] = add_o( sub_o( speech[n], mult_ro( *gain, pred_speech[n], &Overflow ), &Overflow ), zir[n], &Overflow ); #endif @@ -894,7 +894,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on, FOR( n = L_subfr; n < L_frame; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); + speech_ltp[n] = sub_sat( speech[n], mult( *gain, pred_speech[n] ) ); #else speech_ltp[n] = sub_o( speech[n], mult( *gain, pred_speech[n] ), &Overflow ); #endif @@ -1239,7 +1239,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, mult_r_sat( alpha_fx, pred_speech_fx[n] ) ) ); #else speech_ltp_fx[n] = sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, mult_ro( alpha_fx, pred_speech_fx[n], &Overflow ), &Overflow ), &Overflow ); #endif @@ -1293,7 +1293,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = 0; n < L_subfr; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); + speech_ltp_fx[n] = add_sat( sub_sat( speech_fx[n], mult_r_sat( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ), zir_fx[n] ); #else speech_ltp_fx[n] = add_o( sub_o( speech_fx[n], mult_ro( hTcxEnc->tcxltp_gain, pred_speech_fx[n], &Overflow ), &Overflow ), zir_fx[n], &Overflow ); #endif @@ -1315,7 +1315,7 @@ void tcx_ltp_encode_ivas_fx( FOR( n = L_subfr; n < L_frame; n++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); + speech_ltp_fx[n] = sub_sat( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ) ); #else speech_ltp_fx[n] = sub_o( speech_fx[n], mult( hTcxEnc->tcxltp_gain, pred_speech_fx[n] ), &Overflow ); #endif diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index adb3f8b7f..b8f187205 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -299,7 +299,7 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 move32(); BASOP_SATURATE_WARNING_OFF_EVS /* Allow saturation, because threshold is being compared to powerSpec[i] below. */ #ifdef ISSUE_1867_replace_overflow_libenc - threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); + threshold = L_shl_sat( threshold, sub( 28, powerSpec_e ) ); #else threshold = L_shl_o( threshold, sub( 28, powerSpec_e ), &Overflow ); #endif @@ -308,7 +308,7 @@ static void detectLowpassFac( const Word32 *powerSpec, Word16 powerSpec_e, Word1 { /* compensate for bad side-lobe attenuation with asymmetric windows */ #ifdef ISSUE_1867_replace_overflow_libenc - threshold = L_shl_sat( threshold, 1 ); + threshold = L_shl_sat( threshold, 1 ); #else threshold = L_shl_o( threshold, 1, &Overflow ); #endif @@ -2759,7 +2759,7 @@ void tcx_noise_factor_ivas_fx( s = add( add( exp_sqErrorNrg, -15 ), s ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp4 = L_shl_sat( tmp4, s ); + tmp4 = L_shl_sat( tmp4, s ); #else tmp4 = L_shl_o( tmp4, s, &Overflow ); #endif diff --git a/lib_enc/tns_base_enc_fx.c b/lib_enc/tns_base_enc_fx.c index fc2a41a58..ce7a9074d 100644 --- a/lib_enc/tns_base_enc_fx.c +++ b/lib_enc/tns_base_enc_fx.c @@ -128,7 +128,7 @@ Word16 DetectTnsFilt_fx( STnsConfig const *pTnsConfig, /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); #else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); #endif @@ -499,7 +499,7 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur /* Check threshold HLM_MIN_NRG */ BASOP_SATURATE_WARNING_OFF_EVS; #ifdef ISSUE_1867_replace_overflow_libenc - tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); + tmp32 = L_sub( L_shl_sat( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ) ), 3277l /*HLM_MIN_NRG Q7*/ ); #else tmp32 = L_sub( L_shl_o( L_tmp, s_min( 31, sub( shift, 24 - 31 * 2 ) ), &Overflow ), 3277l /*HLM_MIN_NRG Q7*/ ); #endif diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index ba92b3d13..2e63fffec 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2218,7 +2218,7 @@ static void gain_trans_enc_fx( gscale = 7; move16(); #ifdef ISSUE_1867_replace_overflow_libenc - gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 ) ); /* Q7 */ #else gain_trans = extract_h( L_shl_o( gain_trans32, 16, &Overflow ) ); /* Q7 */ #endif @@ -2226,7 +2226,7 @@ static void gain_trans_enc_fx( IF( GT_32( L_abs( gain_trans32 ), 29862L ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ + gain_trans = extract_h( L_shl_sat( gain_trans32, 16 - 3 ) ); /* Q4 */ #else gain_trans = extract_h( L_shl_o( gain_trans32, 16 - 3, &Overflow ) ); /* Q4 */ #endif @@ -2263,7 +2263,7 @@ static void gain_trans_enc_fx( { /*exc[i] *= (*gain_trans);*/ #ifdef ISSUE_1867_replace_overflow_libenc - exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); + exc[i] = round_fx_sat( L_shl_sat( L_mult( exc[i], gain_trans ), tmp16 ) ); #else exc[i] = round_fx_o( L_shl_o( L_mult( exc[i], gain_trans ), tmp16, &Overflow ), &Overflow ); #endif @@ -2373,7 +2373,7 @@ void tc_classif_enc_fx( FOR( i = 1; i < len; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_sum = L_mac0_sat( L_sum, res[i], res[i] ); + L_sum = L_mac0_sat( L_sum, res[i], res[i] ); #else L_sum = L_mac0_o( L_sum, res[i], res[i], &Overflow ); #endif @@ -2390,8 +2390,8 @@ void tc_classif_enc_fx( test(); #ifdef ISSUE_1867_replace_overflow_libenc - IF( GT_32( temp2, L_shl_sat( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && - LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) + IF( GT_32( temp2, L_shl_sat( L_temp2, ( 31 - exp2 ) - ( 31 - exp ) ) ) && + LT_32( aver, L_shl_sat( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ) ) ) ) #else IF( GT_32( temp2, L_shl_o( L_temp2, ( 31 - exp2 ) - ( 31 - exp ), &Overflow ) ) && LT_32( aver, L_shl_o( L_temp1, ( 31 - exp_aver ) - ( 31 - exp ), &Overflow ) ) ) diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 951d3b840..9883d9fae 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -223,7 +223,7 @@ static void sign_thr_snr_acc_fx( BASOP_SATURATE_WARNING_OFF_EVS /* may saturate in BASOP */ #ifdef ISSUE_1867_replace_overflow_libenc *L_snr_sum = L_add_sat( *L_snr_sum, L_tmp ); - /* Q4 */ + /* Q4 */ #else *L_snr_sum = L_add_o( *L_snr_sum, L_tmp, &Overflow ); /* Q4 */ #endif @@ -1053,7 +1053,7 @@ Word16 wb_vad_fx( IF( LT_16( i, 2 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta1 ); /*Q13 */ + tmp = add_sat( tmp, delta1 ); /*Q13 */ #else tmp = add_o( tmp, delta1, &Overflow ); /*Q13 */ #endif @@ -1061,7 +1061,7 @@ Word16 wb_vad_fx( ELSE IF( LT_16( i, 7 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta2 ); /*Q13 */ + tmp = add_sat( tmp, delta2 ); /*Q13 */ #else tmp = add_o( tmp, delta2, &Overflow ); /*Q13 */ #endif @@ -1069,7 +1069,7 @@ Word16 wb_vad_fx( ELSE IF( LT_16( i, 18 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta3 ); /*Q13 */ + tmp = add_sat( tmp, delta3 ); /*Q13 */ #else tmp = add_o( tmp, delta3, &Overflow ); /*Q13 */ #endif @@ -1077,7 +1077,7 @@ Word16 wb_vad_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - tmp = add_sat( tmp, delta4 ); /*Q13 */ + tmp = add_sat( tmp, delta4 ); /*Q13 */ #else tmp = add_o( tmp, delta4, &Overflow ); /*Q13 */ #endif @@ -1089,7 +1089,7 @@ Word16 wb_vad_fx( if ( LT_16( i, 7 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ + tmp1 = add_sat( tmp, 3277 ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #else tmp1 = add_o( tmp, 3277, &Overflow ); /*.4 in Q13 ftmp1 = ftmp + 0.4f; */ #endif @@ -1177,7 +1177,7 @@ Word16 wb_vad_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ #else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif @@ -1185,7 +1185,7 @@ Word16 wb_vad_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*Q_new+QSCALE */ #else L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*Q_new+QSCALE */ #endif @@ -1283,7 +1283,7 @@ Word16 wb_vad_fx( } /*st_fx->snr_sum_vad_fx = 0.5f * st->snr_sum_vad + 0.5f * snr_sum_ol;*/ #ifdef ISSUE_1867_replace_overflow_libenc - hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ + hVAD->L_snr_sum_vad_fx = L_shr( L_add_sat( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol ), 1 ); /*Q4*/ #else hVAD->L_snr_sum_vad_fx = L_shr( L_add_o( hVAD->L_snr_sum_vad_fx, L_snr_sum_ol, &Overflow ), 1 ); /*Q4*/ #endif @@ -1401,7 +1401,7 @@ Word16 wb_vad_fx( move16(); L_tmp2 = Msub_32_16( (Word32) 614, L_snr_outlier, 20972 ); /* .6*1024= */ /* 0.6 Q26(Q10 in high word) - Q4*Q21+1 */ #ifdef ISSUE_1867_replace_overflow_libenc - tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ + tmp2 = round_fx( L_shl_sat( L_tmp2, 14 ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #else tmp2 = round_fx( L_shl_o( L_tmp2, 14, &Overflow ) ); /* Q10(high word)+ 14 -16 --> Q8*/ #endif @@ -2445,7 +2445,7 @@ Word16 wb_vad_ivas_fx( IF( LT_16( i, 3 ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ + L_accum_ener_L = L_add_sat( L_accum_ener_L, hNoiseEst->bckr_fx[i] ); /* hNoiseEst->q_bckr */ #else L_accum_ener_L = L_add_o( L_accum_ener_L, hNoiseEst->bckr_fx[i], &Overflow ); /* hNoiseEst->q_bckr */ #endif @@ -2453,7 +2453,7 @@ Word16 wb_vad_ivas_fx( ELSE { #ifdef ISSUE_1867_replace_overflow_libenc - L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ + L_accum_ener_H = L_add_sat( L_accum_ener_H, hNoiseEst->bckr_fx[i] ); /*hNoiseEst->q_bckr */ #else L_accum_ener_H = L_add_o( L_accum_ener_H, hNoiseEst->bckr_fx[i], &Overflow ); /*hNoiseEst->q_bckr */ #endif @@ -2471,7 +2471,7 @@ Word16 wb_vad_ivas_fx( } } /* end of band loop */ #ifdef ISSUE_1867_replace_overflow_libenc - L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 + L_snr_sum_HE_SAD = L_shl_sat( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ) ); // q_snr_sum_HE_SAD->q4 #else L_snr_sum_HE_SAD = L_shl_o( L_snr_sum_HE_SAD, sub( 4, q_snr_sum_HE_SAD ), &Overflow ); // q_snr_sum_HE_SAD->q4 #endif diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index f581c2244..8cafb40da 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -168,8 +168,8 @@ void vad_param_updt_fx( L_tmp = L_mac( L_tmp, st_fx->voicing_fx[1], 10923 ); L_tmp = L_mac( L_tmp, st_fx->voicing_fx[2], 10923 ); /*Q15 */ #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ - voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ + L_tmp = L_mac_sat( L_tmp, corr_shift_temp[i], 32767 ); /*Q15 */ + voice_tmp = round_fx_sat( L_tmp ); /*Q15 */ #else L_tmp = L_mac_o( L_tmp, corr_shift_temp[i], 32767, &Overflow ); /*Q15 */ voice_tmp = round_fx_o( L_tmp, &Overflow ); /*Q15 */ diff --git a/lib_enc/vbr_average_rate_fx.c b/lib_enc/vbr_average_rate_fx.c index 8989c782d..907b30209 100644 --- a/lib_enc/vbr_average_rate_fx.c +++ b/lib_enc/vbr_average_rate_fx.c @@ -261,7 +261,7 @@ void update_average_rate_fx( /*st->sum_of_rates += (hSC_VBR->core_brate / 1000.0f) * 10; */ L_tmp = L_shl( Mult_32_16( core_brate_fx, 20972 ), 7 ); /*Q13*/ #ifdef ISSUE_1867_replace_overflow_libenc - hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); + hSC_VBR->sum_of_rates_fx = L_add_sat( hSC_VBR->sum_of_rates_fx, L_tmp ); #else hSC_VBR->sum_of_rates_fx = L_add_o( hSC_VBR->sum_of_rates_fx, L_tmp, &Overflow ); #endif diff --git a/lib_enc/vlpc_2st_cod_fx.c b/lib_enc/vlpc_2st_cod_fx.c index e480092a3..3f56add39 100644 --- a/lib_enc/vlpc_2st_cod_fx.c +++ b/lib_enc/vlpc_2st_cod_fx.c @@ -60,7 +60,7 @@ Word16 vlpc_2st_cod_fx( /* output: number of allocated bits FOR( i = 1; i < M; i++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ + L_tmp = L_mac_sat( L_tmp, x[i], x[i] ); /*10Q21*/ #else L_tmp = L_mac_o( L_tmp, x[i], x[i], &Overflow ); /*10Q21*/ #endif diff --git a/lib_enc/voiced_enc_fx.c b/lib_enc/voiced_enc_fx.c index 7206ae674..ff40bce29 100644 --- a/lib_enc/voiced_enc_fx.c +++ b/lib_enc/voiced_enc_fx.c @@ -566,7 +566,7 @@ ivas_error ppp_voiced_encoder_fx( /* 5 in Q11, 0.65 in Q15 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q31 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) + if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 31, Qtmp ) ) ), 21299 ) ) ) #else if ( ( GT_32( res_enratio_fx, 10240 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 31, Qtmp ), &Overflow ) ), 21299 ) ) ) #endif @@ -581,7 +581,7 @@ ivas_error ppp_voiced_encoder_fx( /*3 in Q11, 1.2 in Q14 // L_shl(tmp_fx,sub(31,Qtmp)) makes tmp_fx FIXED Q14 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) + if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_sat( tmp_fx, sub( 30, Qtmp ) ) ), 19661 ) ) ) #else if ( ( GT_32( res_enratio_fx, 6144 ) ) && ( LT_16( extract_h( L_shl_o( tmp_fx, sub( 30, Qtmp ), &Overflow ) ), 19661 ) ) ) #endif @@ -600,7 +600,7 @@ ivas_error ppp_voiced_encoder_fx( /* if (res_enratio < 0.025) */ #ifdef ISSUE_1867_replace_overflow_libenc IF( LT_32( L_shl_sat( res_enratio_fx, 4 ), 819 ) ) - /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ + /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #else IF( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 819 ) ) /*0x0333 = 0.025 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif @@ -620,7 +620,7 @@ ivas_error ppp_voiced_encoder_fx( { /* if ( res_enratio < 0.092f) */ #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ + if ( LT_32( L_shl_sat( res_enratio_fx, 4 ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #else if ( LT_32( L_shl_o( res_enratio_fx, 4, &Overflow ), 3015 ) ) /*3015 = 0.092 in Q15, res_enratio_fx in Q15 after shl 4 */ #endif @@ -633,7 +633,7 @@ ivas_error ppp_voiced_encoder_fx( /* if (min(res_enratio, sp_enratio) < 0.075 && tmp < -0.5f)) : 2458 = 0.075 in Q15 */ test(); #ifdef ISSUE_1867_replace_overflow_libenc - if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) + if ( LT_32( L_min( L_shl_sat( res_enratio_fx, 4 ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) #else if ( LT_32( L_min( L_shl_o( res_enratio_fx, 4, &Overflow ), sp_enratio_fx ), 2458 ) && LT_32( tmp_fx, shl_sat( -1, sub( Qtmp, 1 ) ) ) ) @@ -774,7 +774,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); #else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); #endif @@ -802,7 +802,7 @@ ivas_error ppp_voiced_encoder_fx( Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_NQ_FX->Q, 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_NQ_FX = Q_prev_cw_en_fx */ #endif @@ -911,7 +911,7 @@ ivas_error ppp_voiced_encoder_fx( FOR( x_fx = 0; x_fx < 160; x_fx++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); + energy_impz_fx = L_add_sat( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ) ); #else energy_impz_fx = L_add_o( energy_impz_fx, L_mult0( impzo_fx[x_fx], impzo_fx[x_fx] ), &Overflow ); #endif @@ -929,7 +929,7 @@ ivas_error ppp_voiced_encoder_fx( move32(); Qadj = sub( hSC_VBR->Q_prev_cw_en_fx, shl( CURRP_Q_E_FX->Q, 1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ + Ltmp_32 = L_shl_sat( Ltmp_32, Qadj ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ #else Ltmp_32 = L_shl_o( Ltmp_32, Qadj, &Overflow ); /* shift left required to adjust Q of CURRP_Q_E_FX = Q_prev_cw_en_fx */ #endif @@ -997,7 +997,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); /* tmp in Q15 */ exp = sub( expb, expa ); /* ans = tmp*2^(exp) */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ + Ltemp_fx = L_shl_sat( tmp, add( exp, 12 ) ); /* make tmp Q27 */ #else Ltemp_fx = L_shl_o( tmp, add( exp, 12 ), &Overflow ); /* make tmp Q27 */ #endif @@ -1037,7 +1037,7 @@ ivas_error ppp_voiced_encoder_fx( tmp = div_s( fracb, fraca ); exp = sub( expb, expa ); #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ + Ltemp_fx = L_shl_sat( tmp, add( exp, 14 ) ); /* answer in Q29 */ #else Ltemp_fx = L_shl_o( tmp, add( exp, 14 ), &Overflow ); /* answer in Q29 */ #endif @@ -1109,7 +1109,7 @@ ivas_error ppp_voiced_encoder_fx( frac = Log2_norm_lc( L_tmp ); L_tmp = Mpy_32_16( exp, frac, 12330 ); /* L_tmp is always Q13 */ #ifdef ISSUE_1867_replace_overflow_libenc - Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ + Ltemp = L_shl_sat( L_tmp, 10 ); /* Ltemp is always Q23 */ #else Ltemp = L_shl_o( L_tmp, 10, &Overflow ); /* Ltemp is always Q23 */ #endif @@ -1310,7 +1310,7 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ { /* acc = L_sub(acc, L_mult(memory[j], coef[j])); */ #ifdef ISSUE_1867_replace_overflow_libenc - acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ + acc = L_msu_sat( acc, buf[j], b[j] ); /*Q13 */ #else acc = L_msu_o( acc, buf[j], b[j], &Overflow ); /*Q13 */ #endif @@ -1319,10 +1319,10 @@ static void synthesis_filter_fx( Word16 b[], Word16 x[], Word16 y[], Word16 buf[ } /* acc = L_sub(acc, L_mult(memory[0], coef[0])); */ #ifdef ISSUE_1867_replace_overflow_libenc - acc = L_msu_sat( acc, buf[0], b[0] ); - acc = L_shl_sat( acc, 3 ); - *y++ = round_fx_sat( acc ); - buf[0] = round_fx_sat( acc ); + acc = L_msu_sat( acc, buf[0], b[0] ); + acc = L_shl_sat( acc, 3 ); + *y++ = round_fx_sat( acc ); + buf[0] = round_fx_sat( acc ); #else acc = L_msu_o( acc, buf[0], b[0], &Overflow ); acc = L_shl_o( acc, 3, &Overflow ); @@ -1416,8 +1416,8 @@ static Word32 DTFS_freq_corr_fx( FOR( k = lk; k < hk; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ - corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k] ); /* Q(1) */ + corr_fx = L_mac0_sat( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k] ); /* Q(1) */ #else corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.a_fx[k], X2_DTFS_fx.a_fx[k], &Overflow ); /* Q(1) */ corr_fx = L_mac0_o( corr_fx, X1_DTFS_fx.b_fx[k], X2_DTFS_fx.b_fx[k], &Overflow ); /* Q(1) */ @@ -1432,7 +1432,7 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ + E1_fx = round_fx_sat( L_shl_sat( corr_fx, Qr ) ); /* Q(Qr-16) */ #else E1_fx = round_fx_o( L_shl_o( corr_fx, Qr, &Overflow ), &Overflow ); /* Q(Qr-16) */ #endif @@ -1450,7 +1450,7 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ + E1_fx = round_fx_sat( L_shl_sat( E_fx, q1 ) ); /* Q(1+q1-16) */ #else E1_fx = round_fx_o( L_shl_o( E_fx, q1, &Overflow ), &Overflow ); /* Q(1+q1-16) */ #endif @@ -1464,7 +1464,7 @@ static Word32 DTFS_freq_corr_fx( } #ifdef ISSUE_1867_replace_overflow_libenc - E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ + E2_fx = round_fx_sat( L_shl_sat( E_fx, q2 ) ); /* Q(1+q2-16) */ #else E2_fx = round_fx_o( L_shl_o( E_fx, q2, &Overflow ), &Overflow ); /* Q(1+q2-16) */ #endif @@ -1485,7 +1485,7 @@ static Word32 DTFS_freq_corr_fx( expa = norm_l( Num ); #ifdef ISSUE_1867_replace_overflow_libenc - fraca = extract_h( L_shl_sat( Num, expa ) ); + fraca = extract_h( L_shl_sat( Num, expa ) ); #else fraca = extract_h( L_shl_o( Num, expa, &Overflow ) ); #endif @@ -1494,7 +1494,7 @@ static Word32 DTFS_freq_corr_fx( expb = norm_l( Den ); #ifdef ISSUE_1867_replace_overflow_libenc - fracb = round_fx_sat( L_shl( Den, expb ) ); + fracb = round_fx_sat( L_shl( Den, expb ) ); #else fracb = round_fx_o( L_shl_o( Den, expb, &Overflow ), &Overflow ); #endif @@ -1563,7 +1563,7 @@ static Word16 DTFS_alignment_extract_td_fx( Word16 *x1, Word16 *x2, Word16 lag ) FOR( k = 0; k < lag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); + corr = L_mac_sat( corr, x1[k], x2[( k - j + lag ) % lag] ); #else corr = L_mac_o( corr, x1[k], x2[( k - j + lag ) % lag], &Overflow ); #endif @@ -1643,8 +1643,8 @@ static Word32 DTFS_getEngy_band_fx( FOR( k = lk; k < hk; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc - en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ - en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); /* 2*X1.Q+1 */ + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); #else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); /* 2*X1.Q+1 */ en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); @@ -1661,8 +1661,8 @@ static Word32 DTFS_getEngy_band_fx( IF( ( s_and( X_fx.lag_fx, 1 ) == 0 ) && ( hband == X_fx.upper_cut_off_freq_fx ) ) { #ifdef ISSUE_1867_replace_overflow_libenc - en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); - en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); + en_fx = L_mac0_sat( en_fx, X_fx.a_fx[k], X_fx.a_fx[k] ); + en_fx = L_mac0_sat( en_fx, X_fx.b_fx[k], X_fx.b_fx[k] ); #else en_fx = L_mac0_o( en_fx, X_fx.a_fx[k], X_fx.a_fx[k], &Overflow ); en_fx = L_mac0_o( en_fx, X_fx.b_fx[k], X_fx.b_fx[k], &Overflow ); -- GitLab From 180b81b15b0c38e1f4a78f07743f1373e9799c72 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 3 Sep 2025 14:55:38 +0200 Subject: [PATCH 80/80] clang format --- lib_enc/gain_enc_fx.c | 4 ++-- lib_enc/lsf_enc_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 035cde756..68d467f50 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -769,14 +769,14 @@ void gain_enc_SQ_fx( #ifdef FIX_1978_SAT_MISSING_IN_GAIN_ENC L_tmp1 = L_mult_sat( coeff[1], coeff[4] ); /*Q31*/ #else - L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ + L_tmp1 = L_mult( coeff[1], coeff[4] ); /*Q31*/ #endif exp1 = add( exp_coeff[1], exp_coeff[4] ); #ifdef FIX_1978_SAT_MISSING_IN_GAIN_ENC L_tmp2 = L_mult_sat( coeff[0], coeff[3] ); /*Q31*/ #else - L_tmp2 = L_mult( coeff[0], coeff[3] ); /*Q31*/ + L_tmp2 = L_mult( coeff[0], coeff[3] ); /*Q31*/ #endif exp2 = add( exp_coeff[0], exp_coeff[3] ); diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 06ad57535..8d6801bc5 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -2562,7 +2562,7 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( #ifdef FIX_1979_SAT_MISSING_IN_LSF_ENC L_tmp = L_mac_sat( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #else - L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ + L_tmp = L_mac( L_tmp, mult( diff[j], shl_sat( w[j], 1 ) ), diff[j] ); /*(2.56+Q5+ Q10 -Q15) + 2.56+ Q5 + Q1 = 2.56 + 2.56 + Q6 */ #endif } e[i] = L_tmp; -- GitLab