From 769277adf28e7c75ad5240845b3b3da609486970 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 20 Apr 2026 20:38:31 +0200 Subject: [PATCH 01/22] Issue 2551: creating switch --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index c09e1ff3d..227c6bd6e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -94,6 +94,7 @@ #define FIX_FLOAT_1539_G192_FORMAT_SWITCH /* VA/Nokia: reintroduce format switching for g192 bitstreams */ #define HARMONIZE_2499_CONFIGUREFDCNGDEC /* FhG: basop issue 2499: harmonoize configureFdCngDec */ #define FIX_BASOP_2530_IVAS_DECISION_MAT /* VA: Fix ambiguous usage of extract_l() */ +#define FIX_BASOP_2551_HARM_SCALAR_QUAN /* FhG: issue 2551: Harmonize function pair tcx_scalar_quantization_fx*/ /* #################### End BE switches ################################## */ -- GitLab From 9f849a7b879e003af09d81d504fc6978b0435e13 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Tue, 21 Apr 2026 11:12:48 +0200 Subject: [PATCH 02/22] Issue 2551: necessary changes for harmonization. removing old functions changing ivas variant. altering instances --- lib_com/prot_fx.h | 23 +++++++++-- lib_enc/cod_tcx_fx.c | 79 +++++++++++++++++++++++++++----------- lib_enc/prot_fx_enc.h | 2 + lib_enc/tcx_utils_enc_fx.c | 37 ++++++++++++++---- 4 files changed, 107 insertions(+), 34 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 54eb3d51a..b90a77714 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8617,17 +8617,32 @@ void ivas_mdct_core_reconstruct_fx( void ari_start_encoding_14bits_ivas_fx( Tastat *s ); - +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i: input coefficients */ + Word32* x, /* i: input coefficients */ Word16 x_e, /* i: exponent */ - Word16 *xq, /* o: quantized coefficients */ + Word16* xq, /* o: quantized coefficients */ Word16 L_frame, /* i: frame length */ Word16 gain, /* i: quantization gain */ Word16 gain_e, /* i: quantization gain exponent */ Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ + Word8 const* memQuantZeros_fx, /* i: coefficients to be set to 0 */ const Word16 alfe_flag ); +#else +void tcx_scalar_quantization_fx( + Word32* x, /* i: input coefficients */ + Word16 x_e, /* i: exponent */ + Word16* xq, /* o: quantized coefficients */ + Word16 L_frame, /* i: frame length */ + Word16 gain, /* i: quantization gain */ + Word16 gain_e, /* i: quantization gain exponent */ + Word16 offset, /* i: rounding offset (deadzone) */ + Word8 const* memQuantZeros_fx, /* i: coefficients to be set to 0 */ + const Word16 alfe_flag, + const Word16 element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + + Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 *x, /* Spectral coefficients Q0*/ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 72a8d01d3..acde002ef 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1436,14 +1436,25 @@ void QuantizeSpectrum_fx( shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e ); - - tcx_scalar_quantization_fx( OriginalSpectrum, OriginalSpectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly ); +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_fx(OriginalSpectrum, OriginalSpectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly ); +#else + tcx_scalar_quantization_fx(OriginalSpectrum, OriginalSpectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly, + st->element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + /* Estimate original bitrate */ stop = 0; @@ -1530,14 +1541,24 @@ void QuantizeSpectrum_fx( &sqGain_e ); /* Quantize spectrum */ - - tcx_scalar_quantization_fx( spectrum, *spectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly ); +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_fx(spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly ); +#else + tcx_scalar_quantization_fx(spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly, + st->element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* Estimate bitrate */ stop = 0; @@ -1717,15 +1738,27 @@ void QuantizeSpectrum_fx( { sqGain = tmp1; sqGain_e = s; +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_fx(spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly ); +#else + tcx_scalar_quantization_fx(spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly, + st->element_mode); - tcx_scalar_quantization_fx( spectrum, *spectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly ); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + move16(); stop = 1; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d59870610..76254e280 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1107,6 +1107,7 @@ Word16 SQ_gain_estimate_fx( Word16 *gain_e /* o : SQ gain exponent */ ); +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN void tcx_scalar_quantization_fx( Word32 *x, /* i : i coefficients */ Word16 x_e, /* i : exponent */ @@ -1117,6 +1118,7 @@ void tcx_scalar_quantization_fx( Word16 offset, /* i : rounding offset (deadzone) */ Word8 const *memQuantZeros, /* i : coefficients to be set to 0 */ const Word16 alfe_flag ); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN Word16 tcx_scalar_quantization_rateloop_fx( Word32 *x, /* i : i coefficients */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index db3c828d5..be5b1eb2c 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1259,7 +1259,7 @@ Word16 SQ_gain_estimate_fx( return tmp16; } - +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN void tcx_scalar_quantization_fx( Word32 *x, /* i : input coefficients */ Word16 x_e, /* i : exponent */ @@ -1333,18 +1333,32 @@ void tcx_scalar_quantization_fx( return; } +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN void tcx_scalar_quantization_ivas_fx( - Word32 *x, /* i : input coefficients exponent = x_e */ + Word32* x, /* i : input coefficients exponent = x_e */ Word16 x_e, /* i : exponent */ - Word16 *xq, /* o : quantized coefficients */ + Word16* xq, /* o : quantized coefficients */ Word16 L_frame, /* i : frame length */ Word16 gain, /* i : quantization gain exponent = gain_e */ Word16 gain_e, /* i : quantization gain exponent */ Word16 offset, /* i : rounding offset (deadzone) */ - Word8 const *memQuantZeros_fx, /* i : coefficients to be set to 0 */ + Word8 const* memQuantZeros_fx, /* i : coefficients to be set to 0 */ const Word16 alfe_flag ) +#else +void tcx_scalar_quantization_fx( + Word32* x, /* i : input coefficients exponent = x_e */ + Word16 x_e, /* i : exponent */ + Word16* xq, /* o : quantized coefficients */ + Word16 L_frame, /* i : frame length */ + Word16 gain, /* i : quantization gain exponent = gain_e */ + Word16 gain_e, /* i : quantization gain exponent */ + Word16 offset, /* i : rounding offset (deadzone) */ + Word8 const* memQuantZeros_fx, /* i : coefficients to be set to 0 */ + const Word16 alfe_flag, + const Word16 element_mode) +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN { Word16 i, tmp16, s; Word32 tmp32, offs32; @@ -1354,7 +1368,11 @@ void tcx_scalar_quantization_ivas_fx( /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e - +#ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN + IF(EQ_16(element_mode, EVS_MONO)) { + tmp16 = negate(s_max(tmp16, 0)); + } +#endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); IF( memQuantZeros_fx != NULL ) { @@ -1637,8 +1655,13 @@ Word16 tcx_scalar_quantization_rateloop_fx( } /* Quantize spectrum */ - tcx_scalar_quantization_fx( x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly ); +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); +#else + tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly, st->element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + /* Estimate bitrate */ stopFlag = 1; move16(); -- GitLab From e9153526d84abd3674c754ee4a6073e289af29e7 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Fri, 24 Apr 2026 10:40:59 +0200 Subject: [PATCH 03/22] Issue 2551: necessary changes for harmonization. Converting all instances of the function to the unified version. getting rid of some changes that became obsolete because of another merge !2965 --- lib_enc/cod_tcx_fx.c | 21 +++++++++++++++------ lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 6 +++++- lib_enc/tcx_utils_enc_fx.c | 19 ++++++++++++------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index a29cd0de7..5cb4481b5 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3091,9 +3091,11 @@ void QuantizeTCXSpectrum_fx( /* Quantize original spectrum */ sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, ( mult( hTcxEnc->tcx_target_bits_fac, shl( sqTargetBits, 1 ) ) ), L_spec, &sqGain_e ); - - tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); - +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly); +#else + tcx_scalar_quantization_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* Estimate original bitrate */ stop = 0; move16(); @@ -3184,8 +3186,11 @@ void QuantizeTCXSpectrum_fx( sqGain_fx = SQ_gain_ivas_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e ); } /* Quantize spectrum */ - tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); - +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly); +#else + tcx_scalar_quantization_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode); +#endif /* Estimate bitrate */ stop = 0; move16(); @@ -3454,8 +3459,12 @@ void QuantizeTCXSpectrum_fx( move16(); sqGain_e = 1; move16(); +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly); +#else + tcx_scalar_quantization_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); stop = 1; IF( st->element_mode > EVS_MONO ) { diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 31f337521..ab075db4a 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -969,7 +969,11 @@ static Word16 QuantSpecEstimateBits_fx( Word16 stop, sqBits, nEncoded; Word16 lastnz; - tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 ); +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + tcx_scalar_quantization_ivas_fx(spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1); +#else + tcx_scalar_quantization_fx(spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, IVAS_SCE); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN stop = 0; move16(); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index e734bafb9..687e3c4a0 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1665,13 +1665,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( } /* Quantize spectrum */ -#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); -#else - tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly, st->element_mode); -#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - - + tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); /* Estimate bitrate */ stopFlag = 1; move16(); @@ -2146,6 +2140,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( } /* Quantize spectrum */ +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR tcx_scalar_quantization_ivas_fx( x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly ); #else @@ -2158,6 +2153,9 @@ Word16 tcx_scalar_quantization_rateloop_fx( tcx_scalar_quantization_ivas_fx( x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly ); } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR +#else + tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly, element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* Estimate bitrate */ stopFlag = 1; move16(); @@ -2212,6 +2210,8 @@ Word16 tcx_scalar_quantization_rateloop_fx( IF( GE_16( tcxRateLoopOpt, 1 ) ) { +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + #ifndef FIX_BASOP_2546_HARMONIZE_TCX_SCALAR /* Quantize spectrum */ tcx_scalar_quantization_ivas_fx( x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly ); @@ -2226,6 +2226,11 @@ Word16 tcx_scalar_quantization_rateloop_fx( } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR +#else + tcx_scalar_quantization_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly, element_mode); +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + + /* Output */ *nEncoded = old_nEncoded; move16(); -- GitLab From 6d7ff73bab8a30f8a82aa13bdf933f2266aff213 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Fri, 24 Apr 2026 11:22:08 +0200 Subject: [PATCH 04/22] Issue 2551: Clang formatting patch --- lib_com/prot_fx.h | 15 ++-- lib_enc/cod_tcx_fx.c | 102 +++++++++++------------ lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 4 +- lib_enc/tcx_utils_enc_fx.c | 25 +++--- 4 files changed, 73 insertions(+), 73 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 020c984d0..40e43954e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8659,31 +8659,30 @@ void ari_start_encoding_14bits_ivas_fx( Tastat *s ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN void tcx_scalar_quantization_ivas_fx( - Word32* x, /* i: input coefficients */ + Word32 *x, /* i: input coefficients */ Word16 x_e, /* i: exponent */ - Word16* xq, /* o: quantized coefficients */ + Word16 *xq, /* o: quantized coefficients */ Word16 L_frame, /* i: frame length */ Word16 gain, /* i: quantization gain */ Word16 gain_e, /* i: quantization gain exponent */ Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const* memQuantZeros_fx, /* i: coefficients to be set to 0 */ + Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ const Word16 alfe_flag ); #else void tcx_scalar_quantization_fx( - Word32* x, /* i: input coefficients */ + Word32 *x, /* i: input coefficients */ Word16 x_e, /* i: exponent */ - Word16* xq, /* o: quantized coefficients */ + Word16 *xq, /* o: quantized coefficients */ Word16 L_frame, /* i: frame length */ Word16 gain, /* i: quantization gain */ Word16 gain_e, /* i: quantization gain exponent */ Word16 offset, /* i: rounding offset (deadzone) */ - Word8 const* memQuantZeros_fx, /* i: coefficients to be set to 0 */ + Word8 const *memQuantZeros_fx, /* i: coefficients to be set to 0 */ const Word16 alfe_flag, - const Word16 element_mode); + const Word16 element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( Word16 *x, /* Spectral coefficients Q0*/ const Word16 nt, /* L - size of spectrum (no. of spectral coefficients) Q0*/ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 27b77a219..e136f9b1d 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1446,22 +1446,22 @@ void QuantizeSpectrum_fx( #endif #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_fx(OriginalSpectrum, OriginalSpectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly ); + tcx_scalar_quantization_fx( OriginalSpectrum, OriginalSpectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly ); #else - tcx_scalar_quantization_fx(OriginalSpectrum, OriginalSpectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly, - st->element_mode); + tcx_scalar_quantization_fx( OriginalSpectrum, OriginalSpectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly, + st->element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN @@ -1559,22 +1559,22 @@ void QuantizeSpectrum_fx( /* Quantize spectrum */ #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_fx(spectrum, *spectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly ); + tcx_scalar_quantization_fx( spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly ); #else - tcx_scalar_quantization_fx(spectrum, *spectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly, - st->element_mode); + tcx_scalar_quantization_fx( spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly, + st->element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* Estimate bitrate */ @@ -1786,22 +1786,22 @@ void QuantizeSpectrum_fx( sqGain = tmp1; sqGain_e = s; #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_fx(spectrum, *spectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly ); + tcx_scalar_quantization_fx( spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly ); #else - tcx_scalar_quantization_fx(spectrum, *spectrum_e, - sqQ, - L_spec, - sqGain, sqGain_e, - hTcxCfg->sq_rounding, - hTcxEnc->memQuantZeros, - tcxonly, - st->element_mode); + tcx_scalar_quantization_fx( spectrum, *spectrum_e, + sqQ, + L_spec, + sqGain, sqGain_e, + hTcxCfg->sq_rounding, + hTcxEnc->memQuantZeros, + tcxonly, + st->element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN @@ -3114,9 +3114,9 @@ void QuantizeTCXSpectrum_fx( #endif #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly); + tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); #else - tcx_scalar_quantization_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode); + tcx_scalar_quantization_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* Estimate original bitrate */ stop = 0; @@ -3213,9 +3213,9 @@ void QuantizeTCXSpectrum_fx( } /* Quantize spectrum */ #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly); + tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); #else - tcx_scalar_quantization_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode); + tcx_scalar_quantization_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode ); #endif /* Estimate bitrate */ stop = 0; @@ -3486,9 +3486,9 @@ void QuantizeTCXSpectrum_fx( sqGain_e = 1; move16(); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_ivas_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly); + tcx_scalar_quantization_ivas_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly ); #else - tcx_scalar_quantization_fx(spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode); + tcx_scalar_quantization_fx( spectrum_fx, *spectrum_e, sqQ, L_spec, sqGain_fx, sqGain_e, st->hTcxCfg->sq_rounding, hTcxEnc->memQuantZeros, st->tcxonly, st->element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN stop = 1; diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index ab075db4a..bf7add7cb 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -970,9 +970,9 @@ static Word16 QuantSpecEstimateBits_fx( Word16 lastnz; #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tcx_scalar_quantization_ivas_fx(spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1); + tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 ); #else - tcx_scalar_quantization_fx(spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, IVAS_SCE); + tcx_scalar_quantization_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, IVAS_SCE ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN stop = 0; diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index de357e440..d21ca8a28 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1364,27 +1364,27 @@ void tcx_scalar_quantization_fx( #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN void tcx_scalar_quantization_ivas_fx( - Word32* x, /* i : input coefficients exponent = x_e */ + Word32 *x, /* i : input coefficients exponent = x_e */ Word16 x_e, /* i : exponent */ - Word16* xq, /* o : quantized coefficients */ + Word16 *xq, /* o : quantized coefficients */ Word16 L_frame, /* i : frame length */ Word16 gain, /* i : quantization gain exponent = gain_e */ Word16 gain_e, /* i : quantization gain exponent */ Word16 offset, /* i : rounding offset (deadzone) */ - Word8 const* memQuantZeros_fx, /* i : coefficients to be set to 0 */ + Word8 const *memQuantZeros_fx, /* i : coefficients to be set to 0 */ const Word16 alfe_flag ) #else void tcx_scalar_quantization_fx( - Word32* x, /* i : input coefficients exponent = x_e */ + Word32 *x, /* i : input coefficients exponent = x_e */ Word16 x_e, /* i : exponent */ - Word16* xq, /* o : quantized coefficients */ + Word16 *xq, /* o : quantized coefficients */ Word16 L_frame, /* i : frame length */ Word16 gain, /* i : quantization gain exponent = gain_e */ Word16 gain_e, /* i : quantization gain exponent */ Word16 offset, /* i : rounding offset (deadzone) */ - Word8 const* memQuantZeros_fx, /* i : coefficients to be set to 0 */ + Word8 const *memQuantZeros_fx, /* i : coefficients to be set to 0 */ const Word16 alfe_flag, - const Word16 element_mode) + const Word16 element_mode ) #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN { Word16 i, tmp16, s; @@ -1396,8 +1396,9 @@ void tcx_scalar_quantization_fx( tmp16 = sub( gain_e, x_e ); tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e #ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN - IF(EQ_16(element_mode, EVS_MONO)) { - tmp16 = negate(s_max(tmp16, 0)); + IF( EQ_16( element_mode, EVS_MONO ) ) + { + tmp16 = negate( s_max( tmp16, 0 ) ); } #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); @@ -1682,7 +1683,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( } /* Quantize spectrum */ - tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly); + tcx_scalar_quantization_fx( x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly ); /* Estimate bitrate */ stopFlag = 1; move16(); @@ -2171,7 +2172,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( } #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR #else - tcx_scalar_quantization_fx(x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly, element_mode); + tcx_scalar_quantization_fx( x, x_e, xq, L_frame, sqGain, sqGain_e, offset, memQuantZeros_fx, tcxonly, element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* Estimate bitrate */ stopFlag = 1; @@ -2244,7 +2245,7 @@ Word16 tcx_scalar_quantization_rateloop_fx( #endif // !FIX_BASOP_2546_HARMONIZE_TCX_SCALAR #else - tcx_scalar_quantization_fx(x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly, element_mode); + tcx_scalar_quantization_fx( x, x_e, xq, L_frame, *gain, *gain_e, offset, memQuantZeros_fx, tcxonly, element_mode ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN -- GitLab From 4f843203cadbeabe9ec530cb1a82aa77a871e5cb Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Fri, 24 Apr 2026 13:44:14 +0200 Subject: [PATCH 05/22] Issue 2551: Changing flag to EVS_MONO to fix errors with EVS case --- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index bf7add7cb..d062efbcd 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -972,7 +972,7 @@ static Word16 QuantSpecEstimateBits_fx( #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 ); #else - tcx_scalar_quantization_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, IVAS_SCE ); + tcx_scalar_quantization_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, EVS_MONO ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN stop = 0; -- GitLab From 007ada54dd3da86125b438ba14b2f2c8300e0e42 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Fri, 24 Apr 2026 15:58:54 +0200 Subject: [PATCH 06/22] Issue 2551: Changing some missed differences that caused errors in EVS cases. --- lib_enc/tcx_utils_enc_fx.c | 76 ++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index d21ca8a28..39d5ccbe2 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1394,7 +1394,18 @@ void tcx_scalar_quantization_fx( /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); - tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + +#else + if(EQ_16(element_mode, EVS_MONO)){ + tmp32 = L_shl(L_deposit_h(gain), s_max(-31, s_min(tmp16, 0))); + } + else { + tmp32 = L_shl_sat(L_deposit_h(gain), tmp16); // exp:x_e + } +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + + #ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN IF( EQ_16( element_mode, EVS_MONO ) ) { @@ -1430,24 +1441,67 @@ void tcx_scalar_quantization_fx( s = sub( add( x_e, gain_e ), 15 ); } +#ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN + if (EQ_16(element_mode, EVS_MONO)) { + offset = sub(offset, 0x4000); + } +#endif // FIX_BASOP_2551_HARM_SCALAR_QUAN + FOR( ; i >= 0; i-- ) - { - offs32 = Mpy_32_16_1( x[i], gain ); - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + { +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + offs32 = Mpy_32_16_1(x[i], gain); + offs32 = L_shl_sat(offs32, s); /* convert to 15Q16 */ - offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ - tmp16 = extract_h( offs32_1 ); - IF( x[i] < 0 ) + offs32_1 = L_add_sat(offs32, offset_Q16); /*15Q16 */ + tmp16 = extract_h(offs32_1); + IF(x[i] < 0) { - offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ - tmp16 = extract_h( offs32 ); - if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) + offs32 = L_sub_sat(offs32, offset_Q16); /*15Q16 */ + tmp16 = extract_h(offs32); + if (L_mac_sat(offs32, tmp16, -ONE_IN_Q15) > 0) { - tmp16 = add( tmp16, 1 ); + tmp16 = add(tmp16, 1); } } xq[i] = tmp16; move16(); +#else + if (EQ_16(element_mode, EVS_MONO)) + { + offs32 = Mpy_32_16_1(L_abs(x[i]), gain); /* multiply */ + offs32 = L_shl_sat(offs32, s); /* convert to 15Q16 */ + tmp16 = mac_r_sat(offs32, offset, 1); /* add offset and truncate */ + IF(x[i] < 0) + { + tmp16 = negate(tmp16); /* restore sign */ + } + + xq[i] = tmp16; + move16(); + } + else + { + offs32 = Mpy_32_16_1(x[i], gain); + offs32 = L_shl_sat(offs32, s); /* convert to 15Q16 */ + + offs32_1 = L_add_sat(offs32, offset_Q16); /*15Q16 */ + tmp16 = extract_h(offs32_1); + IF(x[i] < 0) + { + offs32 = L_sub_sat(offs32, offset_Q16); /*15Q16 */ + tmp16 = extract_h(offs32); + if (L_mac_sat(offs32, tmp16, -ONE_IN_Q15) > 0) + { + tmp16 = add(tmp16, 1); + } + } + xq[i] = tmp16; + move16(); + } +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN + + } IF( alfe_flag == 0 ) -- GitLab From 699a595eea69ed89ecc55a4cf6db8457ce52e61d Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Fri, 24 Apr 2026 16:01:12 +0200 Subject: [PATCH 07/22] Issue 2551: Clang formatting patch --- lib_enc/tcx_utils_enc_fx.c | 71 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 39d5ccbe2..0018367ff 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1395,17 +1395,19 @@ void tcx_scalar_quantization_fx( /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - + #else - if(EQ_16(element_mode, EVS_MONO)){ - tmp32 = L_shl(L_deposit_h(gain), s_max(-31, s_min(tmp16, 0))); + if ( EQ_16( element_mode, EVS_MONO ) ) + { + tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); } - else { - tmp32 = L_shl_sat(L_deposit_h(gain), tmp16); // exp:x_e + else + { + tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e } #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - + #ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN IF( EQ_16( element_mode, EVS_MONO ) ) { @@ -1442,39 +1444,40 @@ void tcx_scalar_quantization_fx( } #ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN - if (EQ_16(element_mode, EVS_MONO)) { - offset = sub(offset, 0x4000); + if ( EQ_16( element_mode, EVS_MONO ) ) + { + offset = sub( offset, 0x4000 ); } #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN FOR( ; i >= 0; i-- ) - { + { #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - offs32 = Mpy_32_16_1(x[i], gain); - offs32 = L_shl_sat(offs32, s); /* convert to 15Q16 */ + offs32 = Mpy_32_16_1( x[i], gain ); + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - offs32_1 = L_add_sat(offs32, offset_Q16); /*15Q16 */ - tmp16 = extract_h(offs32_1); - IF(x[i] < 0) + offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32_1 ); + IF( x[i] < 0 ) { - offs32 = L_sub_sat(offs32, offset_Q16); /*15Q16 */ - tmp16 = extract_h(offs32); - if (L_mac_sat(offs32, tmp16, -ONE_IN_Q15) > 0) + offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32 ); + if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) { - tmp16 = add(tmp16, 1); + tmp16 = add( tmp16, 1 ); } } xq[i] = tmp16; move16(); #else - if (EQ_16(element_mode, EVS_MONO)) + if ( EQ_16( element_mode, EVS_MONO ) ) { - offs32 = Mpy_32_16_1(L_abs(x[i]), gain); /* multiply */ - offs32 = L_shl_sat(offs32, s); /* convert to 15Q16 */ - tmp16 = mac_r_sat(offs32, offset, 1); /* add offset and truncate */ - IF(x[i] < 0) + offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ + IF( x[i] < 0 ) { - tmp16 = negate(tmp16); /* restore sign */ + tmp16 = negate( tmp16 ); /* restore sign */ } xq[i] = tmp16; @@ -1482,26 +1485,24 @@ void tcx_scalar_quantization_fx( } else { - offs32 = Mpy_32_16_1(x[i], gain); - offs32 = L_shl_sat(offs32, s); /* convert to 15Q16 */ + offs32 = Mpy_32_16_1( x[i], gain ); + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - offs32_1 = L_add_sat(offs32, offset_Q16); /*15Q16 */ - tmp16 = extract_h(offs32_1); - IF(x[i] < 0) + offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32_1 ); + IF( x[i] < 0 ) { - offs32 = L_sub_sat(offs32, offset_Q16); /*15Q16 */ - tmp16 = extract_h(offs32); - if (L_mac_sat(offs32, tmp16, -ONE_IN_Q15) > 0) + offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32 ); + if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) { - tmp16 = add(tmp16, 1); + tmp16 = add( tmp16, 1 ); } } xq[i] = tmp16; move16(); } #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - - } IF( alfe_flag == 0 ) -- GitLab From 47c3034c516da9efbc0d8b9a7be3296a67bfd9b2 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 10:05:52 +0200 Subject: [PATCH 08/22] Issue 2551: Making more changes in the function to see if the current errors originate from this part or other parts --- lib_enc/tcx_utils_enc_fx.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 0018367ff..b4e035119 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1415,16 +1415,43 @@ void tcx_scalar_quantization_fx( } #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); - IF( memQuantZeros_fx != NULL ) +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN + + IF(memQuantZeros_fx != NULL) { test(); - FOR( ; ( ( memQuantZeros_fx[i] != 0 ) && ( L_abs( x[i] ) < tmp32 ) ); i-- ) + FOR(; ((memQuantZeros_fx[i] != 0) && (L_abs(x[i]) < tmp32)); i--) + { + test(); + xq[i] = 0; + move16(); + } + } + +#else + if (EQ_16(element_mode, EVS_MONO)) { + test(); + WHILE((memQuantZeros_fx[i] != 0) && (LT_32(L_abs(L_shl(x[i], tmp16)), tmp32))) { test(); xq[i] = 0; move16(); + i = sub(i, 1); + } + } + else { + IF(memQuantZeros_fx != NULL) + { + test(); + FOR(; ((memQuantZeros_fx[i] != 0) && (L_abs(x[i]) < tmp32)); i--) + { + test(); + xq[i] = 0; + move16(); + } } } +#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN /* invert gain */ gain = Inv16( gain, &gain_e ); -- GitLab From 103519a13b42916b48c1a8e1f00f43100459eb4e Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 10:28:35 +0200 Subject: [PATCH 09/22] Issue 2551: Clang formatting patch --- lib_enc/tcx_utils_enc_fx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index b4e035119..82e646de7 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1417,10 +1417,10 @@ void tcx_scalar_quantization_fx( i = sub( L_frame, 1 ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - IF(memQuantZeros_fx != NULL) + IF( memQuantZeros_fx != NULL ) { test(); - FOR(; ((memQuantZeros_fx[i] != 0) && (L_abs(x[i]) < tmp32)); i--) + FOR( ; ( ( memQuantZeros_fx[i] != 0 ) && ( L_abs( x[i] ) < tmp32 ) ); i-- ) { test(); xq[i] = 0; @@ -1429,21 +1429,23 @@ void tcx_scalar_quantization_fx( } #else - if (EQ_16(element_mode, EVS_MONO)) { + if ( EQ_16( element_mode, EVS_MONO ) ) + { test(); - WHILE((memQuantZeros_fx[i] != 0) && (LT_32(L_abs(L_shl(x[i], tmp16)), tmp32))) + WHILE( ( memQuantZeros_fx[i] != 0 ) && ( LT_32( L_abs( L_shl( x[i], tmp16 ) ), tmp32 ) ) ) { test(); xq[i] = 0; move16(); - i = sub(i, 1); + i = sub( i, 1 ); } } - else { - IF(memQuantZeros_fx != NULL) + else + { + IF( memQuantZeros_fx != NULL ) { test(); - FOR(; ((memQuantZeros_fx[i] != 0) && (L_abs(x[i]) < tmp32)); i--) + FOR( ; ( ( memQuantZeros_fx[i] != 0 ) && ( L_abs( x[i] ) < tmp32 ) ); i-- ) { test(); xq[i] = 0; -- GitLab From 1906bc783f9c6f0bdcf4011efb86f32aed2f1a82 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 11:21:21 +0200 Subject: [PATCH 10/22] Issue 2551: Changing flag of a specific instance to see if it is possible to prevent further changes in other functions --- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index d062efbcd..bf7add7cb 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -972,7 +972,7 @@ static Word16 QuantSpecEstimateBits_fx( #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 ); #else - tcx_scalar_quantization_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, EVS_MONO ); + tcx_scalar_quantization_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, IVAS_SCE ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN stop = 0; -- GitLab From a5fb07b125a4106321ec5e5f116f14b11060c220 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 12:37:24 +0200 Subject: [PATCH 11/22] Issue 2551: Commenting potentials for future work --- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index bf7add7cb..13be061f8 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -972,6 +972,7 @@ static Word16 QuantSpecEstimateBits_fx( #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN tcx_scalar_quantization_ivas_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1 ); #else + // This flag could potentially be anything except EVS_MONO. In case of future errors consider passing down the flag from higher function calls. tcx_scalar_quantization_fx( spec_fx, spec_e, sqQ, length, G_fx, G_e, 16384 /*Q15*/, NULL, 1, IVAS_SCE ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN -- GitLab From 6392419a1efbc8710cc729cd6537cd6369ce32f8 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 12:46:50 +0200 Subject: [PATCH 12/22] Issue 2551: striving for minimal and possible invasive changes --- lib_enc/tcx_utils_enc_fx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 82e646de7..46fa033c8 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1395,16 +1395,9 @@ void tcx_scalar_quantization_fx( /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - + tmp32 = L_shl_sat(L_deposit_h(gain), tmp16); // exp:x_e #else - if ( EQ_16( element_mode, EVS_MONO ) ) - { - tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); - } - else - { - tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e - } + tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN -- GitLab From fead3d9fc499a7b793e538ec7633e6eab8b8dfc3 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 12:50:45 +0200 Subject: [PATCH 13/22] Issue 2551: Clang formatting patch --- lib_enc/tcx_utils_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 46fa033c8..cb210e700 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1395,7 +1395,7 @@ void tcx_scalar_quantization_fx( /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN - tmp32 = L_shl_sat(L_deposit_h(gain), tmp16); // exp:x_e + tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e #else tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN -- GitLab From 9cfb2a7fd620f36f746e8cfd0d93ec9f583a08d8 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 13:29:19 +0200 Subject: [PATCH 14/22] Issue 2551: further reducing changes to get a compact harmonized solution --- lib_enc/tcx_utils_enc_fx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index cb210e700..07da897d8 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1402,10 +1402,7 @@ void tcx_scalar_quantization_fx( #ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN - IF( EQ_16( element_mode, EVS_MONO ) ) - { tmp16 = negate( s_max( tmp16, 0 ) ); - } #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN -- GitLab From dbc08c4ac191b9177d7266a05b6f0020c8090c3e Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 13:33:17 +0200 Subject: [PATCH 15/22] Issue 2551: Clang formatting patch --- lib_enc/tcx_utils_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 07da897d8..f35985981 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1402,7 +1402,7 @@ void tcx_scalar_quantization_fx( #ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN - tmp16 = negate( s_max( tmp16, 0 ) ); + tmp16 = negate( s_max( tmp16, 0 ) ); #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); #ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN -- GitLab From 1a90f1b717767ef2c08cdb21d736a735fbc24216 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 14:13:04 +0200 Subject: [PATCH 16/22] Issue 2551: reducing changes further to achieve shorter harmonized function --- lib_enc/tcx_utils_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index f35985981..c4d8c60d8 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1405,7 +1405,7 @@ void tcx_scalar_quantization_fx( tmp16 = negate( s_max( tmp16, 0 ) ); #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); -#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN +#ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN IF( memQuantZeros_fx != NULL ) { -- GitLab From 6205f1d8d12812eab782b703a99b7343e8d275c5 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 16:51:58 +0200 Subject: [PATCH 17/22] Issue 2551: actualizing change that was verified using commit 1a90f1b7 --- lib_enc/tcx_utils_enc_fx.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index c4d8c60d8..de67bcf87 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1405,8 +1405,6 @@ void tcx_scalar_quantization_fx( tmp16 = negate( s_max( tmp16, 0 ) ); #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); -#ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN - IF( memQuantZeros_fx != NULL ) { test(); @@ -1418,33 +1416,6 @@ void tcx_scalar_quantization_fx( } } -#else - if ( EQ_16( element_mode, EVS_MONO ) ) - { - test(); - WHILE( ( memQuantZeros_fx[i] != 0 ) && ( LT_32( L_abs( L_shl( x[i], tmp16 ) ), tmp32 ) ) ) - { - test(); - xq[i] = 0; - move16(); - i = sub( i, 1 ); - } - } - else - { - IF( memQuantZeros_fx != NULL ) - { - test(); - FOR( ; ( ( memQuantZeros_fx[i] != 0 ) && ( L_abs( x[i] ) < tmp32 ) ); i-- ) - { - test(); - xq[i] = 0; - move16(); - } - } - } -#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - /* invert gain */ gain = Inv16( gain, &gain_e ); -- GitLab From ead99c7be1367983c7e0df85a7340623e49575ca Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 16:58:55 +0200 Subject: [PATCH 18/22] Issue 2551: trying to get the function even shorter by removing conditionals --- lib_enc/tcx_utils_enc_fx.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index de67bcf87..a69dcaef0 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1460,21 +1460,6 @@ void tcx_scalar_quantization_fx( xq[i] = tmp16; move16(); #else - if ( EQ_16( element_mode, EVS_MONO ) ) - { - offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ - IF( x[i] < 0 ) - { - tmp16 = negate( tmp16 ); /* restore sign */ - } - - xq[i] = tmp16; - move16(); - } - else - { offs32 = Mpy_32_16_1( x[i], gain ); offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ @@ -1491,7 +1476,6 @@ void tcx_scalar_quantization_fx( } xq[i] = tmp16; move16(); - } #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN } -- GitLab From bf485673a8f878bed9ba2dc8b0fd202246d814fe Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 17:01:29 +0200 Subject: [PATCH 19/22] Issue 2551: Clang formatting patch --- lib_enc/tcx_utils_enc_fx.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index a69dcaef0..cd4ec7602 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1460,22 +1460,22 @@ void tcx_scalar_quantization_fx( xq[i] = tmp16; move16(); #else - offs32 = Mpy_32_16_1( x[i], gain ); - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + offs32 = Mpy_32_16_1( x[i], gain ); + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ - tmp16 = extract_h( offs32_1 ); - IF( x[i] < 0 ) + offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32_1 ); + IF( x[i] < 0 ) + { + offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32 ); + if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) { - offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ - tmp16 = extract_h( offs32 ); - if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) - { - tmp16 = add( tmp16, 1 ); - } + tmp16 = add( tmp16, 1 ); } - xq[i] = tmp16; - move16(); + } + xq[i] = tmp16; + move16(); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN } -- GitLab From f3f1aa8ac92548f0b44f49152317247204123e7f Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 18:25:26 +0200 Subject: [PATCH 20/22] Revert "Issue 2551: Clang formatting patch" This reverts commit bf485673a8f878bed9ba2dc8b0fd202246d814fe. --- lib_enc/tcx_utils_enc_fx.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index cd4ec7602..a69dcaef0 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1460,22 +1460,22 @@ void tcx_scalar_quantization_fx( xq[i] = tmp16; move16(); #else - offs32 = Mpy_32_16_1( x[i], gain ); - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + offs32 = Mpy_32_16_1( x[i], gain ); + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ - tmp16 = extract_h( offs32_1 ); - IF( x[i] < 0 ) - { - offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ - tmp16 = extract_h( offs32 ); - if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) + offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32_1 ); + IF( x[i] < 0 ) { - tmp16 = add( tmp16, 1 ); + offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32 ); + if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) + { + tmp16 = add( tmp16, 1 ); + } } - } - xq[i] = tmp16; - move16(); + xq[i] = tmp16; + move16(); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN } -- GitLab From 1eb27907b8bf41016253d447a20be68e9fde0712 Mon Sep 17 00:00:00 2001 From: "Azizi, Arash" Date: Mon, 27 Apr 2026 18:25:27 +0200 Subject: [PATCH 21/22] Revert "Issue 2551: trying to get the function even shorter by removing conditionals" This reverts commit ead99c7be1367983c7e0df85a7340623e49575ca. --- lib_enc/tcx_utils_enc_fx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index a69dcaef0..de67bcf87 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1460,6 +1460,21 @@ void tcx_scalar_quantization_fx( xq[i] = tmp16; move16(); #else + if ( EQ_16( element_mode, EVS_MONO ) ) + { + offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ + IF( x[i] < 0 ) + { + tmp16 = negate( tmp16 ); /* restore sign */ + } + + xq[i] = tmp16; + move16(); + } + else + { offs32 = Mpy_32_16_1( x[i], gain ); offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ @@ -1476,6 +1491,7 @@ void tcx_scalar_quantization_fx( } xq[i] = tmp16; move16(); + } #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN } -- GitLab From a3ffdbe7e645c76a8e1dd144d9c8e7bd226872a3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 27 Apr 2026 20:29:32 +0200 Subject: [PATCH 22/22] few corrections --- lib_enc/tcx_utils_enc_fx.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index de67bcf87..201f07b23 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1398,12 +1398,9 @@ void tcx_scalar_quantization_fx( tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e #else tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); + tmp16 = negate( s_max( tmp16, 0 ) ); #endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN - -#ifdef FIX_BASOP_2551_HARM_SCALAR_QUAN - tmp16 = negate( s_max( tmp16, 0 ) ); -#endif // FIX_BASOP_2551_HARM_SCALAR_QUAN i = sub( L_frame, 1 ); IF( memQuantZeros_fx != NULL ) { @@ -1440,9 +1437,10 @@ void tcx_scalar_quantization_fx( } #endif // FIX_BASOP_2551_HARM_SCALAR_QUAN + +#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN FOR( ; i >= 0; i-- ) { -#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN offs32 = Mpy_32_16_1( x[i], gain ); offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ @@ -1459,13 +1457,17 @@ void tcx_scalar_quantization_fx( } xq[i] = tmp16; move16(); + } #else - if ( EQ_16( element_mode, EVS_MONO ) ) + IF( EQ_16( element_mode, EVS_MONO ) ) + { + FOR( ; i >= 0; i-- ) { offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ - IF( x[i] < 0 ) + + if ( x[i] < 0 ) { tmp16 = negate( tmp16 ); /* restore sign */ } @@ -1473,13 +1475,17 @@ void tcx_scalar_quantization_fx( xq[i] = tmp16; move16(); } - else + } + ELSE + { + FOR( ; i >= 0; i-- ) { offs32 = Mpy_32_16_1( x[i], gain ); offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ tmp16 = extract_h( offs32_1 ); + IF( x[i] < 0 ) { offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ @@ -1489,11 +1495,12 @@ void tcx_scalar_quantization_fx( tmp16 = add( tmp16, 1 ); } } + xq[i] = tmp16; move16(); } -#endif // !FIX_BASOP_2551_HARM_SCALAR_QUAN } +#endif IF( alfe_flag == 0 ) { -- GitLab