From 4c2884057fdeaa7748a00f859edb709990ac9cd8 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 24 Oct 2022 15:06:30 +0200 Subject: [PATCH 1/3] introduce new function for reconfiguration - BE --- lib_com/options.h | 2 +- lib_dec/ivas_tcx_core_dec.c | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b988fcb581..85a4f1eeb2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,7 +152,7 @@ #define FIX_155_HP20_ISSUE /* Issue 155: apply hp20 on all input channels instead of just 2 channels */ #define EFAP_FIX_POLY /* Issue 167: fix bug in EFAP polygon selection */ #define SBA_HOA_HBR_IMPROV /* issue 91: Improvements to SBA high bitrate HOA3 coding */ - +#define FIX_TCX_DEC_RECONF_BF /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 9420be9eb9..8e9744e767 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -52,6 +52,9 @@ *-------------------------------------------------------------*/ static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, int16_t *bitsRead ); +#ifdef FIX_TCX_DEC_RECONF_BFI +static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t is_mct, const int16_t last_element_mode ); +#endif /*-------------------------------------------------------------* @@ -66,7 +69,9 @@ void stereo_tcx_init_dec( const int16_t last_element_mode /* i : element mode of previous frame */ ) { +#ifndef FIX_TCX_DEC_RECONF_BFI int16_t frame_size_index; +#endif TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; @@ -128,6 +133,9 @@ void stereo_tcx_init_dec( if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || ( st->bwidth != st->last_bwidth ) || ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) ) { /*re-initialization*/ +#ifdef FIX_TCX_DEC_RECONF_BFI + stereo_tcx_dec_mode_switch_reconf( st, is_mct, last_element_mode ); +#else st->rate_switching_init = 1; /* Identify frame type - TCX Reconfiguration */ @@ -151,6 +159,7 @@ void stereo_tcx_init_dec( /* Reconfigure Core */ mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, is_mct, last_element_mode ); +#endif } return; @@ -923,3 +932,38 @@ static void dec_prm_tcx( return; } + +#ifdef FIX_TCX_DEC_RECONF_BFI +static void stereo_tcx_dec_mode_switch_reconf( + DecoderState *st, + const int16_t is_mct, + const int16_t last_element_mode +) +{ + int16_t frame_size_index; + + st->rate_switching_init = 1; + + /* Identify frame type - TCX Reconfiguration */ + for ( frame_size_index = 0; frame_size_index < FRAME_SIZE_NB; frame_size_index++ ) + { + if ( frame_size_index < FRAME_SIZE_NB - 1 ) + { + if ( ( FrameSizeConfig[frame_size_index].frame_bits <= st->bits_frame_nominal ) && ( FrameSizeConfig[frame_size_index + 1].frame_bits > st->bits_frame_nominal ) ) + { + break; + } + } + else + { + if ( FrameSizeConfig[frame_size_index].frame_bits <= st->bits_frame_nominal ) + { + break; + } + } + } + + /* Reconfigure Core */ + mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, is_mct, last_element_mode ); +} +#endif -- GitLab From d4368978a4c2034a32feca2e5a733b90f0a44db5 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 24 Oct 2022 16:24:48 +0200 Subject: [PATCH 2/3] add new reconf call --- lib_com/options.h | 2 +- lib_dec/ivas_tcx_core_dec.c | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 85a4f1eeb2..a6cd15b259 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,7 +152,7 @@ #define FIX_155_HP20_ISSUE /* Issue 155: apply hp20 on all input channels instead of just 2 channels */ #define EFAP_FIX_POLY /* Issue 167: fix bug in EFAP polygon selection */ #define SBA_HOA_HBR_IMPROV /* issue 91: Improvements to SBA high bitrate HOA3 coding */ -#define FIX_TCX_DEC_RECONF_BF +#define FIX_TCX_DEC_RECONF_BFI /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 8e9744e767..4cf7a59790 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -51,7 +51,11 @@ * Local prototypes *-------------------------------------------------------------*/ +#ifdef FIX_TCX_DEC_RECONF_BFI +static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, const int16_t last_element_mode, int16_t *bitsRead ); +#else static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, int16_t *bitsRead ); +#endif #ifdef FIX_TCX_DEC_RECONF_BFI static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t is_mct, const int16_t last_element_mode ); #endif @@ -130,7 +134,14 @@ void stereo_tcx_init_dec( } } +#ifdef FIX_TCX_DEC_RECONF_BFI + if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || + ( st->bwidth != st->last_bwidth ) || + ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || + ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) ) +#else if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || ( st->bwidth != st->last_bwidth ) || ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) ) +#endif { /*re-initialization*/ #ifdef FIX_TCX_DEC_RECONF_BFI @@ -293,7 +304,11 @@ void stereo_tcx_core_dec( tcx_current_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; #endif +#ifdef FIX_TCX_DEC_RECONF_BFI + dec_prm_tcx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead ); +#else dec_prm_tcx( st, param, param_lpc, &total_nbbits, &bitsRead ); +#endif #ifdef FIX_IVAS_337 /*IVAS-337 consider BER */ if ( !st->rate_switching_init && st->BER_detect ) @@ -817,6 +832,9 @@ static void dec_prm_tcx( int16_t param[], /* o : decoded parameters */ int16_t param_lpc[], /* o : LPC parameters */ int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ +#ifdef FIX_TCX_DEC_RECONF_BFI + const int16_t last_element_mode, +#endif int16_t *bitsRead /* o : number of read bits */ ) { @@ -870,6 +888,14 @@ static void dec_prm_tcx( st->prev_bfi = 1; } +#ifdef FIX_TCX_DEC_RECONF_BFI + /* possible need for reconfiguration can only be decided correctly once last_core_from_bs has been decoded */ + if ( ( st->last_core != st->last_core_from_bs ) && ( st->last_core_from_bs != TCX_20_CORE && st->last_core_from_bs != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core_from_bs == ACELP_CORE && st->last_con_tcx == 1 ) ) ) + { + stereo_tcx_dec_mode_switch_reconf( st, 0, last_element_mode ); + } +#endif + st->last_core = st->last_core_from_bs; /*for TCX 10 force last_core to be TCX since ACELP as previous core is forbidden*/ @@ -935,7 +961,7 @@ static void dec_prm_tcx( #ifdef FIX_TCX_DEC_RECONF_BFI static void stereo_tcx_dec_mode_switch_reconf( - DecoderState *st, + Decoder_State *st, const int16_t is_mct, const int16_t last_element_mode ) -- GitLab From a11ac756eb2b35ac506d7529c5cf4d5d9520f7b6 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 24 Oct 2022 16:29:18 +0200 Subject: [PATCH 3/3] fix indentation --- lib_dec/ivas_tcx_core_dec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 4cf7a59790..595ed9d4ac 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -889,11 +889,11 @@ static void dec_prm_tcx( } #ifdef FIX_TCX_DEC_RECONF_BFI - /* possible need for reconfiguration can only be decided correctly once last_core_from_bs has been decoded */ - if ( ( st->last_core != st->last_core_from_bs ) && ( st->last_core_from_bs != TCX_20_CORE && st->last_core_from_bs != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core_from_bs == ACELP_CORE && st->last_con_tcx == 1 ) ) ) - { - stereo_tcx_dec_mode_switch_reconf( st, 0, last_element_mode ); - } + /* possible need for reconfiguration can only be decided correctly once last_core_from_bs has been decoded */ + if ( ( st->last_core != st->last_core_from_bs ) && ( st->last_core_from_bs != TCX_20_CORE && st->last_core_from_bs != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core_from_bs == ACELP_CORE && st->last_con_tcx == 1 ) ) ) + { + stereo_tcx_dec_mode_switch_reconf( st, 0, last_element_mode ); + } #endif st->last_core = st->last_core_from_bs; -- GitLab