From 54aae372724465de2900c31493c191252a1da8ee Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 18 Sep 2025 17:14:17 +0200 Subject: [PATCH] port flp mr 1630 - adjust mct max. channels --- lib_com/ivas_cnst.h | 5 +++++ lib_com/options.h | 2 +- lib_dec/ivas_mct_core_dec_fx.c | 26 +++++++++++++++++++++----- lib_enc/ivas_mct_core_enc_fx.c | 11 ++++++++++- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 86bf5d28d..c8397ad59 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1415,10 +1415,15 @@ typedef enum #define LFE_CHANNEL 3 #define MIN_LFE_NRG 0.5f +#ifdef ADJUST_MCT_CHANNELS_MAX +#define MCT_MAX_CHANNELS 11 /* == 7.1.4 LS channels without the LFE channel */ +#define MCT_MAX_BLOCKS ( ( MCT_MAX_CHANNELS + 1 ) / CPE_CHANNELS ) /* max. number of channel pairs (MCT_MAX_CHANNELS/2) within MCT*/ +#else #define MCT_MAX_CHANNELS MAX_TRANSPORT_CHANNELS #define MCT_MAX_BLOCKS ( MCT_MAX_CHANNELS / CPE_CHANNELS ) /* max. number of channel pairs (MCT_MAX_CHANNELS/2) within MCT*/ #define MAX_NUM_DATA max( MCT_MAX_CHANNELS, 4 ) +#endif #define NBBITS_MCT_RATIO 4 #define BITRATE_MCT_RATIO_RANGE ( 1 << NBBITS_MCT_RATIO ) /* Range of the coded bitrate distribution ratio */ diff --git a/lib_com/options.h b/lib_com/options.h index 36331addf..90f83ea38 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,7 @@ #define NONBE_FIX_1220_OMASA_JBM_EXT_USAN /* Nokia: fix issue 1220 OMASA EXT JBM USAN, also fix similar cases of free to avoid future problems */ #define NONBE_FIX_1376_MDCT_CONCEALMENT /* FhG: fix concealment artifact in MDCT Stereo with DTX, in case transition frame gets lost */ #define NONBE_1377_REND_DIRATT_CONF /* Eri: Issue 1377: Error in directivity attenuation configuration for both IVAS_dec and IVAS_rend */ - +#define ADJUST_MCT_CHANNELS_MAX /* FhG: set correct max mct channels constant*/ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index 47cb02d1e..3a2cd3118 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -75,9 +75,16 @@ void ivas_mct_side_bits_fx( { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; - i = add( i, 1 ); - move16(); +#ifdef ADJUST_MCT_CHANNELS_MAX + IF( LT_16( i, MCT_MAX_CHANNELS ) ) + { +#endif + sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; + i = add( i, 1 ); + move16(); +#ifdef ADJUST_MCT_CHANNELS_MAX + } +#endif } } @@ -218,10 +225,19 @@ void ivas_mct_core_dec( { FOR( ch = 0; ch < CPE_CHANNELS; ( ch++, i++ ) ) { - sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; +#ifdef ADJUST_MCT_CHANNELS_MAX + IF( LT_16( i, MCT_MAX_CHANNELS ) ) + { +#endif + sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; +#ifdef ADJUST_MCT_CHANNELS_MAX + } +#endif } } +#ifndef ADJUST_MCT_CHANNELS_MAX + /*seems like obsolete code*/ i = 0; move16(); FOR( ch = 0; ch < nChannels; ch++ ) @@ -232,7 +248,7 @@ void ivas_mct_core_dec( } i = add( i, 1 ); } - +#endif bfi = sts[0]->bfi; move16(); diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index c616bfd30..e42ee56d7 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -293,6 +293,7 @@ void ivas_mct_core_enc_fx( inv_spectrum_fx[ch][1] = inv_spectrum_long_cpe0_fx[ch] + N_TCX10_MAX; powerSpec_fx[ch] = powerSpec_long_cpe0_fx[ch]; } + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { q_powSpec[ch] = 0; @@ -332,7 +333,15 @@ void ivas_mct_core_enc_fx( { FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; +#ifdef ADJUST_MCT_CHANNELS_MAX + IF( LT_16( add( i_mult( cpe_id, CPE_CHANNELS ), ch ), nChannels ) ) + { +#endif + sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; +#ifdef ADJUST_MCT_CHANNELS_MAX + } +#endif + IF( EQ_32( hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { i = add( i, 1 ); -- GitLab