From 0f943250d0fb9394b2dfded2606731b7525f308b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 19 May 2025 16:39:16 +0200 Subject: [PATCH 1/3] port MR 1373 from float fixes for ME encoder crashing with br and bw switching --- lib_com/options.h | 3 ++- lib_enc/bw_detect.c | 21 +++++++++++++++++++++ lib_enc/ivas_cpe_enc.c | 8 ++++++++ lib_enc/ivas_mct_core_enc.c | 10 ++++++++-- lib_enc/ivas_mct_enc.c | 8 ++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 14ce9128d..c66271c15 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -206,7 +206,8 @@ #define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ - +#define FIX_ACCESS_WITHIN_NULL_STRUCT_MC_BW_SWITCHING /* FhG: fix usan error in MCT with bw swicthing */ +#define NONBE_FIX_986_MC_BW_SWITCHING /* FhG: fix crash in bw and br switching with MC */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 75a97feaf..cd26afb12 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -713,6 +713,26 @@ int16_t set_bw_mct( } bw_changed = 0; +#ifdef NONBE_FIX_986_MC_BW_SWITCHING + if ( mct_bwidth != last_mct_bwidth ) + { + bw_changed = 1; + } + + /* + * always set bw for all CPEs even if it is the same value as before, + * in case of bw + br switching when changing to MCT, this overwrites + * potentially incorrect initial values + */ + for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) + { + for ( ch = 0; ch < CPE_CHANNELS; ch++ ) + { + st = hCPE[cpe_id]->hCoreCoder[ch]; + st->bwidth = mct_bwidth; + } + } +#else if ( mct_bwidth != last_mct_bwidth ) { bw_changed = 1; @@ -726,6 +746,7 @@ int16_t set_bw_mct( } } } +#endif return bw_changed; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 9edcf9a27..5b74cec0c 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -578,7 +578,15 @@ ivas_error ivas_cpe_enc( if ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->element_mode != hCPE->last_element_mode || ( hCPE->element_mode == IVAS_CPE_TD && sts[0]->bits_frame_nominal != last_bits_frame_nominal ) || sts[n]->last_bwidth != sts[n]->bwidth ) && ( n == 0 || hCPE->element_mode == IVAS_CPE_MDCT ) ) { int16_t igf; + +#ifdef NONBE_FIX_986_MC_BW_SWITCHING + int16_t bw; + + bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; + igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode ); +#else igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->rf_mode ); +#endif if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 3c345b472..6146378f4 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -279,8 +279,14 @@ void ivas_mct_core_enc( if ( switch_bw ) { - initMdctStereoEncData( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, - sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 ); +#ifdef FIX_ACCESS_WITHIN_NULL_STRUCT_MC_BW_SWITCHING + H_IGF_GRID igf_grid; + + igf_grid = sts[ch_core]->igf ? sts[ch_core]->hIGFEnc->igfData.igfInfo.grid : NULL; + initMdctStereoEncData( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, sts[ch_core]->igf, igf_grid, 0 ); +#else + initMdctStereoEncData( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth, sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 ); +#endif } if ( sts[ch_core]->igf ) diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index ff248f7f3..253ba48c1 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -172,7 +172,9 @@ ivas_error ivas_mct_enc( float orig_spectrum_long[MCT_MAX_BLOCKS][CPE_CHANNELS][L_FRAME48k]; int16_t switch_bw; IVAS_FORMAT ivas_format; +#ifndef NONBE_FIX_986_MC_BW_SWITCHING int16_t max_bwidth; +#endif int32_t ivas_total_brate; ivas_error error; float *pdata[MAX_INPUT_CHANNELS]; @@ -186,7 +188,9 @@ ivas_error ivas_mct_enc( hMCT->hBstr = st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; /* pointer to write MCT side bits */ ivas_format = st_ivas->hEncoderConfig->ivas_format; +#ifndef NONBE_FIX_986_MC_BW_SWITCHING max_bwidth = st_ivas->hEncoderConfig->max_bwidth; +#endif ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; #ifdef DEBUG_FORCE_MCT_CP @@ -230,7 +234,11 @@ ivas_error ivas_mct_enc( for ( n = 0; n < (int16_t) ( hMCT->nchan_out_woLFE * 0.5 ); n++ ) { +#ifdef NONBE_FIX_986_MC_BW_SWITCHING + initMdctStereoEncData( hMCT->hBlockData[n]->hStereoMdct, ivas_format, IVAS_CPE_MDCT, cp_bitrate, st_ivas->hCPE[0]->hCoreCoder[0]->bwidth, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->igf ? st_ivas->hCPE[0]->hCoreCoder[0]->hIGFEnc->igfData.igfInfo.grid : NULL, 0 ); +#else initMdctStereoEncData( hMCT->hBlockData[n]->hStereoMdct, ivas_format, IVAS_CPE_MDCT, cp_bitrate, max_bwidth, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->igf ? st_ivas->hCPE[0]->hCoreCoder[0]->hIGFEnc->igfData.igfInfo.grid : NULL, 0 ); +#endif } } -- GitLab From 7660be4c2fbb12fd2f69b25175664c3cb30a682a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 20 May 2025 14:18:08 +0200 Subject: [PATCH 2/3] add missing #define NONBE_FIX_975_JBM_USAN --- lib_com/options.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a60a9a35b..a0500cc4e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -206,9 +206,10 @@ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_974_OSBA_JBM_MONO_RS_USAN /* FhG : issue #974: usan in mono and stereo output in OSBA JBM RS */ -#define NONBE_FIX_982_OMASA_DELAY_COMP_5MS /* FhG : issue #982 : 5ms and 20ms output different for OMASA */ -#define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ -#define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ +#define NONBE_FIX_982_OMASA_DELAY_COMP_5MS /* FhG : issue #982 : 5ms and 20ms output different for OMASA */ +#define NONBE_FIX_975_JBM_USAN /* FhG: Fix issue #975, USAN in JBM decoding ad 13.2kbps */ +#define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ +#define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ /* #################### End BASOP porting switches ############################ */ -- GitLab From b03fcd0e314ca2e880771738a96f7a66a3a2c79d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 20 May 2025 14:23:52 +0200 Subject: [PATCH 3/3] fix options in options.h --- lib_com/options.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a0500cc4e..863f6c369 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -202,15 +202,16 @@ #define NONBE_FIX_947_STEREO_DMX_EVS_POC /* Orange: Fix clicks on POC */ #define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ #define NONBE_FIX_951_MCMASA_5MS_RENDERING /* Nokia: issue #951: Differences for 5ms and 20ms rendering for McMASA at 13.2kbps to BINAURAL */ + #define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_974_OSBA_JBM_MONO_RS_USAN /* FhG : issue #974: usan in mono and stereo output in OSBA JBM RS */ #define NONBE_FIX_982_OMASA_DELAY_COMP_5MS /* FhG : issue #982 : 5ms and 20ms output different for OMASA */ #define NONBE_FIX_975_JBM_USAN /* FhG: Fix issue #975, USAN in JBM decoding ad 13.2kbps */ -#define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ -#define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ +#define FIX_ACCESS_WITHIN_NULL_STRUCT_MC_BW_SWITCHING /* FhG: fix usan error in MCT with bw swicthing */ +#define NONBE_FIX_986_MC_BW_SWITCHING /* FhG: fix crash in bw and br switching with MC */ /* #################### End BASOP porting switches ############################ */ -- GitLab