From 913763bf1c189c994d3f62cf94f2d33f2c006b0e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 26 Feb 2026 20:35:27 +0100 Subject: [PATCH 1/3] temporarily replace tcx_res_Q_spec_fx() by tcx_res_Q_spec_ivas_fx() --- lib_com/options.h | 1 + lib_enc/cod_tcx_fx.c | 8 ++++++++ lib_enc/prot_fx_enc.h | 3 ++- lib_enc/tcx_utils_enc_fx.c | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b921da142..a9aa9d345 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,6 +98,7 @@ #define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ #define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ #define FIX_MDCT_STEREO_ENC_STACK /* VA: basop issue 2428: Move IGF temporary buffers out of the highest stack */ +#define HARM_2454_TCX_RES_Q_SPEC /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 111805d42..71d22d2a8 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3585,11 +3585,19 @@ void QuantizeTCXSpectrum_fx( resQBits = tcx_res_Q_gain_fx( gain_tcx_opt_fx, gain_tcx_opt_e, gain_tcx_fx, gain_tcx_e, sqQ + L_spec, resQTargetBits ); IF( st->tcxonly ) { +#ifdef HARM_2454_TCX_RES_Q_SPEC + resQBits = tcx_res_Q_spec_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, NULL ); +#else resQBits = tcx_res_Q_spec_ivas_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, NULL ); +#endif } ELSE { +#ifdef HARM_2454_TCX_RES_Q_SPEC + resQBits = tcx_res_Q_spec_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, lf_deemph_fact_fx ); +#else resQBits = tcx_res_Q_spec_ivas_fx( x_orig_fx, x_orig_e, spectrum_fx, *spectrum_e, L_spec, *gain_tcx_fx, *gain_tcx_e, sqQ + L_spec, resQTargetBits, resQBits, st->hTcxCfg->sq_rounding, lf_deemph_fact_fx ); +#endif } } } diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 153c24b36..56694bd04 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1349,6 +1349,7 @@ Word16 tcx_res_Q_spec_fx( Word16 sq_round, const Word16 lf_deemph_factors[] ); +#ifndef HARM_2454_TCX_RES_Q_SPEC Word16 tcx_res_Q_spec_ivas_fx( Word32 *x_orig, Word16 x_orig_e, @@ -1362,7 +1363,7 @@ Word16 tcx_res_Q_spec_ivas_fx( Word16 bits, Word16 sq_round, const Word16 lf_deemph_factors[] ); - +#endif /* compute noise-measure flags for spectrum filling and quantization (0: tonal, 1: noise-like) */ void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 01fe7c1d5..1ada17a8f 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3388,6 +3388,7 @@ Word16 tcx_res_Q_gain_fx( return bits; } +#ifndef HARM_2454_TCX_RES_Q_SPEC Word16 tcx_res_Q_spec_fx( Word32 *x_orig, Word16 x_orig_e, @@ -3568,6 +3569,9 @@ Word16 tcx_res_Q_spec_fx( Word16 tcx_res_Q_spec_ivas_fx( +#else +Word16 tcx_res_Q_spec_fx( +#endif Word32 *x_orig, Word16 x_orig_e, Word32 *x_Q, -- GitLab From c7ccca6053be0e1c844611471de053a73ffde683 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 27 Feb 2026 11:37:15 +0100 Subject: [PATCH 2/3] simplified condition (taken from EVS version) --- lib_enc/tcx_utils_enc_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 1ada17a8f..2e74f9f03 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3593,7 +3593,9 @@ Word16 tcx_res_Q_spec_fx( Word16 c; Word32 thres; Word16 cmp_1, cmp_2; +#ifndef HARM_2454_TCX_RES_Q_SPEC Word32 tmp32_1, tmp32_2; +#endif /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3700,6 +3702,7 @@ Word16 tcx_res_Q_spec_fx( } thres = L_mult( c, lf_deemph_factor ); // Q31 +#ifndef HARM_2454_TCX_RES_Q_SPEC Word16 shift_tmp = s_max( sqGain_e, x_orig_e ); tmp1 = Mpy_32_16_1( thres, sqGain ); @@ -3707,6 +3710,11 @@ Word16 tcx_res_Q_spec_fx( tmp32_1 = L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ); tmp32_2 = L_shl( tmp1, sub( sqGain_e, shift_tmp ) ); IF( GT_32( tmp32_1, tmp32_2 ) ) +#else + tmp1 = L_shl( Mpy_32_16_1( thres, sqGain ), sub( sqGain_e, x_orig_e ) ); + + IF( GT_32( x_orig[i], tmp1 ) ) +#endif { prm[bits] = 1; move16(); @@ -3719,7 +3727,11 @@ Word16 tcx_res_Q_spec_fx( x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) ); move32(); } +#ifdef HARM_2454_TCX_RES_Q_SPEC + ELSE IF( L_add( x_orig[i], tmp1 ) < 0 ) +#else ELSE IF( L_add( tmp32_1, tmp32_2 ) < 0 ) +#endif { prm[bits] = 1; move16(); -- GitLab From 3a383ae0042c8eece230141716e98f602530052a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 27 Feb 2026 11:59:51 +0100 Subject: [PATCH 3/3] Revert "simplified condition (taken from EVS version)" This reverts commit c7ccca6053be0e1c844611471de053a73ffde683. --- lib_enc/tcx_utils_enc_fx.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 2e74f9f03..1ada17a8f 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3593,9 +3593,7 @@ Word16 tcx_res_Q_spec_fx( Word16 c; Word32 thres; Word16 cmp_1, cmp_2; -#ifndef HARM_2454_TCX_RES_Q_SPEC Word32 tmp32_1, tmp32_2; -#endif /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3702,7 +3700,6 @@ Word16 tcx_res_Q_spec_fx( } thres = L_mult( c, lf_deemph_factor ); // Q31 -#ifndef HARM_2454_TCX_RES_Q_SPEC Word16 shift_tmp = s_max( sqGain_e, x_orig_e ); tmp1 = Mpy_32_16_1( thres, sqGain ); @@ -3710,11 +3707,6 @@ Word16 tcx_res_Q_spec_fx( tmp32_1 = L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ); tmp32_2 = L_shl( tmp1, sub( sqGain_e, shift_tmp ) ); IF( GT_32( tmp32_1, tmp32_2 ) ) -#else - tmp1 = L_shl( Mpy_32_16_1( thres, sqGain ), sub( sqGain_e, x_orig_e ) ); - - IF( GT_32( x_orig[i], tmp1 ) ) -#endif { prm[bits] = 1; move16(); @@ -3727,11 +3719,7 @@ Word16 tcx_res_Q_spec_fx( x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) ); move32(); } -#ifdef HARM_2454_TCX_RES_Q_SPEC - ELSE IF( L_add( x_orig[i], tmp1 ) < 0 ) -#else ELSE IF( L_add( tmp32_1, tmp32_2 ) < 0 ) -#endif { prm[bits] = 1; move16(); -- GitLab