From 8e07d02691c0f33c297288f996e0e66054d8f7f5 Mon Sep 17 00:00:00 2001 From: muxe6256 Date: Wed, 8 Feb 2023 12:46:34 +0100 Subject: [PATCH 1/5] Initial version fix memory counting --- lib_com/ivas_prot.h | 2 + lib_com/options.h | 2 +- lib_dec/ivas_init_dec.c | 2 + lib_rend/ivas_crend.c | 3 +- lib_rend/ivas_hrtf.c | 4 +- lib_util/hrtf_file_reader.c | 80 +++++++++++++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8..847e39facf 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5384,9 +5384,11 @@ ivas_error ivas_crend_init_from_hrtf_handle( HRTFS_HANDLE hrtf); #endif +#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE ivas_error destroy_SetOfHRTF( HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ ); +#endif #endif diff --git a/lib_com/options.h b/lib_com/options.h index 7ee75363c7..54d21f1459 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -153,7 +153,7 @@ #define FIX_301_PLC /* FhG: issue 301 - fix bug of missing update of overlap buffer for DFT-stereo PLC*/ #define FIX_337_TDREND_INTP /* Issue 337: TD renderer interpolation threshold set too low */ - +#define FIX_MEMORY_COUNTING_HRTF_BINARY_FILE /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 763c83dc39..0cd809b181 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1759,7 +1759,9 @@ void ivas_destroy_dec( /* CRend binaural renderer handle */ if ( st_ivas->hSetOfHRTF != NULL ) { +#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE destroy_SetOfHRTF( st_ivas->hSetOfHRTF ); +#endif ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); } diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index cf29f0c988..e3fc82c9af 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -875,6 +875,7 @@ ivas_error ivas_crend_init_from_setofhrtf( #endif #endif +#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE /*---------------------------------------------------------------------* * destroy_HRTF() * @@ -952,7 +953,7 @@ ivas_error destroy_SetOfHRTF( } #endif - +#endif #ifndef FIX_197_CREND_INTERFACE /*------------------------------------------------------------------------- * ivas_crend_open() diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index ba5f02da63..659ff04ff6 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -40,7 +40,9 @@ #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" - +#ifdef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE +#include "hrtf_file_reader.h" +#endif /*-------------------------------------------------------------------* * Local constants diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 42ab5a869b..c6316b2057 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1511,3 +1511,83 @@ ivas_error create_SetOfHRTF_from_binary( } #endif + +#ifdef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE +/*---------------------------------------------------------------------* + * destroy_HRTF() + * + * Destroy the HRTF CRend handle + *---------------------------------------------------------------------*/ + +static ivas_error destroy_HRTF( + HRTFS_HANDLE *hHRTF /* i/o: HRTF CRend handle */ +) +{ + uint16_t i, j; + + if ( *hHRTF != NULL && hHRTF != NULL ) + { + for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) + { + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + if ( ( *hHRTF )->pIndex_frequency_max[i][j] != NULL ) + { + free( ( *hHRTF )->pIndex_frequency_max[i][j] ); + } + if ( ( *hHRTF )->pOut_to_bin_re[i][j] != NULL ) + { + free( ( *hHRTF )->pOut_to_bin_re[i][j] ); + } + if ( ( *hHRTF )->pOut_to_bin_im[i][j] != NULL ) + { + free( ( *hHRTF )->pOut_to_bin_im[i][j] ); + } + } + } + for ( j = 0; j < BINAURAL_CHANNELS; j++ ) + { + if ( ( *hHRTF )->pIndex_frequency_max_diffuse[j] != NULL ) + { + free( ( *hHRTF )->pIndex_frequency_max_diffuse[j] ); + } + if ( ( *hHRTF )->pOut_to_bin_diffuse_re[j] != NULL ) + { + free( ( *hHRTF )->pOut_to_bin_diffuse_re[j] ); + } + if ( ( *hHRTF )->pOut_to_bin_diffuse_im[j] != NULL ) + { + free( ( *hHRTF )->pOut_to_bin_diffuse_im[j] ); + } + } + + free( *hHRTF ); + *hHRTF = NULL; + } + + return IVAS_ERR_OK; +} + +#ifdef HRTF_BINARY_FILE +/*---------------------------------------------------------------------* + * destroy_SetOfHRTF() + * + * Destroy the HRTF data set. + *---------------------------------------------------------------------*/ + +ivas_error destroy_SetOfHRTF( + HRTFS_CREND_HANDLE hSetOfHRTF /* i/o: Set of HRTF CRend handle */ +) +{ + if ( hSetOfHRTF != NULL ) + { + destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_combined ) ); + destroy_HRTF( &( hSetOfHRTF->hHRTF_hrir_hoa3 ) ); + destroy_HRTF( &( hSetOfHRTF->hHRTF_brir_combined ) ); + } + + return IVAS_ERR_OK; +} + +#endif +#endif -- GitLab From c52f4737e04dfc2a3d53bfb37e08bf56483d6ca0 Mon Sep 17 00:00:00 2001 From: muxe6256 Date: Wed, 8 Feb 2023 16:54:05 +0100 Subject: [PATCH 2/5] fix bug --- apps/decoder.c | 5 +++++ lib_rend/ivas_hrtf.c | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index f018814423..93d991afc9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -538,6 +538,11 @@ cleanup: IVAS_DEC_HRTF_HANDLE hHrtfTD; IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ); dealloc_HRTF_binary( hHrtfTD ); +#ifdef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF; + IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ); + destroy_SetOfHRTF( hSetOfHRTF ); +#endif } IVAS_DEC_Close( &hIvasDec ); CustomLsReader_close( &hLsCustomReader ); diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index c8bda19db2..6d3008e4da 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -40,9 +40,6 @@ #include "ivas_rom_TdBinauralRenderer.h" #include "ivas_error.h" #include "wmc_auto.h" -#ifdef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE -#include "hrtf_file_reader.h" -#endif /*-------------------------------------------------------------------* * Local constants @@ -303,7 +300,9 @@ void ivas_HRTF_CRend_binary_close( return; } - destroy_SetOfHRTF( *hSetOfHRTF ); +#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE + destroy_SetOfHRTF( hSetOfHRTF ); +#endif free( *hSetOfHRTF ); *hSetOfHRTF = NULL; -- GitLab From 007f5243f34e8462b1059d398b74e7d6091b0ace Mon Sep 17 00:00:00 2001 From: muxe6256 Date: Wed, 8 Feb 2023 17:20:23 +0100 Subject: [PATCH 3/5] fix missing #ifdef --- apps/decoder.c | 2 ++ lib_com/options.h | 4 +++- lib_rend/ivas_hrtf.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 93d991afc9..58030803ca 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -538,10 +538,12 @@ cleanup: IVAS_DEC_HRTF_HANDLE hHrtfTD; IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ); dealloc_HRTF_binary( hHrtfTD ); +#ifdef HRTF_BINARY_FILE #ifdef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF; IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ); destroy_SetOfHRTF( hSetOfHRTF ); +#endif #endif } IVAS_DEC_Close( &hIvasDec ); diff --git a/lib_com/options.h b/lib_com/options.h index 8830324dae..12b72bfa57 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,13 +147,15 @@ #endif #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -#define HRTF_BINARY_FILE /* HRTF filters' binary file used for binaural rendering. */ +//#define HRTF_BINARY_FILE /* HRTF filters' binary file used for binaural rendering. */ #define FIX_197_CREND_INTERFACE #define FIX_301_PLC /* FhG: issue 301 - fix bug of missing update of overlap buffer for DFT-stereo PLC*/ #define FIX_337_TDREND_INTP /* Issue 337: TD renderer interpolation threshold set too low */ +#ifdef HRTF_BINARY_FILE /* HRTF filters' binary file used for binaural rendering. */ #define FIX_MEMORY_COUNTING_HRTF_BINARY_FILE +#endif #define FIX_310_TD_REND_DELAY /* Adding HRTF delay being read from ROM/Binary file, fix rounding for delay compensation in renderer */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 6d3008e4da..ea4f74c2f6 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -301,7 +301,7 @@ void ivas_HRTF_CRend_binary_close( } #ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE - destroy_SetOfHRTF( hSetOfHRTF ); + destroy_SetOfHRTF( *hSetOfHRTF ); #endif free( *hSetOfHRTF ); -- GitLab From 2e34a167630bb854ad74f376f4ea956287214c7e Mon Sep 17 00:00:00 2001 From: Arnaud LEFORT Date: Thu, 9 Feb 2023 09:54:53 +0100 Subject: [PATCH 4/5] Missing definition of HRTF_BINARY_FILE added. --- 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 12b72bfa57..cc4c32e07e 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,7 @@ #endif #define FIX_FIX_I59 /* Issue 59: small fix concerning LFE delay rounding */ -//#define HRTF_BINARY_FILE /* HRTF filters' binary file used for binaural rendering. */ +#define HRTF_BINARY_FILE /* HRTF filters' binary file used for binaural rendering. */ #define FIX_197_CREND_INTERFACE #define FIX_301_PLC /* FhG: issue 301 - fix bug of missing update of overlap buffer for DFT-stereo PLC*/ -- GitLab From 0ffb80c598ec93bd4bb32b5dba044ee993d841f9 Mon Sep 17 00:00:00 2001 From: muxe6256 Date: Thu, 9 Feb 2023 10:49:54 +0100 Subject: [PATCH 5/5] fix clang-format error --- lib_dec/ivas_init_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0cd809b181..22f0594db4 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1761,7 +1761,7 @@ void ivas_destroy_dec( { #ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE destroy_SetOfHRTF( st_ivas->hSetOfHRTF ); -#endif +#endif ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); } -- GitLab