From 0509fcc0e7b33508fafda835c90daebad34b0d53 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 30 Jun 2022 14:43:04 +0200 Subject: [PATCH 1/2] write last_core in TCX10 frames again to prevent crashes --- lib_dec/ivas_mdct_core_dec.c | 26 ++++---------------------- lib_dec/ivas_tcx_core_dec.c | 11 ----------- lib_enc/ivas_mdct_core_enc.c | 7 ------- lib_enc/ivas_tcx_core_enc.c | 14 -------------- 4 files changed, 4 insertions(+), 54 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 77c70b1f9f..1da209bae3 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -151,40 +151,22 @@ static void dec_prm_tcx_sidebits( if ( ( st->last_core == ACELP_CORE && st->last_total_brate == FRAME_NO_DATA ) || st->prev_bfi ) { /* needed for cases where first TCX frame after a certain transition (e.g. inactive SID/zero frame -> active or stereo switching) is lost */ -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - if ( st->core == TCX_20_CORE ) - { - st->last_core_from_bs = get_next_indice( st0, 1 ); - } - else - { - st->last_core_from_bs = st->last_core; - } -#else st->last_core_from_bs = get_next_indice( st0, 1 ); -#endif /* ACELP -> TCX_10 transitions are forbidden */ +#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 /* put under this switch for documentation, even though it is actually a general bug */ + if ( st->core == TCX_10_CORE && st->last_core == ACELP_CORE ) +#else if ( st->core == TCX_10_CORE && st->last_core == ACELP_CORE && st->last_total_brate == FRAME_NO_DATA ) +#endif { st->last_core = TCX_20_CORE; -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - st->last_core_from_bs = st->last_core; -#endif } } else { -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - if ( st->core != TCX_10_CORE ) - { - st->last_core = get_next_indice( st0, 1 ); - st->last_core_from_bs = st->last_core; - } -#else st->last_core = get_next_indice( st0, 1 ); st->last_core_from_bs = st->last_core; -#endif } #ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 21a525391d..1fc0de4a88 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -876,18 +876,7 @@ static void dec_prm_tcx( /* last_core for error concealment */ if ( !st->use_partial_copy && st->element_mode != IVAS_CPE_MDCT ) { -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - if ( st->core == TCX_20_CORE ) - { - st->last_core_from_bs = get_next_indice( st, 1 ); - } - else - { - st->last_core_from_bs = st->last_core; - } -#else st->last_core_from_bs = get_next_indice( st, 1 ); /* Store decoder memory of last_core */ -#endif if ( st->last_core == ACELP_CORE && st->last_core_from_bs != ACELP_CORE ) { /* A mismatch between the memory and the last_core diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 6f0735837b..98b3a354c5 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -87,14 +87,7 @@ static void enc_prm_pre_mdct( #endif /* write last_core for core switching and error concealment */ -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - if ( st->core == TCX_20_CORE ) - { - push_next_indice( hBstr, st->last_core != ACELP_CORE, 1 ); - } -#else push_next_indice( hBstr, st->last_core != ACELP_CORE, 1 ); -#endif #ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 writeTCXWindowing( hBstr, st->hTcxCfg->tcx_curr_overlap_mode ); diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index f5725b48af..fa0851a52a 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -196,11 +196,7 @@ void stereo_tcx_core_enc( st->bits_frame_core = (int16_t) ( st->total_brate / FRAMES_PER_SEC ) - hBstr->nb_bits_tot; /*Get Bits of TCX header*/ -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - nbits_header = 2; /* Coder types (2) */ -#else nbits_header = 3; /* Coder types (2) + last_core for bfi (1) */ -#endif if ( st->tcxonly ) { @@ -261,9 +257,6 @@ void stereo_tcx_core_enc( { st->core = TCX_20_CORE; n_subframes = 1; -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - nbits_header += 1; /* last core for bfi */ -#endif } #ifdef DEBUG_MODE_TCX @@ -284,14 +277,7 @@ void stereo_tcx_core_enc( #endif /* write last_core for error concealment */ -#ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 - if ( st->core == TCX_20_CORE ) - { - push_next_indice( hBstr, ( st->last_core != ACELP_CORE || st->core == TCX_10_CORE ), 1 ); - } -#else push_next_indice( hBstr, ( st->last_core != ACELP_CORE || st->core == TCX_10_CORE ), 1 ); -#endif /* write TCX overlap mode (1 bit: full, 2 bits: half or no overlap) */ #ifdef FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 -- GitLab From 5d9f88c54dc25df3fd4bf855a6a4327cdee517c7 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 4 Jul 2022 17:47:02 +0200 Subject: [PATCH 2/2] activate switch --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8e0fe3db46..2ae8b252e1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -144,7 +144,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ /*#define FIX_IVAS_185_MDCT_ST_PLC_FADEOUT*/ /* IVAS-185 fix bug in TCX-PLC fadeout for MDCT-Stereo and improve fadeout by fading to background noise instead of white noise */ -/*#define FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10*/ /* IVAS-180 write last overlap mode in TCX10 frames to allow for correct TCX10/TCX5 subframe decomposition in TCX10 frames after a lost frame */ +#define FIX_IVAS_180_PLC_SIGNAL_LAST_OVLP_IN_TCX10 /* IVAS-180 write last overlap mode in TCX10 frames to allow for correct TCX10/TCX5 subframe decomposition in TCX10 frames after a lost frame */ /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ #define FIX_TDREND_STANDALONE /* Fix for TD standalone renderer (broken after update of hHrtfTD pointer and addition of hRenderConfig */ -- GitLab