From 95aa351f212613d704a58d9afe334a4c7a14f01c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 9 Dec 2024 15:03:06 +0100 Subject: [PATCH 1/5] issue 1224: reset ACELP PLC FEC memory in case of switching from MDCT stereo to TD/DFT stereo; under NONBE_1214_PLC_LSF_MEMORY --- lib_com/options.h | 1 + lib_dec/core_switching_dec.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 484de232aa..c92d400879 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,6 +177,7 @@ #define NONBE_1220_OMASA_JBM_BRATE_SW_FLUSH /* VA: issue 1220: fix bug in renderer flush in OMASA 1ISM JBM bitrate switching */ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ +#define NONBE_1214_PLC_LSF_MEMORY /* VA: issue 1224: reset ACELP PLC FEC memory in case of switching from MDCT stereo to TD/DFT stereo */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index c15a165989..c65c80ca17 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -263,8 +263,14 @@ ivas_error core_switching_pre_dec( st->uv_count = 0; } +#ifdef NONBE_1214_PLC_LSF_MEMORY + if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == HQ_CORE || last_element_mode == IVAS_CPE_MDCT ) ) || + ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && + st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) ) +#else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) ) +#endif { if ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) { -- GitLab From d66d1b19dac44cb2dea41aa0afa4649bae0f6261 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 9 Dec 2024 15:53:08 +0100 Subject: [PATCH 2/5] fix for MDCT DTX --- lib_dec/core_switching_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index c65c80ca17..1fd95d91c8 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -264,7 +264,7 @@ ivas_error core_switching_pre_dec( } #ifdef NONBE_1214_PLC_LSF_MEMORY - if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == HQ_CORE || last_element_mode == IVAS_CPE_MDCT ) ) || + if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == HQ_CORE || ( last_element_mode == IVAS_CPE_MDCT && st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) ) #else -- GitLab From 9f26f8d796227b013a735af655d405b1bcadfbe4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 9 Dec 2024 21:22:38 +0100 Subject: [PATCH 3/5] update within NONBE_1214_PLC_LSF_MEMORY --- lib_dec/core_switching_dec.c | 5 ++--- lib_enc/core_switching_enc.c | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 1fd95d91c8..0f3aa52a92 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -264,9 +264,8 @@ ivas_error core_switching_pre_dec( } #ifdef NONBE_1214_PLC_LSF_MEMORY - if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && ( st->last_core == HQ_CORE || ( last_element_mode == IVAS_CPE_MDCT && st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) ) ) || - ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && - st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) ) + if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) || + ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k && st->L_frame <= L_FRAME16k && st->element_mode > EVS_MONO ) /* TCX @ 25.6/32 kHz -> ACELP */ ) #else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) ) diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index acc45973e9..f1b00c5fe0 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -171,7 +171,12 @@ void core_switching_pre_enc( st->uv_count = 0; } +#ifdef NONBE_1214_PLC_LSF_MEMORY + if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) || + ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k && st->L_frame <= L_FRAME16k && st->element_mode > EVS_MONO ) /* TCX @ 25.6/32 kHz -> ACELP */ ) +#else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) ) +#endif { /* Reset the ACELP core in case of HQ->ACELP core switching */ -- GitLab From 273335ab521bc26fe10f4619e68c0f97a6bba2e6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 10 Dec 2024 08:33:02 +0100 Subject: [PATCH 4/5] simplify the condition --- lib_dec/core_switching_dec.c | 2 +- lib_enc/core_switching_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 0f3aa52a92..8bf00f5fb8 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -265,7 +265,7 @@ ivas_error core_switching_pre_dec( #ifdef NONBE_1214_PLC_LSF_MEMORY if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) || - ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k && st->L_frame <= L_FRAME16k && st->element_mode > EVS_MONO ) /* TCX @ 25.6/32 kHz -> ACELP */ ) + ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k ) /* TCX @ 25.6/32 kHz -> ACELP */ ) #else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) ) diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index f1b00c5fe0..3e2312aad2 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -173,7 +173,7 @@ void core_switching_pre_enc( #ifdef NONBE_1214_PLC_LSF_MEMORY if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) || - ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k && st->L_frame <= L_FRAME16k && st->element_mode > EVS_MONO ) /* TCX @ 25.6/32 kHz -> ACELP */ ) + ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k ) /* TCX @ 25.6/32 kHz -> ACELP */ ) #else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) ) #endif -- GitLab From 8bc86b86054933f30e5a48e63cf3acbd42105adb Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 10 Dec 2024 10:15:50 +0100 Subject: [PATCH 5/5] add comments --- lib_dec/core_switching_dec.c | 3 ++- lib_enc/core_switching_enc.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index 8bf00f5fb8..686e5926db 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -264,7 +264,8 @@ ivas_error core_switching_pre_dec( } #ifdef NONBE_1214_PLC_LSF_MEMORY - if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) || + if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) /* EVS and HQ -> ACELP */ || + ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && st->core_brate != SID_2k40 && st->core_brate != FRAME_NO_DATA && ( last_core_brate_st0 == FRAME_NO_DATA || last_core_brate_st0 == SID_2k40 ) ) || ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k ) /* TCX @ 25.6/32 kHz -> ACELP */ ) #else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && nchan_out == 2 && diff --git a/lib_enc/core_switching_enc.c b/lib_enc/core_switching_enc.c index 3e2312aad2..c4a8f8bd52 100644 --- a/lib_enc/core_switching_enc.c +++ b/lib_enc/core_switching_enc.c @@ -172,7 +172,8 @@ void core_switching_pre_enc( } #ifdef NONBE_1214_PLC_LSF_MEMORY - if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) || + if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) /* EVS and HQ -> ACELP */ || + ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) || ( st->core == ACELP_CORE && st->last_L_frame > L_FRAME16k ) /* TCX @ 25.6/32 kHz -> ACELP */ ) #else if ( ( ( st->core == ACELP_CORE || st->core == AMR_WB_CORE ) && st->last_core == HQ_CORE ) || ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_MDCT && last_element_mode == IVAS_CPE_DFT ) ) && active_cnt == 1 ) ) -- GitLab