From db5de5ef5d0586bff7e079a5afab53335f387fdc Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 09:53:45 +0100 Subject: [PATCH 1/8] fix crash reported in BASOP issue 1585 --- lib_com/options.h | 1 + lib_dec/core_switching_dec.c | 2 +- lib_dec/ivas_mdct_core_dec.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 301a4fdab4..d219504635 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -208,6 +208,7 @@ #define FIX_1430_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for basop issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ #define FIX_1440_AMR_WB_RESET /* VA: issue 1440: Fix missing AMR-WB IO memory reset (applicable to float only) */ +#define FIX_BASOP_ISSUE_1585_CUT_BS_CRASH /* FhG: Fix for BASOP issue 1585 crash of a cut bitstream, also valid for float code*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 6445970f2a..f9ba20e707 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -663,7 +663,7 @@ ivas_error core_switching_post_dec( } else if ( ( ( st->last_core == ACELP_CORE || st->last_core_bfi == ACELP_CORE ) && !( st->prev_bfi == 1 && st->last_con_tcx == 1 ) ) || st->last_core == AMR_WB_CORE ) /*ACELP->TCX/HQ*/ { - /* if this is first active MDCT-Stereo frame after a CNG frame and output format is mono DMX, this should only be done for the zero-th channel, the other one will simply be copied over after this function */ + /* if output format is mono DMX, this should only be done for the zero-th channel, the other one will simply be copied over after this function */ if ( ( ( st->last_core_brate != SID_2k40 && st->last_core_brate != FRAME_NO_DATA ) || ( st->element_mode != IVAS_CPE_DFT && st->element_mode != IVAS_CPE_TD ) || nchan_out == 1 ) && !( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 && ( nchan_out == 1 || last_element_mode == IVAS_CPE_DFT ) ) ) { core_switch_lb_upsamp( st, output ); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 9cf401aba4..381516dba3 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -160,6 +160,10 @@ static void dec_prm_tcx_sidebits( st->last_core_from_bs = st->last_core; } +#ifdef FIX_BASOP_ISSUE_1585_CUT_BS_CRASH + /* for first frame reset last_core to initialization value for better error-robustness*/ + st->last_core = -1; +#endif getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st0 ); st->hTcxDec->kernel_type[0] = st->hTcxDec->kernel_type[1] = MDCT_IV; -- GitLab From 076854369fea0f3bbb46cb140d6a4687ae3134a9 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 10:53:16 +0100 Subject: [PATCH 2/8] forgotten if condition --- lib_dec/ivas_mdct_core_dec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 381516dba3..48ea0d6c28 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -162,7 +162,10 @@ static void dec_prm_tcx_sidebits( #ifdef FIX_BASOP_ISSUE_1585_CUT_BS_CRASH /* for first frame reset last_core to initialization value for better error-robustness*/ - st->last_core = -1; + if ( st->ini_frame == 0 ) + { + st->last_core = -1; + } #endif getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st0 ); -- GitLab From a31ec58c04c62feca29c6403acfbb0f2a7f31332 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 12:38:25 +0100 Subject: [PATCH 3/8] fix for stereo switching --- lib_dec/ivas_stereo_switching_dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index a0565824af..2de783d0f0 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1581,6 +1581,9 @@ void stereo_switching_dec( sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; +#ifdef FIX_BASOP_ISSUE_1585_CUT_BS_CRASH + sts[1]->ini_frame = sts[0]->ini_frame; +#endif } return; -- GitLab From 780e8db2b703c7a68ebbe22493f198f7b642b006 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 14:39:40 +0100 Subject: [PATCH 4/8] reset to the right value --- lib_dec/ivas_mdct_core_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 48ea0d6c28..b9c1b5ca17 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -164,7 +164,7 @@ static void dec_prm_tcx_sidebits( /* for first frame reset last_core to initialization value for better error-robustness*/ if ( st->ini_frame == 0 ) { - st->last_core = -1; + st->last_core = st->core; } #endif getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st0 ); -- GitLab From 97563c1b4aa3c80c648f5df1fef0a7a9f4f6d79d Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 15:41:47 +0100 Subject: [PATCH 5/8] prevent differences to other modes other than bitrate switching --- lib_dec/ivas_mdct_core_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index b9c1b5ca17..83e69cc96b 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -164,7 +164,7 @@ static void dec_prm_tcx_sidebits( /* for first frame reset last_core to initialization value for better error-robustness*/ if ( st->ini_frame == 0 ) { - st->last_core = st->core; + st->last_core = TCX_20_CORE; } #endif getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st0 ); -- GitLab From d17d49db8545393cd1d33fe76dddc924a4b5c3cf Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 16:20:35 +0100 Subject: [PATCH 6/8] temporarily disable switch to check BE --- lib_dec/ivas_stereo_switching_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 2de783d0f0..786824114f 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1581,7 +1581,7 @@ void stereo_switching_dec( sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; -#ifdef FIX_BASOP_ISSUE_1585_CUT_BS_CRASH +#if 0 // def FIX_BASOP_ISSUE_1585_CUT_BS_CRASH sts[1]->ini_frame = sts[0]->ini_frame; #endif } -- GitLab From 4a2ee931b3ba8e1f0192899c06557d01e4fef431 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 18:22:14 +0100 Subject: [PATCH 7/8] re-enable stereo switching fix --- lib_dec/ivas_stereo_switching_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 786824114f..2de783d0f0 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1581,7 +1581,7 @@ void stereo_switching_dec( sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; -#if 0 // def FIX_BASOP_ISSUE_1585_CUT_BS_CRASH +#ifdef FIX_BASOP_ISSUE_1585_CUT_BS_CRASH sts[1]->ini_frame = sts[0]->ini_frame; #endif } -- GitLab From 66fdc9737496e2607e41f65e00a8b7514d80f914 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 13 Nov 2025 22:38:54 +0100 Subject: [PATCH 8/8] remove bitrate switching fix to retain BE --- lib_dec/ivas_stereo_switching_dec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 2de783d0f0..a0565824af 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1581,9 +1581,6 @@ void stereo_switching_dec( sts[1]->pit_res_max_past = sts[0]->pit_res_max_past; sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX; sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain; -#ifdef FIX_BASOP_ISSUE_1585_CUT_BS_CRASH - sts[1]->ini_frame = sts[0]->ini_frame; -#endif } return; -- GitLab