From 70388bf0358f4e8ea36a280c77eba71dab20b5d8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 19 Jun 2026 16:01:29 +0200 Subject: [PATCH 1/2] Simplify calculation of st->bits_frame_core in dec_prm_tcx(), align function name to float; also rename stereo_tcx_dec_mode_switch_reconf_ivas_fx() to stereo_tcx_dec_mode_switch_reconf_fx() --- lib_com/options.h | 1 + lib_dec/ivas_tcx_core_dec_fx.c | 54 ++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 708911c0f..fccc81623 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,6 +87,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define HARMONIZE_2502_GENERATE_COMFORT_NOISE_DEC /* FhG: harmonize generate_comfort_noise_dec_fx() and generate_comfort_noise_dec_ivas_fx() */ +#define FIX_BASOP_2650_DEC_PRM_TCX /* FhG: Simplify calculation of st->bits_frame_core in dec_prm_tcx(), align function name to float */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index f81d46d99..9827d03cf 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -43,8 +43,12 @@ * Local prototypes *-------------------------------------------------------------*/ +#ifdef FIX_BASOP_2650_DEC_PRM_TCX +static void dec_prm_tcx_fx( Decoder_State *st, Word16 param[], Word16 param_lpc[], Word16 *total_nbbits, const Word16 last_element_mode, Word16 *bitsRead ); +#else static void dec_prm_tcx_ivas_fx( Decoder_State *st, Word16 param[], Word16 param_lpc[], Word16 *total_nbbits, const Word16 last_element_mode, Word16 *bitsRead ); -static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, const Word16 MCT_flag, const Word16 last_element_mode, Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, Word16 *Q_syn_Overl_TDACFB, Word16 *Q_syn_OverlFB, Word16 *Q_old_out, Word16 *Q_old_outLB, Word16 *Q_old_Aq_12_8 ); +#endif +static void stereo_tcx_dec_mode_switch_reconf_fx( Decoder_State *st, const Word16 MCT_flag, const Word16 last_element_mode, Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, Word16 *Q_syn_Overl_TDACFB, Word16 *Q_syn_OverlFB, Word16 *Q_old_out, Word16 *Q_old_outLB, Word16 *Q_old_Aq_12_8 ); /*-------------------------------------------------------------* @@ -167,15 +171,15 @@ void stereo_tcx_init_dec_fx( Word16 Q_old_Aq_12_8 = 12; move16(); - stereo_tcx_dec_mode_switch_reconf_ivas_fx( st, MCT_flag, last_element_mode, - &st->hTcxDec->Q_syn_Overl_TDAC, - &st->hHQ_core->Q_fer_samples, - &st->hTcxDec->Q_syn_Overl, - &st->hTcxDec->Q_syn_Overl_TDACFB, - &st->hTcxDec->Q_syn_OverlFB, - &st->hHQ_core->Q_old_wtda, - &st->hHQ_core->Q_old_wtda_LB, - &Q_old_Aq_12_8 ); + stereo_tcx_dec_mode_switch_reconf_fx( st, MCT_flag, last_element_mode, + &st->hTcxDec->Q_syn_Overl_TDAC, + &st->hHQ_core->Q_fer_samples, + &st->hTcxDec->Q_syn_Overl, + &st->hTcxDec->Q_syn_Overl_TDACFB, + &st->hTcxDec->Q_syn_OverlFB, + &st->hHQ_core->Q_old_wtda, + &st->hHQ_core->Q_old_wtda_LB, + &Q_old_Aq_12_8 ); } return; @@ -311,7 +315,11 @@ void stereo_tcx_core_dec_fx( move16(); move16(); +#ifdef FIX_BASOP_2650_DEC_PRM_TCX + dec_prm_tcx_fx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead ); +#else dec_prm_tcx_ivas_fx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead ); +#endif } ELSE { @@ -893,7 +901,7 @@ void stereo_tcx_core_dec_fx( } -static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( +static void stereo_tcx_dec_mode_switch_reconf_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ const Word16 last_element_mode, /* i : element mode of previous frame Q0*/ @@ -936,7 +944,12 @@ static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( return; } + +#ifdef FIX_BASOP_2650_DEC_PRM_TCX +static void dec_prm_tcx_fx( +#else static void dec_prm_tcx_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder memory state */ Word16 param[], /* o : decoded parameters Q0*/ Word16 param_lpc[], /* o : LPC parameters Q0*/ @@ -958,8 +971,13 @@ static void dec_prm_tcx_ivas_fx( hm_cfg.indexBuffer = indexBuffer; IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { +#ifdef FIX_BASOP_2650_DEC_PRM_TCX + st->bits_frame_core = extract_l( L_sub( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ), st->next_bit_pos ) ); /* Q0 */ + assert( st->bits_frame_core == (int16_t) ( ( st->total_brate / FRAMES_PER_SEC ) - st->next_bit_pos ) ); +#else // The value of 1/ FRAMES_PER_SEC shifted left by 19 because taking Q as 15 led to precision loss st->bits_frame_core = extract_l( L_sub( L_shr( Mpy_32_16_1( st->total_brate, 10486 ), 4 ), st->next_bit_pos ) ); /* Q0 */ +#endif move16(); } start_bit_pos = st->next_bit_pos; /* Q0 */ @@ -1004,13 +1022,13 @@ static void dec_prm_tcx_ivas_fx( { Word16 Q_old_Aq_12_8 = Q12; move16(); - stereo_tcx_dec_mode_switch_reconf_ivas_fx( st, 0, last_element_mode, &st->hTcxDec->Q_syn_Overl_TDAC, - &st->hHQ_core->Q_fer_samples, - &st->hTcxDec->Q_syn_Overl, - &st->hTcxDec->Q_syn_Overl_TDACFB, - &st->hTcxDec->Q_syn_OverlFB, - &st->hHQ_core->Q_old_wtda, - &st->hHQ_core->Q_old_wtda_LB, &Q_old_Aq_12_8 ); + stereo_tcx_dec_mode_switch_reconf_fx( st, 0, last_element_mode, &st->hTcxDec->Q_syn_Overl_TDAC, + &st->hHQ_core->Q_fer_samples, + &st->hTcxDec->Q_syn_Overl, + &st->hTcxDec->Q_syn_Overl_TDACFB, + &st->hTcxDec->Q_syn_OverlFB, + &st->hHQ_core->Q_old_wtda, + &st->hHQ_core->Q_old_wtda_LB, &Q_old_Aq_12_8 ); } st->last_core = st->last_core_from_bs; /* Q0 */ -- GitLab From 5213e4a355689ca81f7ba8f57f20c4de6fbe5e13 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 19 Jun 2026 17:37:39 +0200 Subject: [PATCH 2/2] fix patch --- lib_dec/ivas_tcx_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 9827d03cf..27a06deb1 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -972,7 +972,7 @@ static void dec_prm_tcx_ivas_fx( IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { #ifdef FIX_BASOP_2650_DEC_PRM_TCX - st->bits_frame_core = extract_l( L_sub( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ), st->next_bit_pos ) ); /* Q0 */ + st->bits_frame_core = extract_l( L_sub( Mpy_32_32_r( st->total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ), st->next_bit_pos ) ); /* Q0 */ assert( st->bits_frame_core == (int16_t) ( ( st->total_brate / FRAMES_PER_SEC ) - st->next_bit_pos ) ); #else // The value of 1/ FRAMES_PER_SEC shifted left by 19 because taking Q as 15 led to precision loss -- GitLab