diff --git a/apps/decoder.c b/apps/decoder.c index 76a053c0f65a99822660a5419ba80166dec89f35..2d6b3f7f1a37d471e0949fd56662f06e5dfeae83 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -538,6 +538,13 @@ 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 ); CustomLsReader_close( &hLsCustomReader ); diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f84e162c45d7585002c4e14f84409c1010af0a5e..c7005f97e98637702f86d99e7cd2dcf703c50ca7 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5387,9 +5387,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 9cbf8bc3389180a366ef602087afc6762a7312fe..7bff2f901b919e2aa83759f52dd8f21c0777694d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -153,6 +153,9 @@ #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 */ #define FIX_334_DEBUG_BE_STEREO_SWITCHING /* FhG: Fix non-BE issue for stereo switching when DEBUGGING is enabled */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 4d0e3e322bf6fabca83c9665450b6e2dc351475d..f8a58c64661e42ee5984b474069d000a533934e4 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1790,7 +1790,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 cf29f0c98852865f657bc0f51e2cfcab4eda0976..e3fc82c9afd83a00dce5fb40c4f1fd4d234ba184 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 84efa1f13e697915b5dfefb56cbee2b4a4b37509..ea4f74c2f6186f3b18ebd41d2878fc31159f7c0f 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -41,7 +41,6 @@ #include "ivas_error.h" #include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -301,7 +300,9 @@ void ivas_HRTF_CRend_binary_close( return; } +#ifndef FIX_MEMORY_COUNTING_HRTF_BINARY_FILE destroy_SetOfHRTF( *hSetOfHRTF ); +#endif free( *hSetOfHRTF ); *hSetOfHRTF = NULL; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 21f2a2988de4ed215aa45978f6eec1bb89f40668..3cae190b5e8c3610b59b736fbc9df90ec0812df3 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1515,3 +1515,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