From 9741c9811463ee4687b1cb5b6ee2eada6e19da38 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 25 Apr 2024 18:36:41 +0200 Subject: [PATCH 1/8] issue 1070 fixed --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec.c | 4 ++++ lib_dec/ivas_mct_dec.c | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 89f4b7e096..c05707fa22 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,7 @@ #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define FIX_1060_USAN_ARRAY_BOUNDS /* FhG: issue 1060: USAN array-bounds errors */ +#define FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index ffb018c06d..4465702edd 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2430,7 +2430,11 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ) { +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + int32_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; +#else int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; +#endif int16_t ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 368f6e76b7..4d1a095c37 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1352,6 +1352,13 @@ static ivas_error ivas_mc_dec_reconfig( tc_nchan_full_new = tc_nchan_allocate_new; } +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV ) && st_ivas->hDecoderConfig->Opt_Headrotation ) + { + tc_nchan_allocate_new = HOA3_CHANNELS; + tc_nchan_full_new = tc_nchan_allocate_new; + } +#endif if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) { tc_nchan_full_new = 0; -- GitLab From 5a77390248cf98487a5f8c8809a4f1e13564baa2 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 25 Apr 2024 18:49:51 +0200 Subject: [PATCH 2/8] fix windows warnings --- lib_dec/ivas_jbm_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 4465702edd..6eb92f8b88 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2431,7 +2431,8 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( ) { #ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT - int32_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; + int32_t nsamp_to_allocate; + int16_t n_samp_full, n_samp_residual, offset, nchan_residual; #else int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; #endif -- GitLab From 9d9dde3435c618861b1be5fc98675a52b789cf60 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 25 Apr 2024 18:56:02 +0200 Subject: [PATCH 3/8] fix build windows 2 --- lib_dec/ivas_jbm_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6eb92f8b88..3930b42207 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2522,7 +2522,11 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + set_zero_l( hTcBuffer->tc_buffer, nsamp_to_allocate ); +#else set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); +#endif offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) -- GitLab From 91677fc1c75819335deb96fd4bde3a56776e1cff Mon Sep 17 00:00:00 2001 From: marc emerit Date: Tue, 30 Apr 2024 16:51:24 +0200 Subject: [PATCH 4/8] wrong if condition --- lib_dec/ivas_mct_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 7bae36fb18..e86b488e0c 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1345,7 +1345,7 @@ static ivas_error ivas_mc_dec_reconfig( } #ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV ) && st_ivas->hDecoderConfig->Opt_Headrotation ) + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hDecoderConfig->Opt_Headrotation ) { tc_nchan_allocate_new = HOA3_CHANNELS; tc_nchan_full_new = tc_nchan_allocate_new; -- GitLab From 855b38261585230fae3e6368b12c17f2de5cab5a Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 2 May 2024 10:40:16 +0200 Subject: [PATCH 5/8] fix for #1070, fix missing conversion to HOA3 and correct pointers for RS flushing for MCT with BINAURAL_ROOM_REVERB and JBM, remove unnecessary change of number of TC buffer channels --- lib_dec/ivas_jbm_dec.c | 23 +++++++++++++++++++++++ lib_dec/ivas_mct_dec.c | 7 ------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6997c8f63a..f4aa9cc86c 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1665,14 +1665,37 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( mc_mode_old == MC_MODE_MCT ) { +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + int16_t crendInPlaceRotation = FALSE; + + if ( st_ivas->transport_config != intern_config_old && ( intern_config_old == IVAS_AUDIO_CONFIG_FOA || intern_config_old == IVAS_AUDIO_CONFIG_HOA2 || intern_config_old == IVAS_AUDIO_CONFIG_HOA3 ) ) + { + if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) < ( hIntSetupOld->nchan_out_woLFE + hIntSetupOld->num_lfe ) ) + { + crendInPlaceRotation = TRUE; + ivas_mc2sba( st_ivas->hTransSetup, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE ); + } + } +#endif if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#if defined SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : st_ivas->hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : st_ivas->hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + +#endif +#else #if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif #endif { return error; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index e86b488e0c..b49069a6b3 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1344,13 +1344,6 @@ static ivas_error ivas_mc_dec_reconfig( tc_nchan_full_new = tc_nchan_allocate_new; } -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hDecoderConfig->Opt_Headrotation ) - { - tc_nchan_allocate_new = HOA3_CHANNELS; - tc_nchan_full_new = tc_nchan_allocate_new; - } -#endif if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) { tc_nchan_full_new = 0; -- GitLab From 9417064906dfdbf87c79e75f98783f7f68555de1 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 2 May 2024 10:46:52 +0200 Subject: [PATCH 6/8] fix for #1070, add type fix for number of samples to allocate also to the TC buffer open function. --- lib_dec/ivas_jbm_dec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index f4aa9cc86c..73c3d4ba6e 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2335,7 +2335,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + int32_t nsamp_to_allocate; +#else int16_t nsamp_to_allocate; +#endif DECODER_TC_BUFFER_HANDLE hTcBuffer; int16_t nMaxSlotsPerSubframe; int16_t nchan_residual; @@ -2414,7 +2418,11 @@ ivas_error ivas_jbm_dec_tc_buffer_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } +#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT + set_zero_l( hTcBuffer->tc_buffer, nsamp_to_allocate ); +#else set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); +#endif offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) -- GitLab From 9456f4a7abaff3b81f014fe6fd0532e9bcd93bcc Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 2 May 2024 11:23:42 +0200 Subject: [PATCH 7/8] fix for #1070, offset into the TC buffer also needs to be of type int32_t --- lib_dec/ivas_jbm_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 73c3d4ba6e..e97532a146 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -2469,8 +2469,8 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( ) { #ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT - int32_t nsamp_to_allocate; - int16_t n_samp_full, n_samp_residual, offset, nchan_residual; + int32_t nsamp_to_allocate, offset; + int16_t n_samp_full, n_samp_residual, nchan_residual; #else int16_t nsamp_to_allocate, n_samp_full, n_samp_residual, offset, nchan_residual; #endif -- GitLab From 9296af03d16d0bc08ec0e0e0156261ef8bc5d387 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 2 May 2024 11:54:24 +0200 Subject: [PATCH 8/8] fix for #1070, rename define and move it to the Non-BE section --- lib_com/options.h | 2 +- lib_dec/ivas_jbm_dec.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2786bb352d..d9162767d4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -159,7 +159,6 @@ #define FIX_NUM_SUBFRAME_UPDATE #define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ -#define FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ /* #################### End BE switches ################################## */ @@ -170,6 +169,7 @@ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ +#define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e97532a146..c4516e4d4d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1665,7 +1665,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( mc_mode_old == MC_MODE_MCT ) { -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT int16_t crendInPlaceRotation = FALSE; if ( st_ivas->transport_config != intern_config_old && ( intern_config_old == IVAS_AUDIO_CONFIG_FOA || intern_config_old == IVAS_AUDIO_CONFIG_HOA2 || intern_config_old == IVAS_AUDIO_CONFIG_HOA3 ) ) @@ -1679,7 +1679,7 @@ ivas_error ivas_jbm_dec_flush_renderer( #endif if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT #if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : st_ivas->hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) @@ -2335,7 +2335,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT int32_t nsamp_to_allocate; #else int16_t nsamp_to_allocate; @@ -2418,7 +2418,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT set_zero_l( hTcBuffer->tc_buffer, nsamp_to_allocate ); #else set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); @@ -2468,7 +2468,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ) { -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT int32_t nsamp_to_allocate, offset; int16_t n_samp_full, n_samp_residual, nchan_residual; #else @@ -2560,7 +2560,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } -#ifdef FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT +#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT set_zero_l( hTcBuffer->tc_buffer, nsamp_to_allocate ); #else set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); -- GitLab