From 92708f2c53fb12a35e55c56f985b3d41323096b0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 20 May 2026 09:46:53 +0200 Subject: [PATCH] macro and code for HARMONIZE_2596_SetModeIndex --- lib_com/options.h | 1 + lib_com/prot_fx.h | 8 ++++++++ lib_enc/ivas_core_pre_proc_front_fx.c | 4 ++++ lib_enc/ivas_core_pre_proc_fx.c | 9 +++++++++ lib_enc/prot_fx_enc.h | 2 ++ lib_enc/setmodeindex_fx.c | 24 ++++++++++++++++++++++-- 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index cd569d12b..9bddc290f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,6 +112,7 @@ #define HARMONIZE_2553_TonalConceal_Init /* FhG: Harmonize TonalMDCTConceal_Init with its ivas derivate */ #define HARMONIZE_2553_TonalConceal_SaveFreqSignal /* FhG: Harmonize TonalConceal_SaveFreqSignal with its ivas derivate */ #define HARMONIZE_2553_TonalConceal_SaveTimeSignal /* FhG: Harmonize TonalConceal_SaveTimeSignal with its ivas derivate */ +#define HARMONIZE_2596_SetModeIndex /* FhG: Harmonize SetModeIndex with its ivas derivate */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index c434a6fc1..6ca8104cc 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9630,11 +9630,19 @@ void core_coder_mode_switch_ivas_fx( ); +#ifdef HARMONIZE_2596_SetModeIndex +void SetModeIndex_fx( +#else void SetModeIndex_ivas_fx( +#endif Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate Q0*/ const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ +#ifdef HARMONIZE_2596_SetModeIndex + , + const Word16 shift +#endif ); void init_tcx_cfg_ivas_fx( diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 92f753704..b74dd8254 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1581,7 +1581,11 @@ void pre_proc_front_ivas_fx( test(); IF( EQ_32( ivas_format, SBA_FORMAT ) && st->core_brate != FRAME_NO_DATA && st->last_core_brate == FRAME_NO_DATA && st->sba_br_sw_while_no_data ) { +#ifdef HARMONIZE_2596_SetModeIndex + SetModeIndex_fx( st, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), element_mode, MCT_flag, 0 ); +#else SetModeIndex_ivas_fx( st, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), element_mode, MCT_flag ); +#endif st->sba_br_sw_while_no_data = 0; move16(); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index f315da04b..832b95c58 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -357,7 +357,11 @@ void pre_proc_ivas_fx( st->total_brate = L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ); /* Q0 */ move32(); +#ifdef HARMONIZE_2596_SetModeIndex + SetModeIndex_fx( st, imult3216( st->last_bits_frame_nominal, FRAMES_PER_SEC ), last_element_mode, MCT_flag, 0 ); +#else SetModeIndex_ivas_fx( st, imult3216( st->last_bits_frame_nominal, FRAMES_PER_SEC ), last_element_mode, MCT_flag ); +#endif st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); /* Q0 */ move16(); @@ -417,7 +421,12 @@ void pre_proc_ivas_fx( { IF( NE_32( st->core_brate, FRAME_NO_DATA ) ) { + +#ifdef HARMONIZE_2596_SetModeIndex + SetModeIndex_fx( st, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), element_mode, MCT_flag, 0 ); +#else SetModeIndex_ivas_fx( st, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), element_mode, MCT_flag ); +#endif } test(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 046f15211..cc8d72195 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2759,12 +2759,14 @@ void spec_flatness_fx( Word16 sSFM[SFM_NUM] /*(o) spectral flatness rate*/ ); +#ifndef HARMONIZE_2596_SetModeIndex void SetModeIndex_fx( Encoder_State *st, Word32 last_total_brate, /* Q0 */ const Word16 last_element_mode, /* Q0 */ const Word16 is_mct, /* Q0 */ const Word16 shift ); +#endif void MDCT_selector_fx( Encoder_State *st, /* i/o: Encoder State */ diff --git a/lib_enc/setmodeindex_fx.c b/lib_enc/setmodeindex_fx.c index 6c34efb0f..7183e452f 100644 --- a/lib_enc/setmodeindex_fx.c +++ b/lib_enc/setmodeindex_fx.c @@ -21,6 +21,7 @@ ---------------------------------------------------------------------------*/ +#ifndef HARMONIZE_2596_SetModeIndex void SetModeIndex_fx( Encoder_State *st, Word32 last_total_brate, /* Q0 */ @@ -56,13 +57,21 @@ void SetModeIndex_fx( return; } +#endif - +#ifdef HARMONIZE_2596_SetModeIndex +void SetModeIndex_fx( +#else void SetModeIndex_ivas_fx( +#endif Encoder_State *st, /* i : Encoder state */ const Word32 last_total_brate, /* i : last total bitrate Q0*/ const Word16 last_element_mode, /* i : last IVAS element mode Q0*/ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) Q0*/ +#ifdef HARMONIZE_2596_SetModeIndex + , + const Word16 shift +#endif ) { Word16 ini_frame_loc = st->ini_frame; // Q0 @@ -93,7 +102,18 @@ void SetModeIndex_ivas_fx( ( NE_16( st->rf_mode_last, st->rf_mode ) ) || ( st->element_mode > EVS_MONO && st->ini_frame == 0 ) ) { - core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); +#ifdef HARMONIZE_2596_SetModeIndex + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + core_coder_mode_switch_fx( st, last_total_brate, MCT_flag, shift ); + } + ELSE + { +#endif + core_coder_mode_switch_ivas_fx( st, last_total_brate, MCT_flag ); +#ifdef HARMONIZE_2596_SetModeIndex + } +#endif } st->ini_frame = ini_frame_loc; // Q0 -- GitLab