From 27bf2432a7463f3efb50e49c5a1572ee3303c150 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 17 May 2023 15:39:38 +0200 Subject: [PATCH 1/3] Added fix FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR to do proper deallocation of structures allocated by HRTF file reading --- lib_com/options.h | 2 +- lib_dec/ivas_ism_dec.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 660b511c72..b9fc00c571 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -220,7 +220,7 @@ #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 FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR /* Eri: Fix for issue 462: Use-of-uninitialized memory in external HRTF deallocation in decoder together with BR switching */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5706261093..a09efdb92f 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -41,7 +41,9 @@ #include "debug.h" #endif #include "wmc_auto.h" - +#ifdef FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR +#include "hrtf_file_reader.h" +#endif /*-------------------------------------------------------------------------* * ivas_ism_bitrate_switching() @@ -260,6 +262,9 @@ static ivas_error ivas_ism_bitrate_switching( } /* Close the TD Binaural renderer */ +#ifdef FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR + dealloc_HRTF_binary( st_ivas->hBinRendererTd->HrFiltSet_p ); +#endif if ( st_ivas->hBinRendererTd != NULL ) { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); -- GitLab From a3c49f124f51332598a608d5b343144549b8b760 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 17 May 2023 16:31:27 +0200 Subject: [PATCH 2/3] Change FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR such that it does not deallocate HRTFs loaded from file --- lib_dec/ivas_ism_dec.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index a09efdb92f..4a4da1c1e8 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -41,9 +41,6 @@ #include "debug.h" #endif #include "wmc_auto.h" -#ifdef FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR -#include "hrtf_file_reader.h" -#endif /*-------------------------------------------------------------------------* * ivas_ism_bitrate_switching() @@ -196,10 +193,20 @@ static ivas_error ivas_ism_bitrate_switching( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* Open the TD Binaural renderer */ +#ifdef FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR + if ( st_ivas->hHrtfTD == NULL ) + { + if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#endif } else { @@ -263,8 +270,19 @@ static ivas_error ivas_ism_bitrate_switching( /* Close the TD Binaural renderer */ #ifdef FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR - dealloc_HRTF_binary( st_ivas->hBinRendererTd->HrFiltSet_p ); -#endif + if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) + { + if ( st_ivas->hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + } + + if ( st_ivas->hHrtfTD != NULL ) + { + st_ivas->hHrtfTD = NULL; + } + } +#else if ( st_ivas->hBinRendererTd != NULL ) { ivas_td_binaural_close( &st_ivas->hBinRendererTd ); @@ -274,6 +292,7 @@ static ivas_error ivas_ism_bitrate_switching( { st_ivas->hHrtfTD = NULL; } +#endif } else { -- GitLab From 9be6e473e600dd29551e519bc1369d708734cd70 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 17 May 2023 17:31:30 +0200 Subject: [PATCH 3/3] Fix for HRTF external file rate switching, when bit rate starts below TD renderer bit rate --- lib_dec/ivas_ism_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 4a4da1c1e8..b8a97ad846 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -194,7 +194,7 @@ static ivas_error ivas_ism_bitrate_switching( /* Open the TD Binaural renderer */ #ifdef FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR - if ( st_ivas->hHrtfTD == NULL ) + if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) { if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) { -- GitLab