From be9605c50778dfb72260bcb773d52c59e4d16305 Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Wed, 12 Apr 2023 11:01:28 +0200 Subject: [PATCH 1/8] Add fix for issue 395 --- lib_com/options.h | 2 ++ lib_enc/ivas_cpe_enc.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index ba44aa63b9..238a1a9a04 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -166,6 +166,8 @@ #define FIX_ISM_DTX_CLICKS /* FhG: fix for clicks in ISM DTX for inactive to active TCX transitions */ +#define FIX_395_CNG_BW /* Eri: Issue 395 - CNG bandwidth issue for unified stereo */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index f9b787ac56..2d8521547d 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -569,8 +569,11 @@ ivas_error ivas_cpe_enc( #ifdef DEBUG_MODE_DFT hCPE->hStereoDft->res_cod_bits = 0; #endif - +#ifdef FIX_395_CNG_BW + stereo_dft_enc_update( hCPE->hStereoDft, min( SWB, sts[0]->bwidth ) ); +#else stereo_dft_enc_update( hCPE->hStereoDft, min( SWB, sts[0]->max_bwidth ) ); +#endif } else { -- GitLab From 3d04f9e7a55e401cc9329586c80572f0d6ccbb8f Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Thu, 13 Apr 2023 11:56:05 +0200 Subject: [PATCH 2/8] Added alternate fix in an inactive define --- lib_com/options.h | 2 ++ lib_enc/ivas_stereo_dft_enc.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 238a1a9a04..ee0908cd84 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,8 @@ #define FIX_395_CNG_BW /* Eri: Issue 395 - CNG bandwidth issue for unified stereo */ +/*#define FIX_395_CNG_BW_ALT*/ /* Eri: Issue 395 - CNG bandwidth issue for unified stereo Alternate solution */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index ab4844ab94..121064c95a 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -2172,6 +2172,18 @@ void stereo_dft_enc_write_BS( k_offset = STEREO_DFT_OFFSET; nbands_full = hStereoDft->nbands; +#ifdef FIX_395_CNG_BW_ALT + if ( core_brate == SID_2k40 ) + { + NFFT_inner = min( STEREO_DFT_N_32k_ENC,STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k ); + } + else + { + NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; + } + + hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC ); +#else NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; if ( !( core_brate == SID_2k40 || core_brate == FRAME_NO_DATA ) ) @@ -2179,6 +2191,7 @@ void stereo_dft_enc_write_BS( /* set number of bands according to bandwidth after BWD */ hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC ); } +#endif if ( core_brate == FRAME_NO_DATA ) { -- GitLab From 3ee61d8c632fb01d4503dabab9b62c3671003e2a Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Wed, 10 May 2023 11:07:56 +0200 Subject: [PATCH 3/8] Fix updated, alternate fix removed --- lib_com/ivas_prot.h | 4 ++++ lib_com/options.h | 2 -- lib_enc/ivas_stereo_dft_enc.c | 21 +++++++++------------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 21ea995a84..1721d171f0 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1063,7 +1063,11 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ +#ifdef FIX_395_CNG_BW + const int16_t bwidth /* i : encoded bandwidth */ +#else const int16_t max_bwidth /* i : maximum encoded bandwidth */ +#endif ); void stereo_dft_enc_destroy( diff --git a/lib_com/options.h b/lib_com/options.h index ee0908cd84..238a1a9a04 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,8 +168,6 @@ #define FIX_395_CNG_BW /* Eri: Issue 395 - CNG bandwidth issue for unified stereo */ -/*#define FIX_395_CNG_BW_ALT*/ /* Eri: Issue 395 - CNG bandwidth issue for unified stereo Alternate solution */ - /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 121064c95a..abb7efd642 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -587,7 +587,11 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ +#ifdef FIX_395_CNG_BW + const int16_t bwidth /* i : encoded bandwidth */ +#else const int16_t max_bwidth /* i : maximum encoded bandwidth */ +#endif ) { int16_t i, k_offset; @@ -633,8 +637,13 @@ void stereo_dft_enc_update( hStereoDft->last_res_cod_mode_modify_flag = hStereoDft->res_cod_sw_flag; hStereoDft->res_cod_sw_flag = 0; +#ifdef FIX_395_CNG_BW + /* update band limits in case of rate switching */ + NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[bwidth] / L_FRAME48k; +#else /* update band limits in case of rate switching assuming max_bwidth as BWD output not yet know here */ NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[max_bwidth] / L_FRAME48k; +#endif hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->hConfig->band_res, NFFT_inner, ENC ); hStereoDft->nbands_dmx = stereo_dft_band_config( hStereoDft->band_limits_dmx, 1, NFFT_inner, ENC ); @@ -2172,18 +2181,7 @@ void stereo_dft_enc_write_BS( k_offset = STEREO_DFT_OFFSET; nbands_full = hStereoDft->nbands; -#ifdef FIX_395_CNG_BW_ALT - if ( core_brate == SID_2k40 ) - { - NFFT_inner = min( STEREO_DFT_N_32k_ENC,STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k ); - } - else - { - NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; - } - hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC ); -#else NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; if ( !( core_brate == SID_2k40 || core_brate == FRAME_NO_DATA ) ) @@ -2191,7 +2189,6 @@ void stereo_dft_enc_write_BS( /* set number of bands according to bandwidth after BWD */ hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC ); } -#endif if ( core_brate == FRAME_NO_DATA ) { -- GitLab From eb9f15c70c0321f3731dab2c061767c439301626 Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Wed, 10 May 2023 12:23:05 +0200 Subject: [PATCH 4/8] fix for clang error --- lib_enc/ivas_stereo_dft_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 2342bc01f2..c5aa8ebb4f 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -573,7 +573,7 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ #ifdef FIX_395_CNG_BW - const int16_t bwidth /* i : encoded bandwidth */ + const int16_t bwidth /* i : encoded bandwidth */ #else const int16_t max_bwidth /* i : maximum encoded bandwidth */ #endif -- GitLab From ef0c7c93234f234ff77730597ac4c724fa878fc6 Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Wed, 10 May 2023 13:55:06 +0200 Subject: [PATCH 5/8] Clang format error fixed --- lib_enc/ivas_stereo_dft_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index c5aa8ebb4f..dd07219780 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -573,9 +573,9 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ #ifdef FIX_395_CNG_BW - const int16_t bwidth /* i : encoded bandwidth */ + const int16_t bwidth /* i : encoded bandwidth */ #else - const int16_t max_bwidth /* i : maximum encoded bandwidth */ + const int16_t max_bwidth /* i : maximum encoded bandwidth */ #endif ) { -- GitLab From f55fd4653d9cd90bcbd4cc54496898d1dd3aaf9b Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Mon, 22 May 2023 10:09:27 +0200 Subject: [PATCH 6/8] Fix changed to not run stereo_dft_enc_update --- lib_com/ivas_prot.h | 4 ---- lib_com/options.h | 2 +- lib_enc/ivas_cpe_enc.c | 4 +--- lib_enc/ivas_stereo_dft_enc.c | 27 ++++++++++++++++++--------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 8e739a5c00..d3a1eda3cc 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1165,11 +1165,7 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ -#ifdef FIX_395_CNG_BW - const int16_t bwidth /* i : encoded bandwidth */ -#else const int16_t max_bwidth /* i : maximum encoded bandwidth */ -#endif ); void stereo_dft_enc_destroy( diff --git a/lib_com/options.h b/lib_com/options.h index 1fe68fdd85..2e4f792aa1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,7 +155,7 @@ #define FIX_STEREO_474 /* FhG fix for issue 574, crash with SBA to stereo output at 512 kbps */ #define FIX_MDCT_ST_PLC_FADEOUT_DELAY #define FIX_DIRAC_LS_SYNTHESIS_CONFIG_479 /* FhG: fix for issue 479, broken LS output with DirAC at high BRs */ -#define HYBRID_ITD_MAX /* FhG: Improvement for DFT-stereo for cases with large ITDs */ +#define HYBRID_ITD_MAX /* FhG: Improvement for DFT-stereo for cases with large ITDs */ #define FIX_487_LOWRATE_SBA_TUNING_FIX /* Dlb: TUning fix for low bitrate cases to match theoretical longest SPAR MD bitstream */ #define FIX_490_MASA_2TC_LBR_DTX /* Nokia: Fixes issue 490 by correcting condition. */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 268ad20de7..03c3f1e0a1 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -578,9 +578,7 @@ ivas_error ivas_cpe_enc( #ifdef DEBUG_MODE_DFT hCPE->hStereoDft->res_cod_bits = 0; #endif -#ifdef FIX_395_CNG_BW - stereo_dft_enc_update( hCPE->hStereoDft, min( SWB, sts[0]->bwidth ) ); -#else +#ifndef FIX_395_CNG_BW stereo_dft_enc_update( hCPE->hStereoDft, min( SWB, sts[0]->max_bwidth ) ); #endif } diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index be4e0c0631..202d202965 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -582,11 +582,7 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ -#ifdef FIX_395_CNG_BW - const int16_t bwidth /* i : encoded bandwidth */ -#else const int16_t max_bwidth /* i : maximum encoded bandwidth */ -#endif ) { int16_t i, k_offset; @@ -632,13 +628,9 @@ void stereo_dft_enc_update( hStereoDft->last_res_cod_mode_modify_flag = hStereoDft->res_cod_sw_flag; hStereoDft->res_cod_sw_flag = 0; -#ifdef FIX_395_CNG_BW - /* update band limits in case of rate switching */ - NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[bwidth] / L_FRAME48k; -#else /* update band limits in case of rate switching assuming max_bwidth as BWD output not yet know here */ NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[max_bwidth] / L_FRAME48k; -#endif + hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->hConfig->band_res, NFFT_inner, ENC ); hStereoDft->nbands_dmx = stereo_dft_band_config( hStereoDft->band_limits_dmx, 1, NFFT_inner, ENC ); @@ -2177,6 +2169,22 @@ void stereo_dft_enc_write_BS( nbands_full = hStereoDft->nbands; +#ifdef FIX_395_CNG_BW + if ( core_brate == FRAME_NO_DATA || core_brate == SID_2k40 ) + { + NFFT_inner = min( STEREO_DFT_N_32k_ENC, STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k ); + hStereoDft->band_res[k_offset] = hStereoDft->hConfig->band_res; + hStereoDft->res_pred_mode[k_offset] = 0; + hStereoDft->res_cod_mode[k_offset] = 0; + } + else + { + NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; + } + + /* set number of bands according to bandwidth after BWD */ + hStereoDft->nbands = stereo_dft_band_config(hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC); +#else NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; if ( !( core_brate == SID_2k40 || core_brate == FRAME_NO_DATA ) ) @@ -2184,6 +2192,7 @@ void stereo_dft_enc_write_BS( /* set number of bands according to bandwidth after BWD */ hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC ); } +#endif if ( core_brate == FRAME_NO_DATA ) { -- GitLab From 09a3295e5c70d1d72838a829abf990a16bc166c2 Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Mon, 22 May 2023 10:21:19 +0200 Subject: [PATCH 7/8] clang format fixed --- lib_enc/ivas_stereo_dft_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 202d202965..65e193cdcd 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -582,7 +582,7 @@ void stereo_enc_itd_init( void stereo_dft_enc_update( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ - const int16_t max_bwidth /* i : maximum encoded bandwidth */ + const int16_t max_bwidth /* i : maximum encoded bandwidth */ ) { int16_t i, k_offset; @@ -2183,7 +2183,7 @@ void stereo_dft_enc_write_BS( } /* set number of bands according to bandwidth after BWD */ - hStereoDft->nbands = stereo_dft_band_config(hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC); + hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[k_offset], NFFT_inner, ENC ); #else NFFT_inner = STEREO_DFT_N_MAX_ENC * inner_frame_tbl[hCPE->hCoreCoder[0]->bwidth] / L_FRAME48k; -- GitLab From 31ca5a7993e92d4d13539e119db3a3edc4021358 Mon Sep 17 00:00:00 2001 From: Fredrik Jansson Date: Mon, 29 May 2023 09:55:54 +0200 Subject: [PATCH 8/8] clang format fix --- 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 9ec1af822e..7024723e97 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -37,7 +37,7 @@ #ifndef OPTIONS_H #define OPTIONS_H - /* clang-format off */ +/* clang-format off */ /* ################### Start compiler switches ######################## */ #define SUPPORT_JBM_TRACEFILE /* support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -- GitLab