From baa47b2b08978daf64fb59446712675760fa72df Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jun 2023 11:29:19 +0200 Subject: [PATCH 01/10] issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio; under FIX_529_BWD_ISSUE --- lib_com/ivas_prot.h | 5 ++++- lib_com/options.h | 1 + lib_com/prot.h | 8 +++++--- lib_enc/amr_wb_enc.c | 7 +++++-- lib_enc/bw_detect.c | 13 ++++++++++--- lib_enc/ivas_core_pre_proc_front.c | 12 +++++++++--- lib_enc/ivas_cpe_enc.c | 3 +++ lib_enc/ivas_ism_enc.c | 4 ++++ lib_enc/ivas_mdct_core_enc.c | 4 ++++ lib_enc/ivas_sce_enc.c | 3 +++ lib_enc/pre_proc.c | 7 +++++-- 11 files changed, 53 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2804668e0f..cca3a4830e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -211,7 +211,10 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ +#ifdef FIX_529_BWD_ISSUE + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#endif + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); ivas_error pre_proc_ivas( diff --git a/lib_com/options.h b/lib_com/options.h index 369eb91f24..ca67203afd 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -237,6 +237,7 @@ #define ENHANCED_STEREO_DMX /* Orange : Contribution 48 - Enhanced stereo downmix. */ #define BINAURAL_AUDIO_CMDLINE +#define FIX_529_BWD_ISSUE /* VA: issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/prot.h b/lib_com/prot.h index e6f371c468..a8b07ce486 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3877,9 +3877,11 @@ void bw_detect( Encoder_State *st, /* i/o: Encoder State */ const float signal_in[], /* i : input signal */ float *spectrum, /* i : MDCT spectrum */ - const float *enerBuffer /* i : energy buffer */ - , - const int16_t mct_on /* i : flag MCT mode */ + const float *enerBuffer, /* i : energy buffer */ +#ifdef FIX_529_BWD_ISSUE + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#endif + const int16_t mct_on /* i : flag MCT mode */ ); diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index c0c0b4f18e..bf7ad3808a 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -342,8 +342,11 @@ void amr_wb_enc( * WB, SWB and FB bandwidth detector *----------------------------------------------------------------*/ - bw_detect( st, st->input, NULL, NULL, - 0 ); +#ifdef FIX_529_BWD_ISSUE + bw_detect( st, st->input, NULL, NULL, MONO_FORMAT, 0 ); +#else + bw_detect( st, st->input, NULL, NULL, 0 ); +#endif /* in AMR_WB IO, limit the maximum band-width to WB */ if ( st->bwidth > WB ) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 6de35a211a..cb9c532cbc 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -71,9 +71,11 @@ void bw_detect( Encoder_State *st, /* i/o: Encoder State */ const float signal_in[], /* i : input signal */ float *spectrum, /* i : MDCT spectrum */ - const float *enerBuffer /* i : energy buffer */ - , - const int16_t mct_on /* i : flag MCT mode */ + const float *enerBuffer, /* i : energy buffer */ +#ifdef FIX_529_BWD_ISSUE + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#endif + const int16_t mct_on /* i : flag MCT mode */ ) { int16_t i, j, k, bw_max, bin_width, n_bins; @@ -86,7 +88,12 @@ void bw_detect( int16_t bwd_count_wider_bw, l_frame; bwd_count_wider_bw = BWD_COUNT_WIDER_BW; +#ifdef FIX_529_BWD_ISSUE + if ( ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate >= IVAS_64k || mct_on ) ) || + ( ivas_format == ISM_FORMAT && st->element_brate >= IVAS_48k ) ) +#else if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) ) +#endif { bwd_count_wider_bw = BWD_COUNT_WIDER_BW_MDCT; } diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 5f775d2403..4937305223 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -107,7 +107,10 @@ ivas_error pre_proc_front_ivas( const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ +#ifdef FIX_529_BWD_ISSUE + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#endif + const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { @@ -479,8 +482,11 @@ ivas_error pre_proc_front_ivas( if ( st->idchan == 0 && element_mode != IVAS_CPE_MDCT ) { - bw_detect( st, st->input, NULL, enerBuffer, - 0 ); +#ifdef FIX_529_BWD_ISSUE + bw_detect( st, st->input, NULL, enerBuffer, ivas_format, 0 ); +#else + bw_detect( st, st->input, NULL, enerBuffer, 0 ); +#endif } if ( element_mode != IVAS_CPE_MDCT ) /* in MDCT stereo, set_bw_stereo() is used instead */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 5f19a5395a..b8bc2facff 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -442,6 +442,9 @@ ivas_error ivas_cpe_enc( &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n], realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n], fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, +#ifdef FIX_529_BWD_ISSUE + ivas_format, +#endif ivas_total_brate ); if ( error != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 6c6a0c8837..0c4d654436 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -165,6 +165,10 @@ ivas_error ivas_ism_enc( &ener[sce_id][0], &relE[sce_id][0], A[sce_id][0], Aw[sce_id][0], epsP[sce_id][0], lsp_new[sce_id][0], lsp_mid[sce_id][0], &vad_hover_flag[sce_id][0], &attack_flag[sce_id][0], realBuffer[sce_id][0], imagBuffer[sce_id][0], old_wsp[sce_id][0], pitch_fr[sce_id][0], voicing_fr[sce_id][0], &loc_harm[sce_id][0], &cor_map_sum[sce_id][0], &vad_flag_dtx[sce_id][0], enerBuffer[sce_id][0], fft_buff[sce_id][0], A[sce_id][0], lsp_new[sce_id][0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, 0, 0, 0, 0, +#ifdef FIX_529_BWD_ISSUE + ISM_FORMAT, +#endif + st_ivas->hEncoderConfig->ivas_total_brate ); if ( error != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index edc9ea1e50..dac1489aed 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -686,7 +686,11 @@ void ivas_mdct_core_whitening_enc( for ( n = 0; n < nSubframes; n++ ) { +#ifdef FIX_529_BWD_ISSUE + bw_detect( st, NULL, st->hTcxEnc->spectrum[n], NULL, MC_FORMAT /*just cannot be ISM_FORMAT*/, mct_on ); +#else bw_detect( st, NULL, st->hTcxEnc->spectrum[n], NULL, mct_on ); +#endif if ( nSubframes == NB_DIV && n == 0 ) { diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 87c0e8e9d3..cf272fab6b 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -185,6 +185,9 @@ ivas_error ivas_sce_enc( &vad_hover_flag[0], &attack_flag[0], realBuffer[0], imagBuffer[0], old_wsp[0], pitch_fr[0], voicing_fr[0], &loc_harm[0], &cor_map_sum[0], &vad_flag_dtx[0], enerBuffer[0], fft_buff[0], A[0], lsp_new[0], currFlatness[0], 0, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, NULL, flag_16k_smc, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->force_front_vad : 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_dtx_flag : 0, +#ifdef FIX_529_BWD_ISSUE + ivas_format, +#endif st_ivas->hEncoderConfig->ivas_total_brate ); if ( error != IVAS_ERR_OK ) { diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 82436a7dfc..cac5e8efbe 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -219,8 +219,11 @@ void pre_proc( * NB/WB/SWB/FB bandwidth detector *----------------------------------------------------------------*/ - bw_detect( st, st->input, NULL, enerBuffer, - 0 ); +#ifdef FIX_529_BWD_ISSUE + bw_detect( st, st->input, NULL, enerBuffer, MONO_FORMAT, 0 ); +#else + bw_detect( st, st->input, NULL, enerBuffer, 0 ); +#endif /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation -- GitLab From cc240b0ed645d80a88964a79b6b311f561a49312 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jun 2023 13:45:48 +0200 Subject: [PATCH 02/10] fix MSAN error within FIX_529_BWD_ISSUE --- lib_enc/bw_detect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index cb9c532cbc..8ef000626c 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -89,8 +89,8 @@ void bw_detect( bwd_count_wider_bw = BWD_COUNT_WIDER_BW; #ifdef FIX_529_BWD_ISSUE - if ( ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate >= IVAS_64k || mct_on ) ) || - ( ivas_format == ISM_FORMAT && st->element_brate >= IVAS_48k ) ) + if ( st->ini_frame > 0 && ( ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate >= IVAS_64k || mct_on ) ) || + ( ivas_format == ISM_FORMAT && st->element_brate >= IVAS_48k ) ) ) #else if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) ) #endif -- GitLab From 5d33d50cd0e508099a43636906477a242498dc23 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jun 2023 13:02:22 +0000 Subject: [PATCH 03/10] lower the limit for no hysteresis BWD switching; under FIX_529_BWD_ISSUE --- lib_enc/bw_detect.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 8ef000626c..7ef39091c5 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -89,8 +89,7 @@ void bw_detect( bwd_count_wider_bw = BWD_COUNT_WIDER_BW; #ifdef FIX_529_BWD_ISSUE - if ( st->ini_frame > 0 && ( ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate >= IVAS_64k || mct_on ) ) || - ( ivas_format == ISM_FORMAT && st->element_brate >= IVAS_48k ) ) ) + if ( st->ini_frame > 0 && ( st->element_mode == IVAS_CPE_MDCT || ivas_format == ISM_FORMAT ) && ( st->element_brate >= IVAS_48k || mct_on ) ) #else if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) ) #endif -- GitLab From 894d309bc1762034cf0259b530b33c5d6e9a7239 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 5 Jun 2023 16:11:54 +0200 Subject: [PATCH 04/10] clang-format --- lib_enc/bw_detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 7ef39091c5..4358355138 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -89,7 +89,7 @@ void bw_detect( bwd_count_wider_bw = BWD_COUNT_WIDER_BW; #ifdef FIX_529_BWD_ISSUE - if ( st->ini_frame > 0 && ( st->element_mode == IVAS_CPE_MDCT || ivas_format == ISM_FORMAT ) && ( st->element_brate >= IVAS_48k || mct_on ) ) + if ( st->ini_frame > 0 && ( st->element_mode == IVAS_CPE_MDCT || ivas_format == ISM_FORMAT ) && ( st->element_brate >= IVAS_48k || mct_on ) ) #else if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) ) #endif -- GitLab From 267f5c24f916f0c8167f88c4ea2415dc254bd960 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jun 2023 09:02:41 +0200 Subject: [PATCH 05/10] fix: BWD output not employed at high bitrates --- lib_com/options.h | 5 ++++- lib_enc/bw_detect.c | 47 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5e475705b1..7ad3f7214c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,12 +170,15 @@ #define FIX_122_MC_DECODER_COMPLEXITY /* FhG: Issue 122, significant decrease of worst case MC decoder complexity */ #define FIX_531_BWS_ISM_BFI /* VA: issue 531: fix MemorySanitizer: use-of-uninitialized-value in ISM2 rate switching with frame errors */ #define FIX_395_CNG_BW /* Eri: Issue 395 - CNG bandwidth issue for unified stereo */ -#define FIX_529_BWD_ISSUE /* VA: issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio */ #define EXTERNAL_ORIENTATIONS /* Nokia: Contribution 41: (external) orientation information handling */ #define MASA_PREREND /* Nokia: Contribution 42: Support for IVAS_rend to merge MASA + other format to MASA */ +#define FIX_529_BWD_ISSUE /* VA: issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio */ + + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 4358355138..79cb67636e 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -52,6 +52,13 @@ * Local constants *-------------------------------------------------------------------*/ +#ifdef FIX_529_BWD_ISSUE +#define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k +#define BWD_MIN_BRATE_WIDER_BW_ISM IVAS_32k +#define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k +#define BWD_MAX_BRATE_WIDER_BW_ISM IVAS_64k +#endif + #define ALPHA_BWD 0.75f #define BWD_LT_THRESH 0.6f @@ -62,10 +69,10 @@ #define CLDFB_ENER_OFFSET 1.6f /*-------------------------------------------------------------------* - * bw_detect() - * - * bandwidth detector - *-------------------------------------------------------------------*/ + * bw_detect() + * + * bandwidth detector + *-------------------------------------------------------------------*/ void bw_detect( Encoder_State *st, /* i/o: Encoder State */ @@ -89,7 +96,8 @@ void bw_detect( bwd_count_wider_bw = BWD_COUNT_WIDER_BW; #ifdef FIX_529_BWD_ISSUE - if ( st->ini_frame > 0 && ( st->element_mode == IVAS_CPE_MDCT || ivas_format == ISM_FORMAT ) && ( st->element_brate >= IVAS_48k || mct_on ) ) + if ( st->ini_frame > 0 && ( ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate >= BWD_MIN_BRATE_WIDER_BW_MDCT || mct_on ) ) || + ( ivas_format == ISM_FORMAT && st->element_brate >= BWD_MIN_BRATE_WIDER_BW_ISM ) ) ) #else if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) ) #endif @@ -583,6 +591,12 @@ void set_bw( { st->bwidth = SWB; } +#ifdef FIX_529_BWD_ISSUE + else if ( element_brate > BWD_MAX_BRATE_WIDER_BW_ISM ) + { + st->bwidth = st->max_bwidth; + } +#endif } /* element_mode == EVS_MONO */ else if ( total_brate <= ACELP_9k60 && st->bwidth > WB ) @@ -640,7 +654,15 @@ void set_bw_stereo( { Encoder_State **sts = hCPE->hCoreCoder; - if ( hCPE->element_mode == IVAS_CPE_MDCT ) +#ifdef FIX_529_BWD_ISSUE + if ( sts[0]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT || sts[1]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT ) + { + sts[0]->bwidth = sts[0]->max_bwidth; + sts[1]->bwidth = sts[1]->max_bwidth; + } + else +#endif + if ( hCPE->element_mode == IVAS_CPE_MDCT ) { /* ensure that both CPE channels have the same audio band-width */ if ( sts[0]->input_bwidth == sts[1]->input_bwidth ) @@ -685,8 +707,7 @@ int16_t set_bw_mct( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = hCPE[cpe_id]->hCoreCoder[ch]; - if ( - st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -695,6 +716,16 @@ int16_t set_bw_mct( } } +#ifdef FIX_529_BWD_ISSUE + for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) + { + if ( hCPE[cpe_id]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT ) + { + mct_bwidth = max( mct_bwidth, hCPE[cpe_id]->hCoreCoder[0]->max_bwidth ); + } + } +#endif + bw_changed = 0; if ( mct_bwidth != last_mct_bwidth ) { -- GitLab From 1af927fa19bae01579b6ed38595b2d8e7e851267 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jun 2023 14:10:13 +0200 Subject: [PATCH 06/10] tuning within FIX_529_BWD_ISSUE --- lib_com/options.h | 2 +- lib_enc/bw_detect.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7ad3f7214c..efad21d267 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -58,7 +58,7 @@ #ifdef DEBUGGING -/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ +#define DEBUG_MODE_INFO /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO /*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 79cb67636e..2a7c13d9a6 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -62,17 +62,21 @@ #define ALPHA_BWD 0.75f #define BWD_LT_THRESH 0.6f -#define BWD_COUNT_MAX 100 -#define BWD_COUNT_WIDER_BW 10 +#define BWD_COUNT_MAX 100 +#define BWD_COUNT_WIDER_BW 10 +#ifdef FIX_529_BWD_ISSUE +#define BWD_COUNT_WIDER_BW_MDCT 2 +#else #define BWD_COUNT_WIDER_BW_MDCT 0 +#endif #define CLDFB_ENER_OFFSET 1.6f /*-------------------------------------------------------------------* - * bw_detect() - * - * bandwidth detector - *-------------------------------------------------------------------*/ + * bw_detect() + * + * bandwidth detector + *-------------------------------------------------------------------*/ void bw_detect( Encoder_State *st, /* i/o: Encoder State */ -- GitLab From 4b42978bdbbc828d2aeb6ab506dffe611260b7ca Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 9 Jun 2023 14:23:53 +0200 Subject: [PATCH 07/10] clang-format --- lib_com/prot.h | 66 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/lib_com/prot.h b/lib_com/prot.h index 0831522564..28466e7587 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -526,29 +526,29 @@ void push_next_bits( #ifdef IND_LIST_DYN /*! r: maximum number of indices */ int16_t get_ivas_max_num_indices( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); /*! r: maximum number of indices */ int16_t get_core_max_num_indices( - const int16_t core, /* i : core */ - const int32_t total_brate /* i : total bitrate */ + const int16_t core, /* i : core */ + const int32_t total_brate /* i : total bitrate */ ); /*! r: maximum number of indices */ int16_t get_BWE_max_num_indices( - const int32_t extl_brate /* i : extensiona layer bitrate */ + const int32_t extl_brate /* i : extensiona layer bitrate */ ); /*! r: maximum number of indices */ int16_t get_ivas_max_num_indices_metadata( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); ivas_error ind_list_realloc( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const int16_t max_num_indices /* i : new maximum number of allowed indices in the list */ ); @@ -568,15 +568,15 @@ ivas_error move_indices( /*! r: index of the indice in the list, -1 if not found */ int16_t find_indice( - BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ const int16_t id, /* i : ID of the indice */ - uint16_t *value, /* o : value of the quantized indice */ - int16_t *nb_bits /* o : number of bits used to quantize the indice */ + uint16_t *value, /* o : value of the quantized indice */ + int16_t *nb_bits /* o : number of bits used to quantize the indice */ ); /*! r: number of deleted indices */ uint16_t delete_indice( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const int16_t id /* i : ID of the indice */ ); #endif @@ -3093,7 +3093,7 @@ void lsf_enc( float *Aq, /* o : quantized A(z) for 4 subframes */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); void isf_enc_amr_wb( @@ -4569,7 +4569,7 @@ ivas_error acelp_core_dec( const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ const int16_t nchan_out, /* i : number of output channels */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t read_sid_info /* i : read SID info flag */ + const int16_t read_sid_info /* i : read SID info flag */ ); void bass_psfilter_init( @@ -4642,15 +4642,15 @@ void swb_CNG_dec( ); void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ + Decoder_State *st, /* i/o: State structure */ + const int16_t tc_subfr, /* i : TC subframe index */ + float *Aq, /* o : quantized A(z) for 4 subframes */ + int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ + float *lsf_new, /* o : de-quantized LSF vector */ + float *lsp_new, /* o : de-quantized LSP vector */ + float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); void isf_dec_amr_wb( @@ -8114,11 +8114,11 @@ int16_t enc_lsf_tcxlpc( ); void msvq_enc( - const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ - const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const float u[], /* i : Vector to be encoded (prediction and mean removed) */ - const int16_t *levels, /* i : Number of levels in each stage */ + const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ + const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const float u[], /* i : Vector to be encoded (prediction and mean removed) */ + const int16_t *levels, /* i : Number of levels in each stage */ const int16_t maxC, /* i : Tree search size (number of candidates kept from one stage to the next == M-best) */ const int16_t stages, /* i : Number of stages */ const float w[], /* i : Weights */ @@ -8183,12 +8183,12 @@ void extend_dctN_input( /*! r: (p_max , best candidate sofar ) */ int16_t msvq_stage1_dct_search( - const float *u, /* i : target */ - const int16_t N, /* i : target length and IDCT synthesis length */ - const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const float *u, /* i : target */ + const int16_t N, /* i : target length and IDCT synthesis length */ + const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ const int16_t max_dct_trunc, /* i : maximum of truncation lenghts */ - float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ const float *midQ_truncQ, /* i : midQ vector */ const float *dct_invScaleF, /* i : global inv scale factors */ const float *dct_scaleF, /* i : global scale factors */ @@ -8358,7 +8358,7 @@ void lsf_end_dec( int16_t *lpc_param, /* i : LPC parameters */ int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ int16_t *nb_indices, /* o : number of indices */ - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); ivas_error find_pred_mode( -- GitLab From 8c6e554d5898ba2cf99f0598da34dc920154a66c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jun 2023 07:59:02 +0200 Subject: [PATCH 08/10] revert BWD hysteresis at mediumbitrates back to 0 frames --- lib_enc/bw_detect.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 2a7c13d9a6..9a15ae61bb 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -62,13 +62,9 @@ #define ALPHA_BWD 0.75f #define BWD_LT_THRESH 0.6f -#define BWD_COUNT_MAX 100 -#define BWD_COUNT_WIDER_BW 10 -#ifdef FIX_529_BWD_ISSUE -#define BWD_COUNT_WIDER_BW_MDCT 2 -#else +#define BWD_COUNT_MAX 100 +#define BWD_COUNT_WIDER_BW 10 #define BWD_COUNT_WIDER_BW_MDCT 0 -#endif #define CLDFB_ENER_OFFSET 1.6f -- GitLab From be359988c3d539edb540a0de52e7385b8f4c396c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jun 2023 08:25:28 +0200 Subject: [PATCH 09/10] fix MSAN error --- lib_enc/bw_detect.c | 2 +- lib_enc/ivas_cpe_enc.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 9a15ae61bb..9c96a851f2 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -655,7 +655,7 @@ void set_bw_stereo( Encoder_State **sts = hCPE->hCoreCoder; #ifdef FIX_529_BWD_ISSUE - if ( sts[0]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT || sts[1]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT ) + if ( hCPE->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT ) { sts[0]->bwidth = sts[0]->max_bwidth; sts[1]->bwidth = sts[1]->max_bwidth; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 17d9f855db..2595c6f78b 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -302,10 +302,7 @@ ivas_error ivas_cpe_enc( lfe_bits = ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ? st_ivas->hLFE->lfe_bits : 0 ); sts[n]->total_brate = hCPE->element_brate; sts[n]->bits_frame_nominal = (int16_t) ( hCPE->element_brate / FRAMES_PER_SEC ); - sts[n]->bits_frame_channel = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC - - lfe_bits - - nb_bits_metadata ) / - st_ivas->hMCT->nchan_out_woLFE ); + sts[n]->bits_frame_channel = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC - lfe_bits - nb_bits_metadata ) / st_ivas->hMCT->nchan_out_woLFE ); } else { @@ -333,8 +330,7 @@ ivas_error ivas_cpe_enc( if ( hCPE->element_mode == IVAS_CPE_DFT ) { - stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, - hCPE->hStereoDft->hItd->hybrid_itd_max ); + stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); /* Time Domain ITD compensation using extrapolation */ #ifdef DEBUG_MODE_DFT -- GitLab From 6cc39710e491bdc6226485a5b8fc761f922f571e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Jun 2023 08:42:18 +0200 Subject: [PATCH 10/10] disable --- 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 efad21d267..7ad3f7214c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -58,7 +58,7 @@ #ifdef DEBUGGING -#define DEBUG_MODE_INFO /* output most important parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO /*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ -- GitLab