From 9ed08a2fc01989649ccd8223fde8e2ecca5f1fa4 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 18 Oct 2024 14:52:07 +0200 Subject: [PATCH 01/17] fix fix mismatch of coder_type (mod_ct) btw. TD stereo encoder and decoder --- lib_com/options.h | 1 + lib_enc/ivas_decision_matrix_enc.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 30200d09d1..85859cf25e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -186,6 +186,7 @@ #define NONBE_FIX_1197_OMASA_META_BUFFER /* Nokia: OMASA ISM_MASA_MODE_PARAM_ONE_OBJ history zero in rateswitching */ #define FIX_1139_REV_COLORATION_SHORT_T60 /* Nokia,FhG: Fix issue 1139, prevent sound coloration artefacts at very low reverberation times */ +#define NONBE_FIX_1205_TD_STEREO_MOD_CT /* VA: fix mismatch of coder_type (mod_ct) btw. TD stereo encoder and decoder */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index dec6a9bc59..1a4e4c25c7 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -172,6 +172,23 @@ void ivas_decision_matrix_enc( st->core = ACELP_CORE; } +#ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT + if ( st->element_mode == IVAS_CPE_TD && st->idchan == 0 && element_brate < IVAS_24k4 && st->core == ACELP_CORE ) + { + /* In TD stereo, TRANSITION mode has different bit allocation than other modes */ + /* the two conditions below are replicated from tdm_configure_enc() where mod_ct is derived from coder_type */ + /* it ensures that coder_type is identical in the TD stereo encoder and decoder */ + if ( ( ( st->last_L_frame >= L_FRAME16k && st->flag_ACELP16k == 0 ) || ( st->last_L_frame == L_FRAME && st->flag_ACELP16k == 1 ) ) && st->last_core_brate != FRAME_NO_DATA && st->last_core_brate != SID_2k40 && st->coder_type_raw != VOICED ) + { + st->coder_type = TRANSITION; + } + else if ( st->coder_type != AUDIO && ( st->sp_aud_decision1 == 1 || st->sp_aud_decision2 == 1 ) ) + { + st->coder_type = AUDIO; + } + } +#endif + if ( st->is_ism_format && st->tcxonly ) { st->core = TCX_20_CORE; -- GitLab From 92416844509a2461e08efa68361b8b04d47f9757 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 29 Oct 2024 11:02:40 -0400 Subject: [PATCH 02/17] change to Vladimir proposed fix, moving it to ivas_stereo_td_enc --- lib_enc/ivas_decision_matrix_enc.c | 17 ----------------- lib_enc/ivas_stereo_td_enc.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 1a4e4c25c7..dec6a9bc59 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -172,23 +172,6 @@ void ivas_decision_matrix_enc( st->core = ACELP_CORE; } -#ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT - if ( st->element_mode == IVAS_CPE_TD && st->idchan == 0 && element_brate < IVAS_24k4 && st->core == ACELP_CORE ) - { - /* In TD stereo, TRANSITION mode has different bit allocation than other modes */ - /* the two conditions below are replicated from tdm_configure_enc() where mod_ct is derived from coder_type */ - /* it ensures that coder_type is identical in the TD stereo encoder and decoder */ - if ( ( ( st->last_L_frame >= L_FRAME16k && st->flag_ACELP16k == 0 ) || ( st->last_L_frame == L_FRAME && st->flag_ACELP16k == 1 ) ) && st->last_core_brate != FRAME_NO_DATA && st->last_core_brate != SID_2k40 && st->coder_type_raw != VOICED ) - { - st->coder_type = TRANSITION; - } - else if ( st->coder_type != AUDIO && ( st->sp_aud_decision1 == 1 || st->sp_aud_decision2 == 1 ) ) - { - st->coder_type = AUDIO; - } - } -#endif - if ( st->is_ism_format && st->tcxonly ) { st->core = TCX_20_CORE; diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 701035cc9f..ebfb1bd990 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -449,6 +449,18 @@ void tdm_configure_enc( } mod_ct = AUDIO; +#ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT + if ( hCPE->element_brate < IVAS_24k4 ) + { + mod_ct = AUDIO; + /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ + if ( sts[0]->coder_type == TRANSITION || + ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && sts[0]->last_core_brate != FRAME_NO_DATA && sts[0]->last_core_brate != SID_2k40 && sts[0]->coder_type_raw != VOICED /*in case of CNG, this code is not reached sts[0]->core_brate != FRAME_NO_DATA && sts[0]->core_brate != SID_2k40 &&*/ ) ) + { + mod_ct = TRANSITION; + } + } +#else if ( hCPE->element_brate < IVAS_24k4 ) { mod_ct = sts[0]->coder_type; @@ -462,7 +474,7 @@ void tdm_configure_enc( mod_ct = AUDIO; } } - +#endif /* Correction of tdm_inst_ratio_idx in case of TC in the seecondary channel */ if ( hStereoTD->flag_skip_DMX == 0 && hStereoTD->tdm_LRTD_flag == 1 && sts[1]->tc_cnt > 1 /*&& abs(hStereoTD->tdm_inst_ratio_idx-LRTD_STEREO_MID_IS_PRIM) > 5*/ ) { -- GitLab From 715dc056964adaeecbdd5eae30f25fe226612614 Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 31 Oct 2024 14:18:04 +0100 Subject: [PATCH 03/17] simplification of logic --- lib_enc/ivas_decision_matrix_enc.c | 11 +++++++++++ lib_enc/ivas_stereo_td_enc.c | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index dec6a9bc59..836cd85c9c 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -465,6 +465,16 @@ void ivas_signaling_enc( if ( st->core == ACELP_CORE ) { +#ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT + /* write coder type */ + push_indice( hBstr, IND_ACELP_SIGNALLING, st->coder_type, 3 ); + + if ( element_brate >= FRMT_SHP_MIN_BRATE_IVAS ) + { + /* write sharpening flag */ + push_indice( hBstr, IND_SHARP_FLAG, st->sharpFlag, 1 ); + } +#else if ( element_brate < FRMT_SHP_MIN_BRATE_IVAS ) { push_indice( hBstr, IND_ACELP_SIGNALLING, st->coder_type, 3 ); @@ -477,6 +487,7 @@ void ivas_signaling_enc( /* write sharpening flag */ push_indice( hBstr, IND_SHARP_FLAG, st->sharpFlag, 1 ); } +#endif /* write extension layer flag to distinguish between TBE (0) and BWE (1) */ if ( st->extl_brate > 0 ) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index ebfb1bd990..a6fee8b26e 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -452,7 +452,6 @@ void tdm_configure_enc( #ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT if ( hCPE->element_brate < IVAS_24k4 ) { - mod_ct = AUDIO; /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ if ( sts[0]->coder_type == TRANSITION || ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && sts[0]->last_core_brate != FRAME_NO_DATA && sts[0]->last_core_brate != SID_2k40 && sts[0]->coder_type_raw != VOICED /*in case of CNG, this code is not reached sts[0]->core_brate != FRAME_NO_DATA && sts[0]->core_brate != SID_2k40 &&*/ ) ) -- GitLab From c35709f7e4136ffad348967d9a270876cdfb406d Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 1 Nov 2024 07:53:59 -0400 Subject: [PATCH 04/17] add supplementary condition in case transition of overwritten --- lib_enc/ivas_stereo_td_enc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index ebfb1bd990..938d9ee128 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -454,8 +454,14 @@ void tdm_configure_enc( { mod_ct = AUDIO; /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ - if ( sts[0]->coder_type == TRANSITION || - ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && sts[0]->last_core_brate != FRAME_NO_DATA && sts[0]->last_core_brate != SID_2k40 && sts[0]->coder_type_raw != VOICED /*in case of CNG, this code is not reached sts[0]->core_brate != FRAME_NO_DATA && sts[0]->core_brate != SID_2k40 &&*/ ) ) + /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ + if ( !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && + ( sts[0]->coder_type == TRANSITION || + ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || + ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && + sts[0]->last_core_brate != FRAME_NO_DATA && + sts[0]->last_core_brate != SID_2k40 && + sts[0]->coder_type_raw != VOICED ) ) ) { mod_ct = TRANSITION; } -- GitLab From 7cc651764487910e453978a3571bf37e5ef00ca0 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 1 Nov 2024 08:25:54 -0400 Subject: [PATCH 05/17] fix clang --- lib_enc/ivas_stereo_td_enc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 2a9bf89616..e701e524c5 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -454,12 +454,12 @@ void tdm_configure_enc( { /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ - if ( !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && - ( sts[0]->coder_type == TRANSITION || - ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || - ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && - sts[0]->last_core_brate != FRAME_NO_DATA && - sts[0]->last_core_brate != SID_2k40 && + if ( !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && + ( sts[0]->coder_type == TRANSITION || + ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || + ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && + sts[0]->last_core_brate != FRAME_NO_DATA && + sts[0]->last_core_brate != SID_2k40 && sts[0]->coder_type_raw != VOICED ) ) ) { mod_ct = TRANSITION; -- GitLab From 026f7bda530e42684e4d401a4915c26906b43833 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 1 Nov 2024 11:19:09 -0400 Subject: [PATCH 06/17] Adding one more condition --- lib_enc/ivas_stereo_td_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index e701e524c5..6bfe85450e 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -454,7 +454,8 @@ void tdm_configure_enc( { /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ - if ( !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && + if ( !( sts[0]->sp_aud_decision1 == 1 && sts[0]->sp_aud_decision2 == 1 && sts[0]->coder_type == TRANSITION && sts[0]->total_brate < STEREO_TCX_MIN_RATE ) && + !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && ( sts[0]->coder_type == TRANSITION || ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && -- GitLab From a7586bd17f24300748401e82597d603ad953101b Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 1 Nov 2024 11:26:23 -0400 Subject: [PATCH 07/17] fix clang --- lib_enc/ivas_stereo_td_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 6bfe85450e..b1f16f9f10 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -455,7 +455,7 @@ void tdm_configure_enc( /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ if ( !( sts[0]->sp_aud_decision1 == 1 && sts[0]->sp_aud_decision2 == 1 && sts[0]->coder_type == TRANSITION && sts[0]->total_brate < STEREO_TCX_MIN_RATE ) && - !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && + !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && ( sts[0]->coder_type == TRANSITION || ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && -- GitLab From b2f433ff3de997a42720ef147cdc3a3236b3726d Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 6 Nov 2024 13:19:24 -0500 Subject: [PATCH 08/17] Revert " Adding one more condition" This reverts commit 026f7bda530e42684e4d401a4915c26906b43833. lib_enc/ivas_stereo_td_enc.c --- lib_enc/ivas_stereo_td_enc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index b1f16f9f10..e701e524c5 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -454,8 +454,7 @@ void tdm_configure_enc( { /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ - if ( !( sts[0]->sp_aud_decision1 == 1 && sts[0]->sp_aud_decision2 == 1 && sts[0]->coder_type == TRANSITION && sts[0]->total_brate < STEREO_TCX_MIN_RATE ) && - !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && + if ( !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && ( sts[0]->coder_type == TRANSITION || ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || ( sts[0]->last_L_frame == L_FRAME && sts[0]->flag_ACELP16k == 1 ) ) && -- GitLab From 98a9dc6cb0542368c254063317db0068c463c386 Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 6 Nov 2024 15:27:45 -0500 Subject: [PATCH 09/17] complementary fix for 1205 + debugging code --- lib_enc/ivas_decision_matrix_enc.c | 27 ++++++++++++++++++++++++++- lib_enc/ivas_stereo_td_enc.c | 3 +++ lib_enc/stat_enc.h | 4 +++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 836cd85c9c..e18d571ef2 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -215,7 +215,22 @@ void ivas_decision_matrix_enc( if ( st->core == TCX_20_CORE && st->total_brate < STEREO_TCX_MIN_RATE ) { st->core = ACELP_CORE; +#ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT + /* For TD stereo at 16.4kbps (TD is not allowed at 13k2), we can't overwrite the coder_type here WHEN it is TRANSITION */ + /* as it has been used for TD bit allocation and must remained the same at the decoder side to ensure identical bit allocation */ + if ( st->idchan == 0 && !( element_brate <= IVAS_16k4 && st->coder_type == TRANSITION && st->element_mode == IVAS_CPE_TD ) ) + { + st->coder_type = AUDIO; + } +#ifdef DEBUG_MODE_TD + else + { + printf( "coder type not changed\n" ); + } +#endif +#else st->coder_type = AUDIO; +#endif st->sp_aud_decision2 = 0; if ( st->low_rate_mode ) @@ -371,7 +386,17 @@ void ivas_decision_matrix_enc( { st->inactive_coder_type_flag = 1; /* GSC */ } - +#ifdef DEBUG_MODE_TD + if ( st->idchan == 0 && st->element_mode == IVAS_CPE_TD && st->core == ACELP_CORE && element_brate < IVAS_24k4 ) + { + if ( (st->coder_type == TRANSITION && st->mod_ct_ST != TRANSITION ) || + ( st->coder_type != TRANSITION && st->mod_ct_ST == TRANSITION ) ) + { + printf( "st->coder_type != st->mod_ct_ST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); + exit( -555 ); + } + } +#endif return; } diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index e701e524c5..0758430ad6 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -479,6 +479,9 @@ void tdm_configure_enc( mod_ct = AUDIO; } } +#endif +#ifdef DEBUG_MODE_TD + sts[0]->mod_ct_ST = mod_ct; #endif /* Correction of tdm_inst_ratio_idx in case of TC in the seecondary channel */ if ( hStereoTD->flag_skip_DMX == 0 && hStereoTD->tdm_LRTD_flag == 1 && sts[1]->tc_cnt > 1 /*&& abs(hStereoTD->tdm_inst_ratio_idx-LRTD_STEREO_MID_IS_PRIM) > 5*/ ) diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 3b7d7b5901..144ed4c48f 100755 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1557,7 +1557,9 @@ typedef struct enc_core_structure int16_t dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ - +#ifdef DEBUG_MODE_TD + short mod_ct_ST; +#endif } Encoder_State, *ENC_CORE_HANDLE; -- GitLab From afcec1e39c9e81d05c852e918c311ddad0df9a75 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 7 Nov 2024 13:35:58 -0500 Subject: [PATCH 10/17] fix clang format --- lib_enc/ivas_decision_matrix_enc.c | 6 +++--- lib_enc/stat_enc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index e18d571ef2..b2291fb6d2 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -219,7 +219,7 @@ void ivas_decision_matrix_enc( /* For TD stereo at 16.4kbps (TD is not allowed at 13k2), we can't overwrite the coder_type here WHEN it is TRANSITION */ /* as it has been used for TD bit allocation and must remained the same at the decoder side to ensure identical bit allocation */ if ( st->idchan == 0 && !( element_brate <= IVAS_16k4 && st->coder_type == TRANSITION && st->element_mode == IVAS_CPE_TD ) ) - { + { st->coder_type = AUDIO; } #ifdef DEBUG_MODE_TD @@ -389,8 +389,8 @@ void ivas_decision_matrix_enc( #ifdef DEBUG_MODE_TD if ( st->idchan == 0 && st->element_mode == IVAS_CPE_TD && st->core == ACELP_CORE && element_brate < IVAS_24k4 ) { - if ( (st->coder_type == TRANSITION && st->mod_ct_ST != TRANSITION ) || - ( st->coder_type != TRANSITION && st->mod_ct_ST == TRANSITION ) ) + if ( ( st->coder_type == TRANSITION && st->mod_ct_ST != TRANSITION ) || + ( st->coder_type != TRANSITION && st->mod_ct_ST == TRANSITION ) ) { printf( "st->coder_type != st->mod_ct_ST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); exit( -555 ); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 144ed4c48f..323cc90037 100755 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1558,7 +1558,7 @@ typedef struct enc_core_structure int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ #ifdef DEBUG_MODE_TD - short mod_ct_ST; + short mod_ct_ST; #endif } Encoder_State, *ENC_CORE_HANDLE; -- GitLab From 22adcacdddcb09ce4e39df639834537ee7df5c12 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 12 Nov 2024 14:45:00 +0100 Subject: [PATCH 11/17] corerectio of TD stereo debugging output --- lib_dec/ivas_cpe_dec.c | 7 +++++++ lib_enc/ivas_cpe_enc.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index efd192ce6a..10c824fd88 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -410,6 +410,13 @@ ivas_error ivas_cpe_dec( tdm_ratio_idx = hCPE->hStereoTD->tdm_last_ratio_idx; } } +#ifdef DEBUG_MODE_TD + else + { + dbgwrite( 0, 2, 1, 320, "res/mod_ct.dec" ); + } +#endif + /*----------------------------------------------------------------* * Core Decoder diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 292cbd6a5f..7f996b9f3e 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -586,6 +586,13 @@ ivas_error ivas_cpe_enc( stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt, NULL ); } } +#ifdef DEBUG_MODE_TD + else + { + dbgwrite( 0, 2, 1, 320, "res/mod_ct.enc" ); + } +#endif + /* modify the coder_type depending on the total_brate per channel */ for ( n = 0; n < n_CoreChannels; n++ ) -- GitLab From ad9eef1985ab98f0ecfb2c3c393b182147b3e968 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 12 Nov 2024 14:47:29 +0100 Subject: [PATCH 12/17] correction of comments and debugging output --- lib_enc/ivas_decision_matrix_enc.c | 6 +++--- lib_enc/ivas_stereo_classifier.c | 1 - lib_enc/ivas_stereo_td_enc.c | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index b2291fb6d2..b6a53f6884 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -216,8 +216,8 @@ void ivas_decision_matrix_enc( { st->core = ACELP_CORE; #ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT - /* For TD stereo at 16.4kbps (TD is not allowed at 13k2), we can't overwrite the coder_type here WHEN it is TRANSITION */ - /* as it has been used for TD bit allocation and must remained the same at the decoder side to ensure identical bit allocation */ + /* In TD stereo at 16.4kbps (not applicable at 13.2kbps), we cannot overwrite the `coder_type` when it is set to TRANSITION, */ + /* as it is used for TD stereo bit allocation. To ensure consistent bit allocation, it must remain unchanged on the decoder side. */ if ( st->idchan == 0 && !( element_brate <= IVAS_16k4 && st->coder_type == TRANSITION && st->element_mode == IVAS_CPE_TD ) ) { st->coder_type = AUDIO; @@ -225,7 +225,7 @@ void ivas_decision_matrix_enc( #ifdef DEBUG_MODE_TD else { - printf( "coder type not changed\n" ); + printf( "TD stereo: coder_type not changed in ivas_decision_matrix_enc().\n" ); } #endif #else diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 55ceb014be..79a69f5b32 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -78,7 +78,6 @@ static void edge_detect( const float *inp, const int16_t len, const float inp_mi static float redge_detect( const float *inp, const int16_t len, const float inp_min, const float inp_max ); - /*-------------------------------------------------------------------* * Function select_stereo_mode() * diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 0758430ad6..16409c13e6 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -452,8 +452,7 @@ void tdm_configure_enc( #ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT if ( hCPE->element_brate < IVAS_24k4 ) { - /* Only sure TRANSITION coding modes are important for bit allocation, otherwise mod_ct is set to AUDIO only to easy debugging if needed */ - /* Enforce GC coder type on inactive signal (this can be later overwritten to INACTIVE) */ + /* In TD stereo, the TRANSITION mode has a specific bit allocation. All other formats share the same bit allocation. For these other formats, `mod_ct` is set to AUDIO to aid in debugging, though it does not have any functional impact. */ if ( !( sts[0]->localVAD == 0 && sts[0]->coder_type == TRANSITION ) && ( sts[0]->coder_type == TRANSITION || ( ( ( sts[0]->last_L_frame >= L_FRAME16k && sts[0]->flag_ACELP16k == 0 ) || -- GitLab From 0fdd136562ae0f3e211120e7f07d9757353fb669 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 13 Nov 2024 15:24:05 +0100 Subject: [PATCH 13/17] formal issues: reintroduce empty lines --- lib_enc/ivas_decision_matrix_enc.c | 3 +++ lib_enc/ivas_stereo_classifier.c | 1 + lib_enc/ivas_stereo_td_enc.c | 1 + lib_enc/stat_enc.h | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index b6a53f6884..4f73845035 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -215,6 +215,7 @@ void ivas_decision_matrix_enc( if ( st->core == TCX_20_CORE && st->total_brate < STEREO_TCX_MIN_RATE ) { st->core = ACELP_CORE; + #ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT /* In TD stereo at 16.4kbps (not applicable at 13.2kbps), we cannot overwrite the `coder_type` when it is set to TRANSITION, */ /* as it is used for TD stereo bit allocation. To ensure consistent bit allocation, it must remain unchanged on the decoder side. */ @@ -231,6 +232,7 @@ void ivas_decision_matrix_enc( #else st->coder_type = AUDIO; #endif + st->sp_aud_decision2 = 0; if ( st->low_rate_mode ) @@ -397,6 +399,7 @@ void ivas_decision_matrix_enc( } } #endif + return; } diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 79a69f5b32..55ceb014be 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -78,6 +78,7 @@ static void edge_detect( const float *inp, const int16_t len, const float inp_mi static float redge_detect( const float *inp, const int16_t len, const float inp_min, const float inp_max ); + /*-------------------------------------------------------------------* * Function select_stereo_mode() * diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 16409c13e6..7f62647603 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -482,6 +482,7 @@ void tdm_configure_enc( #ifdef DEBUG_MODE_TD sts[0]->mod_ct_ST = mod_ct; #endif + /* Correction of tdm_inst_ratio_idx in case of TC in the seecondary channel */ if ( hStereoTD->flag_skip_DMX == 0 && hStereoTD->tdm_LRTD_flag == 1 && sts[1]->tc_cnt > 1 /*&& abs(hStereoTD->tdm_inst_ratio_idx-LRTD_STEREO_MID_IS_PRIM) > 5*/ ) { diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 323cc90037..b4ab7730dd 100755 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1558,8 +1558,9 @@ typedef struct enc_core_structure int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ #ifdef DEBUG_MODE_TD - short mod_ct_ST; + int16_t mod_ct_ST; #endif + } Encoder_State, *ENC_CORE_HANDLE; -- GitLab From ef5cd1102b3291eb381aee8b7f2b2238307464da Mon Sep 17 00:00:00 2001 From: malenovsky Date: Thu, 14 Nov 2024 11:44:34 +0000 Subject: [PATCH 14/17] Correction of comment --- lib_enc/ivas_decision_matrix_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 4f73845035..d5433aec29 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -217,7 +217,7 @@ void ivas_decision_matrix_enc( st->core = ACELP_CORE; #ifdef NONBE_FIX_1205_TD_STEREO_MOD_CT - /* In TD stereo at 16.4kbps (not applicable at 13.2kbps), we cannot overwrite the `coder_type` when it is set to TRANSITION, */ + /* In TD stereo below 24.4 kbps we cannot overwrite the `coder_type` when it is set to TRANSITION, */ /* as it is used for TD stereo bit allocation. To ensure consistent bit allocation, it must remain unchanged on the decoder side. */ if ( st->idchan == 0 && !( element_brate <= IVAS_16k4 && st->coder_type == TRANSITION && st->element_mode == IVAS_CPE_TD ) ) { -- GitLab From f5b9e51763a965a3954904331d54c25e72dc4805 Mon Sep 17 00:00:00 2001 From: malenovsky Date: Thu, 14 Nov 2024 11:48:13 +0000 Subject: [PATCH 15/17] Cleanup of obsolete debugging code --- lib_enc/ivas_decision_matrix_enc.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index d5433aec29..5f4db2c040 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -388,17 +388,6 @@ void ivas_decision_matrix_enc( { st->inactive_coder_type_flag = 1; /* GSC */ } -#ifdef DEBUG_MODE_TD - if ( st->idchan == 0 && st->element_mode == IVAS_CPE_TD && st->core == ACELP_CORE && element_brate < IVAS_24k4 ) - { - if ( ( st->coder_type == TRANSITION && st->mod_ct_ST != TRANSITION ) || - ( st->coder_type != TRANSITION && st->mod_ct_ST == TRANSITION ) ) - { - printf( "st->coder_type != st->mod_ct_ST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ); - exit( -555 ); - } - } -#endif return; } -- GitLab From 85f304f73eaf7dd827e838ac39683ba5dd0fa32c Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 14 Nov 2024 12:53:57 +0100 Subject: [PATCH 16/17] cleanup of obsolete debugging output --- lib_dec/ivas_cpe_dec.c | 7 ------- lib_dec/ivas_stereo_td_dec.c | 1 - lib_enc/ivas_cpe_enc.c | 7 ------- lib_enc/ivas_stereo_td_enc.c | 4 ---- lib_enc/stat_enc.h | 3 --- 5 files changed, 22 deletions(-) diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 10c824fd88..efd192ce6a 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -410,13 +410,6 @@ ivas_error ivas_cpe_dec( tdm_ratio_idx = hCPE->hStereoTD->tdm_last_ratio_idx; } } -#ifdef DEBUG_MODE_TD - else - { - dbgwrite( 0, 2, 1, 320, "res/mod_ct.dec" ); - } -#endif - /*----------------------------------------------------------------* * Core Decoder diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index 9ed0fb2e1b..5c534e08f1 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -251,7 +251,6 @@ void tdm_configure_dec( } #ifdef DEBUG_MODE_TD - dbgwrite( &mod_ct, 2, 1, 320, "res/mod_ct.dec" ); dbgwrite( tdm_ratio_idx, 2, 1, 320, "res/tdm_ratio_idx.dec" ); dbgwrite( &tdm_inst_ratio_idx, 2, 1, 320, "res/tdm_inst_ratio_idx.dec" ); dbgwrite( &hStereoTD->tdm_lp_reuse_flag, 2, 1, 320, "res/tdm_lp_reuse_flag.dec" ); diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 7f996b9f3e..292cbd6a5f 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -586,13 +586,6 @@ ivas_error ivas_cpe_enc( stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt, NULL ); } } -#ifdef DEBUG_MODE_TD - else - { - dbgwrite( 0, 2, 1, 320, "res/mod_ct.enc" ); - } -#endif - /* modify the coder_type depending on the total_brate per channel */ for ( n = 0; n < n_CoreChannels; n++ ) diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 7f62647603..5ba900a6aa 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -479,9 +479,6 @@ void tdm_configure_enc( } } #endif -#ifdef DEBUG_MODE_TD - sts[0]->mod_ct_ST = mod_ct; -#endif /* Correction of tdm_inst_ratio_idx in case of TC in the seecondary channel */ if ( hStereoTD->flag_skip_DMX == 0 && hStereoTD->tdm_LRTD_flag == 1 && sts[1]->tc_cnt > 1 /*&& abs(hStereoTD->tdm_inst_ratio_idx-LRTD_STEREO_MID_IS_PRIM) > 5*/ ) @@ -569,7 +566,6 @@ void tdm_configure_enc( #ifdef DEBUG_MODE_TD dbgwrite( &hStereoTD->tdm_low_rate_mode, 2, 1, 320, "res/tdm_low_rate_mode_c" ); dbgwrite( &hStereoTD->tdm_lp_reuse_flag, 2, 1, 320, "res/tdm_lp_reuse_flag_c" ); - dbgwrite( &mod_ct, 2, 1, 320, "res/mod_ct.enc" ); #endif /*----------------------------------------------------------------* diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index b4ab7730dd..3b7d7b5901 100755 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1557,9 +1557,6 @@ typedef struct enc_core_structure int16_t dtx_sce_sba; /* enable use of FD CNG with transform domain cores in SCE SBA */ int16_t sba_br_sw_while_no_data; /* Indicator for SBA bitrate switch while in FRAME_NO_DATA mode */ -#ifdef DEBUG_MODE_TD - int16_t mod_ct_ST; -#endif } Encoder_State, *ENC_CORE_HANDLE; -- GitLab From dc71e1e4889a513e9365c3e32e9619d3c91d269d Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 14 Nov 2024 12:56:00 +0100 Subject: [PATCH 17/17] cleanup of obsolete debugging output --- lib_enc/ivas_decision_matrix_enc.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 5f4db2c040..c5c58fbeba 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -223,12 +223,6 @@ void ivas_decision_matrix_enc( { st->coder_type = AUDIO; } -#ifdef DEBUG_MODE_TD - else - { - printf( "TD stereo: coder_type not changed in ivas_decision_matrix_enc().\n" ); - } -#endif #else st->coder_type = AUDIO; #endif -- GitLab