From fc3f167366f364348350856119543d6a41ac9315 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 5 Dec 2025 10:21:41 +0100 Subject: [PATCH 1/6] fix issue --- lib_com/options.h | 1 + lib_rend/ivas_hrtf_fx.c | 31 +++++++++++++++++++++++++++++++ lib_rend/ivas_prot_rend_fx.h | 6 ++++++ lib_util/hrtf_file_reader.c | 5 ++++- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index b73b5ee8a..5e49d033e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -86,6 +86,7 @@ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ #define FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /* OR : Fix issue basop 2201 hrtf_file_reader crend differs between basop ivas-main and ivas-float-update */ +#define FIX_2249_MEMORY_LEAK_IN_SBA /* OR : issue 2249 : Memory leak in SBA to BINAURAL_ROOM_REVERB with memory instrumentation */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index dee0fe052..a4246e9e0 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -424,3 +424,34 @@ ivas_error ivas_HRTF_statistics_init_fx( return IVAS_ERR_OK; } + +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*---------------------------------------------------------------------* + * ivas_HRTF_statistics_destroy_fx() + * + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ + +void ivas_HRTF_statistics_destroy_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +{ + if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) + { + if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } + } + + return; +} +#endif \ No newline at end of file diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 5f37622a8..469e46f5e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -621,6 +621,12 @@ ivas_error ivas_HRTF_statistics_init_fx( const Word32 sampleRate /* i : Sample rate */ ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +void ivas_HRTF_statistics_destroy_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif + void ivas_HRTF_statistics_close_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ ); diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index d274a0ccf..ee6e384c9 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2071,6 +2071,9 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_destroy_fx( hHrtfStatistics ); +#else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) @@ -2086,7 +2089,7 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } - +#endif ivas_HRTF_statistics_close_fx( hHrtfStatistics ); return; -- GitLab From 3b500614ae786b4f6e7bf9c4faa6c6c2ddec18ab Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 5 Dec 2025 10:31:08 +0100 Subject: [PATCH 2/6] fix merge --- lib_util/hrtf_file_reader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index ee6e384c9..584c2f344 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2142,6 +2142,9 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_destroy_fx( hHrtfStatistics ); +#else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) @@ -2157,7 +2160,7 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } - +#endif ivas_HRTF_statistics_close_fx( hHrtfStatistics ); return; -- GitLab From 630123db7dc75e7d33d694e5da969e16bebc03ba Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 08:59:57 +0100 Subject: [PATCH 3/6] ready for test --- apps/decoder.c | 41 ++- apps/renderer.c | 2 + lib_dec/ivas_init_dec_fx.c | 23 +- lib_dec/lib_dec_fx.c | 12 +- lib_rend/ivas_crend_fx.c | 3 + lib_rend/ivas_hrtf_fx.c | 352 ++++++++++++++++++++++---- lib_rend/ivas_objectRenderer_mix_fx.c | 3 +- lib_rend/ivas_prot_rend_fx.h | 54 +++- lib_rend/ivas_stat_rend.h | 4 + lib_rend/lib_rend_fx.c | 33 ++- lib_util/hrtf_file_reader.c | 162 +++++++++++- 11 files changed, 623 insertions(+), 66 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 401a26761..197dddaa8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -142,9 +142,11 @@ typedef struct hrtfFileReader *hrtfReader; char *hrtfFileName; +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD; IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics; +#endif IVAS_BIN_RENDERER_TYPE binaural_renderer; IVAS_BIN_RENDERER_TYPE binaural_renderer_old; @@ -207,8 +209,10 @@ int main( reset_mem( USE_BYTES ); #endif +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA hHrtfBinary.hHrtfTD = NULL; /* just to avoid compilation warning */ hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */ +#endif splitRendBits.bits_buf = splitRendBitsBuf; @@ -730,11 +734,13 @@ cleanup: free( arg.aeSequence.pValidity ); } +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA if ( arg.hrtfReaderEnabled ) { destroy_td_hrtf( hHrtfBinary.hHrtfTD ); destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics ); } +#endif #ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD // TODO: /* This free differs from float version. @@ -3756,12 +3762,12 @@ static ivas_error load_hrtf_from_file( /*------------------------------------------------------------------------------------------* * Release HRTF binary data *------------------------------------------------------------------------------------------*/ - +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL ) { destroy_td_hrtf( hHrtfBinary->hHrtfTD ); } - +#endif if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK ) { return error; @@ -3783,13 +3789,23 @@ static ivas_error load_hrtf_from_file( if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) { + +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL; + if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3798,7 +3814,11 @@ static ivas_error load_hrtf_from_file( } else { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + destroy_td_hrtf( hHrtfTD ); +#else destroy_td_hrtf( hHrtfBinary->hHrtfTD ); +#endif } } } @@ -3873,15 +3893,28 @@ static ivas_error load_hrtf_from_file( } } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#else if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) +#endif { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); return error; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#else if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) +#endif { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { @@ -3890,7 +3923,11 @@ static ivas_error load_hrtf_from_file( } else { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + destroy_hrtf_statistics( hHrtfStatistics ); +#else destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); +#endif } } } diff --git a/apps/renderer.c b/apps/renderer.c index 464a9f893..4ce0b10f7 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2192,8 +2192,10 @@ cleanup: RotationFileReader_close( &externalOrientationFileReader ); RotationFileReader_close( &referenceRotReader ); Vector3PairFileReader_close( &referenceVectorReader ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA destroy_td_hrtf( hHrtfTD ); destroy_hrtf_statistics( hHrtfStatistics ); +#endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); RenderConfigReader_close( &renderConfigReader ); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index f93b5a69c..e212ee0a6 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1799,7 +1799,18 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { /* Init HRTF statistics */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + /* Allocate HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + + /* Init HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -3548,16 +3559,22 @@ void ivas_destroy_dec_fx( IF( st_ivas->hHrtfTD != NULL ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); +#else BSplineModelEvalDealloc_fx( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); +#endif } /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close_fx( &st_ivas->hHrtfCrend ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv ); +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); @@ -3565,8 +3582,12 @@ void ivas_destroy_dec_fx( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); - /* HRTF statistics */ +/* HRTF statistics */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_binary_close_fx( &st_ivas->hHrtfStatistics ); +#else ivas_HRTF_statistics_close_fx( &st_ivas->hHrtfStatistics ); +#endif /* Config. Renderer */ ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 0bc064d05..882d5f413 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1,4 +1,4 @@ -/****************************************************************************************************** +/****************************************************************************************************** (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., @@ -2516,7 +2516,11 @@ ivas_error IVAS_DEC_HRTF_binary_open( test(); IF( ( EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) && st_ivas->hHrtfTD == NULL ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IF( ( error = ivas_HRTF_td_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2598,7 +2602,11 @@ ivas_error IVAS_DEC_HRTF_binary_close( test(); IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_TDREND ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( &st_ivas->hHrtfTD ); +#else ivas_HRTF_binary_close_fx( &st_ivas->hHrtfTD ); +#endif } test(); @@ -2611,8 +2619,10 @@ ivas_error IVAS_DEC_HRTF_binary_close( test(); IF( !( EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_FASTCONV ) || EQ_32( binaural_renderer_old, IVAS_BIN_RENDERER_TYPE_DEFAULT ) ) ) { +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( &st_ivas->hHrtfFastConv ); +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( &st_ivas->hHrtfFastConv ); diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 845976352..3ee45b7b9 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1812,8 +1812,11 @@ void ivas_rend_closeCldfbRend( pCldfbRend->hCldfbRend->hInputSetup = NULL; } + ivas_binRenderer_close_fx( &pCldfbRend->hCldfbRend ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA ivas_binaural_hrtf_close_fx( &pCldfbRend->hHrtfFastConv ); +#endif ivas_HRTF_fastconv_binary_close_fx( &pCldfbRend->hHrtfFastConv ); return; diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index a4246e9e0..9dbd30c4f 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -40,13 +40,18 @@ #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* - * ivas_HRTF_binary_open() + * ivas_HRTF_td_binary_open() * * Allocate HRTF binary handle for TD renderer *-----------------------------------------------------------------------*/ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_td_binary_open_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#else ivas_error ivas_HRTF_binary_open_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#endif { /* Allocate HR filter set for headphones configuration */ *hHrtfTD = (TDREND_HRFILT_FiltSet_t *) malloc( sizeof( TDREND_HRFILT_FiltSet_t ) ); @@ -60,15 +65,18 @@ ivas_error ivas_HRTF_binary_open_fx( return IVAS_ERR_OK; } - /*-------------------------------------------------------------------* - * ivas_HRTF_binary_close() + * ivas_HRTF_td_binary_close_fx() * * Close HRTF binary handle for TD renderer *-------------------------------------------------------------------*/ - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +void ivas_HRTF_td_binary_close_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#else void ivas_HRTF_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD ) +#endif { test(); IF( hHrtfTD == NULL || *hHrtfTD == NULL ) @@ -76,6 +84,78 @@ void ivas_HRTF_binary_close_fx( return; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + int16_t i; + IF( ( *hHrtfTD )->ModelParams.modelROM ) + { + FOR( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx ); + free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ + FOR( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx ); + IF( ( *hHrtfTD )->ModelEval.hrfModR_fx != NULL ) + { + free( ( *hHrtfTD )->ModelEval.hrfModL_fx ); + } + IF( ( *hHrtfTD )->ModelEval.hrfModL_fx != NULL ) + { + free( ( *hHrtfTD )->ModelEval.hrfModR_fx ); + } + } + else + { + if ( ( *hHrtfTD )->ModelParams.UseItdModel ) + { + free( ( *hHrtfTD )->ModelParamsITD.elevKSeq_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimKSeq_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.W_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimBsShape_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.elevBsShape_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimBsLen_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.azimBsStart_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.elevBsLen_dyn_fx ); + free( ( *hHrtfTD )->ModelParamsITD.elevBsStart_dyn_fx ); + } + free( ( *hHrtfTD )->ModelParams.elevKSeq_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.azim_start_idx_dyn ); + free( ( *hHrtfTD )->ModelParams.azimDim3_dyn ); + free( ( *hHrtfTD )->ModelParams.AlphaL_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.AlphaR_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.azimSegSamples_dyn ); + + free( ( *hHrtfTD )->ModelParams.azimShapeIdx_dyn ); + free( ( *hHrtfTD )->ModelParams.azimShapeSampFactor_dyn ); + free( ( *hHrtfTD )->ModelParams.elevBsLen_dyn ); + free( ( *hHrtfTD )->ModelParams.elevBsStart_dyn ); + free( ( *hHrtfTD )->ModelParams.elevBsShape_dyn_fx ); + + for ( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimBsShape_dyn_fx ); + + free( (void *) ( *hHrtfTD )->ModelParams.azimBsShape_fx ); /* void* cast needed to please both gcc and Visual studio compilers. Deallocating const float** should be fine and gcc agrees, but Visual studio complains. */ + for ( i = 0; i < ( *hHrtfTD )->ModelParams.elevDim3; i++ ) + { + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx[i] ); + } + free( ( *hHrtfTD )->ModelParams.azimKSeq_fx ); + + free( ( *hHrtfTD )->ModelParams.EL_dyn_fx ); + free( ( *hHrtfTD )->ModelParams.ER_dyn_fx ); + + free( ( *hHrtfTD )->ModelEval.hrfModL_fx ); + free( ( *hHrtfTD )->ModelEval.hrfModR_fx ); + } +#endif + free( *hHrtfTD ); *hHrtfTD = NULL; @@ -113,11 +193,17 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( * * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_binary_open_buffers_int16( + Word16 **buffer, /* o : buffer to allocate */ + const UWord32 mem_size /* i : size of buffer */ +) +#else ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( Word16 **buffer, /* o : buffer to allocate */ const UWord32 mem_size /* i : size of buffer */ ) +#endif { *buffer = (Word16 *) malloc( mem_size ); @@ -129,7 +215,88 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( return IVAS_ERR_OK; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_uint16() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_uint16( + uint16_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (uint16_t *) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int32() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int32( + int32_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (int32_t *) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int32_ptr() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( + int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (int32_t **) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_binary_open_buffers_int32_ptr_const() + * + * Allocate buffer with dynamic length for HRTF binary Crend handle + *-----------------------------------------------------------------------*/ +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( + const int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +) +{ + *buffer = (const int32_t **) malloc( mem_size ); + + if ( *buffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary data\n" ); + } + + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------* * ivas_HRTF_CRend_binary_close() * @@ -224,6 +391,11 @@ void ivas_HRTF_fastconv_binary_close_fx( return; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + /* Fastconv HRTF memories */ + ivas_binaural_hrtf_close_fx( hHrtfFastConv ); +#endif + free( *hHrtfFastConv ); *hHrtfFastConv = NULL; @@ -288,42 +460,160 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + set_c( (int8_t *) ( *hHrtfStatistics ), 0, (int32_t) sizeof( HRTFS_STATISTICS ) ); +#endif return IVAS_ERR_OK; } - -/*-----------------------------------------------------------------------* - * ivas_HRTF_statistics_close() +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +/*---------------------------------------------------------------------* + * ivas_HRTF_statistics_close_fx() * - * Close HRTF binary handle for statistics handler - *-----------------------------------------------------------------------*/ + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ -void ivas_HRTF_statistics_close_fx( - HRTFS_STATISTICS **hHrtfStatistics ) +void ivas_HRTF_statistics_binary_close_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) { test(); IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) { return; } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + test(); + IF( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) + { + if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } + } +#endif free( *hHrtfStatistics ); *hHrtfStatistics = NULL; return; } - +#endif /*-----------------------------------------------------------------------* * ivas_HRTF_statistics_init() * * Allocates HRTF statistics handle and initializes from ROM *-----------------------------------------------------------------------*/ - -ivas_error ivas_HRTF_statistics_init_fx( +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_statistics_init_from_rom_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, const Word32 sampleRate ) +#else +ivas_error ivas_HRTF_statistics_init_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, + const Word32 sampleRate ) +#endif { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + + test(); + IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + SWITCH( sampleRate ) + { + case 48000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_48kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_48kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_48kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + case 32000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_32kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC, Q28 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_32kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC, Q26 - defaultHRIR_Q_32kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + case 16000: + ( *hHrtfStatistics )->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + ( *hHrtfStatistics )->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + IF( ( *hHrtfStatistics )->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + Copy_Scale_sig_16_32_r( defaultHRIR_left_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_l_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_right_avg_power_16kHz_fx, ( *hHrtfStatistics )->average_energy_r_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q28 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + Copy_Scale_sig_16_32_r( defaultHRIR_coherence_16kHz_fx, ( *hHrtfStatistics )->inter_aural_coherence_dyn, LR_IAC_LENGTH_NR_FC_16KHZ, Q26 - defaultHRIR_Q_16kHz_fx ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + ( *hHrtfStatistics )->average_energy_l = (const Word32 *) ( *hHrtfStatistics )->average_energy_l_dyn; + ( *hHrtfStatistics )->average_energy_r = (const Word32 *) ( *hHrtfStatistics )->average_energy_r_dyn; + ( *hHrtfStatistics )->inter_aural_coherence = (const Word32 *) ( *hHrtfStatistics )->inter_aural_coherence_dyn; + BREAK; + default: + ( *hHrtfStatistics )->average_energy_l = NULL; + ( *hHrtfStatistics )->average_energy_r = NULL; + ( *hHrtfStatistics )->inter_aural_coherence = NULL; + BREAK; + } + ( *hHrtfStatistics )->fromROM = TRUE; +#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD + ( *hHrtfStatistics )->fromROM = FALSE; // TODO: temporary hack until HRTF statistics ROM tables are converted from Word16 to Word32 +#endif + +#else HRTFS_STATISTICS *HrtfStatistics; test(); @@ -421,37 +711,7 @@ ivas_error ivas_HRTF_statistics_init_fx( #endif *hHrtfStatistics = HrtfStatistics; +#endif return IVAS_ERR_OK; } - -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA -/*---------------------------------------------------------------------* - * ivas_HRTF_statistics_destroy_fx() - * - * Destroy the HRTF statistics set. - *---------------------------------------------------------------------*/ - -void ivas_HRTF_statistics_destroy_fx( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ -) -{ - if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) - { - if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_l_dyn ); - } - if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) - { - free( ( *hHrtfStatistics )->average_energy_r_dyn ); - } - if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) - { - free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); - } - } - - return; -} -#endif \ No newline at end of file diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 28ee13931..35cf31546 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -151,6 +151,7 @@ void TDREND_MIX_Dealloc_fx( { BSplineModelEvalDealloc_fx( &hBinRendererTd->HrFiltSet_p->ModelParams, &hBinRendererTd->HrFiltSet_p->ModelEval ); } +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA ELSE { IF( hBinRendererTd->HrFiltSet_p->Elev_p_fx != NULL ) @@ -174,7 +175,7 @@ void TDREND_MIX_Dealloc_fx( hBinRendererTd->HrFiltSet_p->RightFiltSet_p_fx = NULL; } } - +#endif IF( hBinRendererTd->HrFiltSet_p->ModelParams.modelROM ) { IF( hBinRendererTd->HrFiltSet_p->ModelParams.UseItdModel ) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 469e46f5e..fe2dada8a 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -578,7 +578,15 @@ void ivas_masa_ext_dirac_render_fx( /*----------------------------------------------------------------------------------* * HRTF *----------------------------------------------------------------------------------*/ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_td_binary_open_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); +void ivas_HRTF_td_binary_close_fx( + TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ +); +#else ivas_error ivas_HRTF_binary_open_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); @@ -586,6 +594,7 @@ ivas_error ivas_HRTF_binary_open_fx( void ivas_HRTF_binary_close_fx( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); +#endif ivas_error ivas_HRTF_fastconv_binary_open_fx( HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ @@ -607,29 +616,64 @@ ivas_error ivas_HRTF_CRend_binary_open_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_binary_open_buffers_uint16( + uint16_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int16( + int16_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int32( + int32_t **buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( + int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); + +ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( + const int32_t ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ +); +#else ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( Word16 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ); +#endif void ivas_HRTF_CRend_binary_close_fx( HRTFS_CREND_DATA **hHrtfCrend /* i/o: Crend HRTF handle */ ); -ivas_error ivas_HRTF_statistics_init_fx( +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +ivas_error ivas_HRTF_statistics_init_from_rom_fx( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ const Word32 sampleRate /* i : Sample rate */ ); - -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA -void ivas_HRTF_statistics_destroy_fx( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +#else +ivas_error ivas_HRTF_statistics_init_fx( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ + const Word32 sampleRate /* i : Sample rate */ ); #endif +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_close_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ ); +#endif + +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA +void ivas_HRTF_statistics_binary_close_fx( + HRTFS_STATISTICS **hHrtfStatistics ); /* i/o: HRTF statistics structure */ +#endif ivas_error ivas_HRTF_statistics_binary_open_fx( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index a113298e8..f06fcee67 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1166,13 +1166,17 @@ typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct Word16 NumPos; Word16 NumElev; Word32 Dist_fx; +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA Word32 *ItdSet_p_fx; +#endif Word16 FiltLength; +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA Word16 *Azim_p_fx; Word16 *Elev_p_fx; Word16 *ItdSetNominal_p_fx; Word16 *LeftFiltSet_p_fx; Word16 *RightFiltSet_p_fx; +#endif ModelParams_t ModelParams; ModelEval_t ModelEval; ModelParamsITD_t ModelParamsITD; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 9b42d17b2..a3aa7747b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -3786,10 +3786,17 @@ ivas_error IVAS_REND_Open( IF( asHrtfBinary ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IF( NE_32( ( error = ivas_HRTF_td_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) + { + return error; + } +#else IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) { return error; } +#endif IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ) ), IVAS_ERR_OK ) ) { return error; @@ -3810,7 +3817,21 @@ ivas_error IVAS_REND_Open( IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( hIvasRend->hHrtfs.hHrtfStatistics == NULL ) + { + /* Allocate HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + + /* Init HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_HRTF_statistics_init_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -9806,15 +9827,25 @@ void IVAS_REND_Close( ivas_external_orientation_close_fx( &hIvasRend->hExternalOrientationData ); ivas_combined_orientation_close_fx( &hIvasRend->hCombinedOrientationData ); +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( &hIvasRend->hHrtfs.hHrtfFastConv ); +#endif - /* Parametric binauralizer HRTF filters */ +/* Parametric binauralizer HRTF filters */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); +#else ivas_HRTF_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ); +#endif ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfCrend ) ); ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfParambin ) ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_statistics_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#else ivas_HRTF_statistics_close_fx( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#endif free( hIvasRend ); *phIvasRend = NULL; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 18422694d..95c5e634b 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -296,7 +296,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->elevKSeq_dyn_fx, ( modelITD->elevDim3 - 2 ) * sizeof( float ) ); +#else modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( ( modelITD->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( modelITD->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -311,7 +315,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); fread( &modelITD->azimDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->azimKSeq_dyn_fx, ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); +#else modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ +#endif v_tmp16 = (Word16 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word16 ) ); if ( modelITD->azimKSeq_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -326,7 +334,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->W_dyn_fx, tmp * sizeof( float ) ); +#else modelITD->W_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( modelITD->W_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -348,13 +360,21 @@ static ivas_error TDREND_LoadBSplineBinaryITD( free( v_tmp16 ); /* azimuth */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->azimBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->azimBsLen_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( modelITD->azimBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->azimBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->azimBsStart_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -362,7 +382,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->azimBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->azimBsShape_dyn_fx, tmp * sizeof( float ) ); +#else modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); if ( modelITD->azimBsShape_dyn_fx == NULL || v_tmp16 == NULL ) { @@ -379,13 +403,21 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( &modelITD->azimSegSamples, sizeof( Word16 ), 1, f_hrtf ); /* elevation */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->elevBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->elevBsLen_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( modelITD->elevBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else modelITD->elevBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( modelITD->elevBsStart_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -393,7 +425,11 @@ static ivas_error TDREND_LoadBSplineBinaryITD( fread( modelITD->elevBsStart_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &modelITD->elevBsShape_dyn_fx, tmp * sizeof( float ) ); +#else modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( modelITD->elevBsShape_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -489,7 +525,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->K, sizeof( Word16 ), 1, f_hrtf ); fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->elevKSeq_dyn_fx, ( model->elevDim3 - 2 ) * sizeof( float ) ); +#else model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word16 ) ); if ( model->elevKSeq_dyn_fx == NULL || v_tmp16 == NULL ) @@ -503,9 +543,21 @@ static ivas_error TDREND_LoadBSplineBinary( model->elevKSeq_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q22 - factor_Q ); } free( v_tmp16 ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimKSeq_fx, model->elevDim3 * sizeof( float * ) ); +#else model->azimKSeq_fx = (Word32 **) malloc( model->elevDim3 * sizeof( Word32 * ) ); +#endif if ( model->azimDim3_dyn == NULL || model->azim_start_idx_dyn == NULL || model->azimKSeq_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -515,7 +567,11 @@ static ivas_error TDREND_LoadBSplineBinary( { fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf ); fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->azimKSeq_fx[i], ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) ); +#else model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word16 ) ); if ( model->azimKSeq_fx[i] == NULL || v_tmp16 == NULL ) @@ -531,8 +587,11 @@ static ivas_error TDREND_LoadBSplineBinary( free( v_tmp16 ); } fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf ); - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->AlphaL_dyn_fx, model->AlphaN * model->K * sizeof( float ) ); +#else model->AlphaL_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); +#endif v_tmp16 = (Word16 *) malloc( model->AlphaN * model->K * sizeof( Word16 ) ); if ( model->AlphaL_dyn_fx == NULL || v_tmp16 == NULL ) @@ -550,7 +609,11 @@ static ivas_error TDREND_LoadBSplineBinary( { model->AlphaL_dyn_fx[j] = L_shl_r( L_deposit_l( v_tmp16[j] ), Q30 - factor_Q ); } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->AlphaR_dyn_fx, model->AlphaN * model->K * sizeof( float ) ); +#else model->AlphaR_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); +#endif if ( model->AlphaR_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -566,9 +629,21 @@ static ivas_error TDREND_LoadBSplineBinary( /* azimuth */ fread( &model->num_unique_azim_splines, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32_ptr_const( &model->azimBsShape_fx, model->num_unique_azim_splines * sizeof( float * ) ); +#else model->azimBsShape_fx = (const Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32_ptr( &model->azimBsShape_dyn_fx, model->num_unique_azim_splines * sizeof( float * ) ); +#else model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); +#endif +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( int16_t ) ); +#else model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ); +#endif if ( model->azimBsShape_fx == NULL || model->azimBsShape_dyn_fx == NULL || model->azimSegSamples_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -577,7 +652,11 @@ static ivas_error TDREND_LoadBSplineBinary( for ( i = 0; i < model->num_unique_azim_splines; i++ ) { fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->azimBsShape_dyn_fx[i], tmp * sizeof( float ) ); +#else model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( model->azimBsShape_dyn_fx[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -597,8 +676,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf ); free( v_tmp16 ); } - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif if ( model->azimShapeIdx_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -612,13 +694,21 @@ static ivas_error TDREND_LoadBSplineBinary( fread( model->azimShapeSampFactor_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); /* elevation */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else model->elevBsLen_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( model->elevBsLen_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( model->elevBsLen_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); +#else model->elevBsStart_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); +#endif if ( model->elevBsStart_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -627,7 +717,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); v_tmp16 = (Word16 *) malloc( tmp * sizeof( Word16 ) ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->elevBsShape_dyn_fx, tmp * sizeof( float ) ); +#else model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); +#endif if ( model->elevBsShape_dyn_fx == NULL || v_tmp16 == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -643,7 +737,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->EL_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( float ) ); +#else model->EL_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); +#endif if ( model->EL_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -655,7 +753,11 @@ static ivas_error TDREND_LoadBSplineBinary( fread( (Word32 *) model->EL_dyn_fx, sizeof( Word32 ), model->AlphaN * HRTF_MODEL_N_SECTIONS, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &model->ER_dyn_fx, model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( float ) ); +#else model->ER_dyn_fx = (Word32 *) malloc( model->AlphaN * HRTF_MODEL_N_SECTIONS * sizeof( Word32 ) ); +#endif if ( model->ER_dyn_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -685,8 +787,13 @@ static ivas_error TDREND_LoadBSplineBinary( HRTF_model_precalc( model ); HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModL_fx, model->K * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &HrFiltSet_p->ModelEval.hrfModR_fx, model->K * sizeof( float ) ); +#else HrFiltSet_p->ModelEval.hrfModL_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); HrFiltSet_p->ModelEval.hrfModR_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); +#endif if ( HrFiltSet_p->ModelEval.hrfModL_fx == NULL || HrFiltSet_p->ModelEval.hrfModR_fx == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -799,10 +906,15 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_l_dyn, lr_iac_len * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->average_energy_r_dyn, lr_iac_len * sizeof( float ) ); + ivas_HRTF_binary_open_buffers_int32( &hHrtfStatistics->inter_aural_coherence_dyn, lr_iac_len * sizeof( float ) ); +#else hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - +#endif if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -1013,7 +1125,6 @@ ivas_error load_TDrend_HRTF_binary( return TDREND_MIX_LoadHRTF( hrtfReader->file, sampleRate, hHrtf ); } - /*---------------------------------------------------------------------* * destroy_td_hrtf() * @@ -1024,8 +1135,11 @@ void destroy_td_hrtf( IVAS_DEC_HRTF_TD_HANDLE *hHrtf /* i/o: TD rend. HRTF handle */ ) { - int16_t i; +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_td_binary_close_fx( hHrtf ); +#else + int16_t i; if ( ( hHrtf == NULL ) || ( *hHrtf == NULL ) ) { return; @@ -1077,8 +1191,9 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL_fx ); free( ( *hHrtf )->ModelEval.hrfModR_fx ); } - ivas_HRTF_binary_close_fx( hHrtf ); +#endif + return; } @@ -1150,7 +1265,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_dyn_fx[i][j], mem_size ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1177,7 +1296,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1220,7 +1343,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_re_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1247,7 +1374,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( { for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_im_dyn_fx[i][j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1282,7 +1413,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* coeff_diffuse_re : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_re_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1306,7 +1441,11 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* coeff_diffuse_im : The size depends on pIndex_frequency_max_diffuse */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_HRTF_CRend_binary_open_buffers_int16( &( *hHRTF )->pOut_to_bin_diffuse_im_dyn_fx[j], mem_size_buf ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1992,6 +2131,9 @@ void destroy_crend_hrtf( IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend /* i/o: Crend HRTF handle */ ) { +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_CRend_binary_close_fx( hHrtfCrend ); +#else uint16_t i, j; test(); @@ -2033,6 +2175,7 @@ void destroy_crend_hrtf( free( *hHrtfCrend ); *hHrtfCrend = NULL; } +#endif return; } @@ -2048,9 +2191,10 @@ void destroy_fastconv_hrtf( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv /* i/o: FastConv HRTF handle */ ) { +#ifndef FIX_2249_MEMORY_LEAK_IN_SBA /* Fastconv HRTF memories */ ivas_binaural_hrtf_close_fx( hHrtfFastConv ); - +#endif /* Fastconv HRTF filters */ ivas_HRTF_fastconv_binary_close_fx( hHrtfFastConv ); @@ -2084,7 +2228,7 @@ void destroy_hrtf_statistics( ) { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_statistics_destroy_fx( hHrtfStatistics ); + ivas_HRTF_statistics_binary_close_fx( hHrtfStatistics ); #else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { @@ -2101,8 +2245,8 @@ void destroy_hrtf_statistics( free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } } -#endif ivas_HRTF_statistics_close_fx( hHrtfStatistics ); +#endif return; } -- GitLab From 5552d2c0d9ca7fa071c5bf6f3ec4b28dd893f20d Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 11:24:00 +0100 Subject: [PATCH 4/6] fix usan and missing switch --- apps/decoder.c | 28 +++++++++++++++++----------- lib_dec/ivas_init_dec_fx.c | 10 ++++++---- lib_dec/lib_dec.h | 5 +++++ lib_dec/lib_dec_fx.c | 15 +++++++++++++-- lib_rend/ivas_hrtf_fx.c | 12 ++++++++---- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 197dddaa8..7e9113933 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -740,7 +740,6 @@ cleanup: destroy_td_hrtf( hHrtfBinary.hHrtfTD ); destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics ); } -#endif #ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD // TODO: /* This free differs from float version. @@ -748,6 +747,7 @@ cleanup: IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); destroy_hrtf_statistics( hHrtfStatistics ); +#endif #endif IVAS_DEC_Close( &hIvasDec ); CustomLsReader_close( &hLsCustomReader ); @@ -3901,7 +3901,8 @@ static ivas_error load_hrtf_from_file( { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; - if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + Word16 initFromRom; + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics, &initFromRom ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK ) #endif @@ -3911,25 +3912,30 @@ static ivas_error load_hrtf_from_file( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) + if ( initFromRom ) + { + if ( ( error = load_reverb_binary( *hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #else if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK ) #endif - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); - return error; - } - else { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName ); + return error; + } + else + { #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - destroy_hrtf_statistics( hHrtfStatistics ); + destroy_hrtf_statistics( hHrtfStatistics ); #else destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics ); #endif + } } +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA } +#endif } return IVAS_ERR_OK; diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index e212ee0a6..a554e3a87 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1800,12 +1800,14 @@ ivas_error ivas_init_decoder_fx( { /* Init HRTF statistics */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - /* Allocate HRTF statistics */ - IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + if ( st_ivas->hHrtfStatistics == NULL ) { - return error; + /* Allocate HRTF statistics */ + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open_fx( &( st_ivas->hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } } - /* Init HRTF statistics */ IF( NE_32( ( error = ivas_HRTF_statistics_init_from_rom_fx( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) #else diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 58c33c92d..3d60a042d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -440,6 +440,11 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( ivas_error IVAS_DEC_GetHrtfStatisticsHandle( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + , /* o : HRTF statistics handle */ + Word16 *intialisedFromRom /* o : int16_t handle */ +#endif + ); ivas_error IVAS_DEC_HRTF_binary_open( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 882d5f413..3954b7436 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2470,18 +2470,29 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + , /* o : HRTF statistics handle */ + Word16 *intialisedFromRom /* o : int16_t handle */ +#endif ) { test(); test(); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL || intialisedFromRom == NULL ) +#else IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) +#endif { return IVAS_ERR_WRONG_PARAMS; } *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + *intialisedFromRom = hIvasDec->st_ivas->hHrtfStatistics->fromROM; +#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 9dbd30c4f..0b435be32 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -466,16 +466,20 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( return IVAS_ERR_OK; } -#ifdef FIX_2249_MEMORY_LEAK_IN_SBA /*---------------------------------------------------------------------* - * ivas_HRTF_statistics_close_fx() + * ivas_HRTF_statistics_binary_close_fx() * * Destroy the HRTF statistics set. *---------------------------------------------------------------------*/ - +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA void ivas_HRTF_statistics_binary_close_fx( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) +#else +void ivas_HRTF_statistics_close_fx( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +#endif { test(); IF( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) @@ -506,7 +510,7 @@ void ivas_HRTF_statistics_binary_close_fx( return; } -#endif + /*-----------------------------------------------------------------------* * ivas_HRTF_statistics_init() -- GitLab From 6e9d1a7e08730bb98ff1597d81157161429a7802 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 14:47:50 +0100 Subject: [PATCH 5/6] bug smoke test fix --- lib_util/hrtf_file_reader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 95c5e634b..3247b27db 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -686,7 +686,11 @@ static ivas_error TDREND_LoadBSplineBinary( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); +#ifdef FIX_2249_MEMORY_LEAK_IN_SBA + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); +#else model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); +#endif if ( model->azimShapeSampFactor_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); -- GitLab From fb9b4f1e7e94ff4bea52a428dfd3cafbf2e01b5c Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 12 Dec 2025 15:20:19 +0100 Subject: [PATCH 6/6] bug bix and code refactoring --- lib_rend/ivas_hrtf_fx.c | 22 +++--- lib_util/hrtf_file_reader.c | 134 ++++++++++++++++++------------------ 2 files changed, 78 insertions(+), 78 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 0b435be32..7854afbbb 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -85,7 +85,7 @@ void ivas_HRTF_binary_close_fx( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - int16_t i; + Word16 i; IF( ( *hHrtfTD )->ModelParams.modelROM ) { FOR( i = 0; i < ( *hHrtfTD )->ModelParams.num_unique_azim_splines; i++ ) @@ -222,11 +222,11 @@ ivas_error ivas_HRTF_CRend_binary_open_buffers_int16( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_uint16( - uint16_t **buffer, /* o : buffer to allocate */ + UWord16 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (uint16_t *) malloc( mem_size ); + *buffer = (UWord16 *) malloc( mem_size ); if ( *buffer == NULL ) { @@ -242,11 +242,11 @@ ivas_error ivas_HRTF_binary_open_buffers_uint16( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_int32( - int32_t **buffer, /* o : buffer to allocate */ + Word32 **buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (int32_t *) malloc( mem_size ); + *buffer = (Word32 *) malloc( mem_size ); if ( *buffer == NULL ) { @@ -262,11 +262,11 @@ ivas_error ivas_HRTF_binary_open_buffers_int32( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( - int32_t ***buffer, /* o : buffer to allocate */ + Word32 ***buffer, /* o : buffer to allocate */ const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (int32_t **) malloc( mem_size ); + *buffer = (Word32 **) malloc( mem_size ); if ( *buffer == NULL ) { @@ -282,11 +282,11 @@ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr( * Allocate buffer with dynamic length for HRTF binary Crend handle *-----------------------------------------------------------------------*/ ivas_error ivas_HRTF_binary_open_buffers_int32_ptr_const( - const int32_t ***buffer, /* o : buffer to allocate */ - const uint32_t mem_size /* i : size of buffer */ + const Word32 ***buffer, /* o : buffer to allocate */ + const uint32_t mem_size /* i : size of buffer */ ) { - *buffer = (const int32_t **) malloc( mem_size ); + *buffer = (const Word32 **) malloc( mem_size ); if ( *buffer == NULL ) { @@ -461,7 +461,7 @@ ivas_error ivas_HRTF_statistics_binary_open_fx( } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - set_c( (int8_t *) ( *hHrtfStatistics ), 0, (int32_t) sizeof( HRTFS_STATISTICS ) ); + set_c( (Word8 *) ( *hHrtfStatistics ), 0, (Word32) sizeof( HRTFS_STATISTICS ) ); #endif return IVAS_ERR_OK; } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 3247b27db..5f1b47235 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -51,9 +51,9 @@ struct hrtfFileReader typedef struct ivas_hrtfs_file_header_t { char identifier[8]; - int32_t file_size; - int16_t nb_hrtf; - int32_t max_data_size; + Word32 file_size; + Word16 nb_hrtf; + Word32 max_data_size; } ivas_hrtfs_file_header_t; @@ -129,7 +129,7 @@ static ivas_error read_and_check_hrtf_binary_file_header( ivas_hrtfs_file_header_t *hrtf_file_header, FILE *f_hrtf ) { - int32_t file_size; + Word32 file_size; if ( hrtf_file_header == NULL || f_hrtf == NULL ) { @@ -146,7 +146,7 @@ static ivas_error read_and_check_hrtf_binary_file_header( file_size = ftell( f_hrtf ); fseek( f_hrtf, 0, SEEK_SET ); - if ( file_size < (int32_t) sizeof( ivas_hrtfs_file_header_t ) ) + if ( file_size < (Word32) sizeof( ivas_hrtfs_file_header_t ) ) { return IVAS_ERROR( IVAS_ERR_END_OF_FILE, "HRTF binary file not compliant (size of file header)" ); } @@ -230,7 +230,7 @@ static ivas_error read_hrtf_binary_header( /* Sampling Frequency (4 bytes) */ /* Raw data size (4 bytes) */ - if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) ) + if ( ( fread( &( hrtf_header->rend_type ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( Word32 ), 1, f_hrtf ) == 1 ) ) { return IVAS_ERR_OK; } @@ -361,7 +361,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( /* azimuth */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->azimBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -371,7 +371,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( modelITD->azimBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->azimBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->azimBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -404,7 +404,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( /* elevation */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsLen_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->elevBsLen_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -414,7 +414,7 @@ static ivas_error TDREND_LoadBSplineBinaryITD( } fread( modelITD->elevBsLen_dyn_fx, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &modelITD->elevBsStart_dyn_fx, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else modelITD->elevBsStart_dyn_fx = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -544,12 +544,12 @@ static ivas_error TDREND_LoadBSplineBinary( } free( v_tmp16 ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimDim3_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azim_start_idx_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif @@ -640,7 +640,7 @@ static ivas_error TDREND_LoadBSplineBinary( model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); #endif #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimSegSamples_dyn, model->num_unique_azim_splines * sizeof( Word16 ) ); #else model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ); #endif @@ -677,7 +677,7 @@ static ivas_error TDREND_LoadBSplineBinary( free( v_tmp16 ); } #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif @@ -687,7 +687,7 @@ static ivas_error TDREND_LoadBSplineBinary( } fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->azimShapeIdx_dyn, model->elevDim3 * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->azimShapeSampFactor_dyn, model->elevDim3 * sizeof( Word16 ) ); #else model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); #endif @@ -699,7 +699,7 @@ static ivas_error TDREND_LoadBSplineBinary( /* elevation */ #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->elevBsLen_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else model->elevBsLen_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -709,7 +709,7 @@ static ivas_error TDREND_LoadBSplineBinary( } fread( model->elevBsLen_dyn, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA - ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( int16_t ) ); + ivas_HRTF_binary_open_buffers_int16( &model->elevBsStart_dyn, HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #else model->elevBsStart_dyn = (Word16 *) malloc( HRTF_MODEL_BSPLINE_NUM_COEFFS * sizeof( Word16 ) ); #endif @@ -830,12 +830,12 @@ static ivas_error load_reverb_from_binary( bool is_reverb; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; + Word16 hrtf_id; ivas_hrtfs_header_t hrtf_header; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; - int16_t lr_iac_len; - int16_t ind; + Word16 lr_iac_len; + Word16 ind; Word16 factorQ; Word16 tmp16; @@ -989,13 +989,13 @@ static ivas_error TDREND_MIX_LoadHRTF( IVAS_DEC_HRTF_TD_HANDLE HrFiltSet_p /* o : Loaded HR filter set */ ) { - int16_t tmp; + Word16 tmp; bool is_tdrend; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; + Word16 hrtf_id; ivas_hrtfs_header_t hrtf_header; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; if ( f_hrtf == NULL ) @@ -1010,7 +1010,7 @@ static ivas_error TDREND_MIX_LoadHRTF( /* try if it is old format for BE tests*/ fseek( f_hrtf, 0, SEEK_SET ); - if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 ) + if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) { header_check_result = IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1082,7 +1082,7 @@ static ivas_error TDREND_MIX_LoadHRTF( if ( is_tdrend ) { - if ( fread( &tmp, 1, sizeof( int16_t ), f_hrtf ) == 0 ) + if ( fread( &tmp, 1, sizeof( Word16 ), f_hrtf ) == 0 ) { return IVAS_ERROR( IVAS_ERR_FAILED_FILE_READ, "Error in HRTF file reading" ); } @@ -1115,7 +1115,7 @@ static ivas_error TDREND_MIX_LoadHRTF( ivas_error load_TDrend_HRTF_binary( IVAS_DEC_HRTF_TD_HANDLE hHrtf, /* i/o: TD rend. HRTF handle */ - const int32_t sampleRate, /* i : sample rate */ + const Word32 sampleRate, /* i : sample rate */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ) { @@ -1143,7 +1143,7 @@ void destroy_td_hrtf( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_td_binary_close_fx( hHrtf ); #else - int16_t i; + Word16 i; if ( ( hHrtf == NULL ) || ( *hHrtf == NULL ) ) { return; @@ -1299,7 +1299,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* pIndex_frequency_max_diffuse (the size depends on num_iterations_diffuse) */ for ( j = 0; j < BINAURAL_CHANNELS; j++ ) { - mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( uint16_t ); + mem_size = ( *hHRTF )->num_iterations_diffuse[j] * sizeof( UWord16 ); #ifdef FIX_2249_MEMORY_LEAK_IN_SBA if ( ( error = ivas_HRTF_binary_open_buffers_int16( &( *hHRTF )->pIndex_frequency_max_diffuse_dyn_fx[j], mem_size ) ) != IVAS_ERR_OK ) #else @@ -1316,7 +1316,7 @@ static ivas_error create_Crend_HRTF_from_rawdata( /* index_frequency_max_diffuse */ ( *hHRTF )->index_frequency_max_diffuse = *( (Word16 *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* inv_diffuse_weight Q factor*/ ( *hHRTF )->factor_Q_inv_diffuse_weight = Q15 - *( (Word16 *) ( hrtf_data_rptr ) ); @@ -1405,8 +1405,8 @@ static ivas_error create_Crend_HRTF_from_rawdata( } /* max_total_num_fsamp_per_iteration_diff */ - max_total_num_fsamp_per_iteration_diff = *( (uint32_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint32_t ); + max_total_num_fsamp_per_iteration_diff = *( (UWord32 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord32 ); mem_size_buf = max_total_num_fsamp_per_iteration_diff * sizeof( Word16 ); @@ -1513,17 +1513,17 @@ static ivas_error create_fastconv_HRTF_from_rawdata( latency_s = *( (Word32 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word32 ); - if ( BINAURAL_CONVBANDS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( BINAURAL_CONVBANDS != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (BINAURAL_CONVBANDS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); - nbchan = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + nbchan = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); - ntaps = *( (uint16_t *) ( hrtf_data_rptr ) ); - hrtf_data_rptr += sizeof( uint16_t ); + ntaps = *( (UWord16 *) ( hrtf_data_rptr ) ); + hrtf_data_rptr += sizeof( UWord16 ); ( *hHRTF )->ntaps = ntaps; ( *hHRTF )->FASTCONV_latency_s_Q_fx = Q31 - factorQ; @@ -1689,11 +1689,11 @@ static ivas_error create_parambin_HRTF_from_rawdata( char *hrtf_data /* i : pointer to binary file */ ) { - int16_t i, j, k; + Word16 i, j, k; char *hrtf_data_rptr; - uint32_t data_size_tmp; + UWord32 data_size_tmp; Word16 factorQ; - int16_t *ptW16; + Word16 *ptW16; if ( hrtf_data == NULL ) { @@ -1703,30 +1703,30 @@ static ivas_error create_parambin_HRTF_from_rawdata( hrtf_data_rptr = hrtf_data; /* HRTF_SH_CHANNELS */ - if ( HRTF_SH_CHANNELS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( HRTF_SH_CHANNELS != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_SH_CHANNELS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* HRTF_NUM_BINS */ - if ( HRTF_NUM_BINS != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( HRTF_NUM_BINS != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (HRTF_NUM_BINS)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* HRTF */ /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - data_size_tmp = HRTF_NUM_BINS * sizeof( int16_t ); + data_size_tmp = HRTF_NUM_BINS * sizeof( Word16 ); for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < HRTF_NUM_BINS; k++ ) { @@ -1739,7 +1739,7 @@ static ivas_error create_parambin_HRTF_from_rawdata( { for ( j = 0; j < HRTF_SH_CHANNELS; j++ ) { - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( k = 0; k < HRTF_NUM_BINS; k++ ) { ( *hHRTF )->hrtfShCoeffsIm_fx[i][j][k] = shl_r( ptW16[k], Q14 - factorQ ); @@ -1749,44 +1749,44 @@ static ivas_error create_parambin_HRTF_from_rawdata( } /* Reverb Parameters */ - if ( CLDFB_NO_CHANNELS_MAX != *( (uint16_t *) ( hrtf_data_rptr ) ) ) + if ( CLDFB_NO_CHANNELS_MAX != *( (UWord16 *) ( hrtf_data_rptr ) ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "HRTF binary file not compliant (CLDFB_NO_CHANNELS_MAX)" ); } - hrtf_data_rptr += sizeof( uint16_t ); + hrtf_data_rptr += sizeof( UWord16 ); /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { ( *hHRTF )->parametricReverberationTimes_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q26 - factorQ ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ); /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { ( *hHRTF )->parametricReverberationEneCorrections_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q31 - factorQ ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ); /* Q factor*/ factorQ = *( (Word16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( Word16 ); - ptW16 = (int16_t *) hrtf_data_rptr; + ptW16 = (Word16 *) hrtf_data_rptr; for ( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { ( *hHRTF )->parametricEarlyPartEneCorrection_fx[j] = L_shl_r( L_deposit_l( ptW16[j] ), Q28 - factorQ ); } - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( int16_t ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ); return IVAS_ERR_OK; } @@ -1806,13 +1806,13 @@ ivas_error load_fastconv_HRTF_from_binary( ) { FILE *f_hrtf; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; ivas_hrtfs_header_t hrtf_header; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; - int16_t asFastconv = 0; + Word16 hrtf_id; + Word16 asFastconv = 0; bool load = false; BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; @@ -1918,13 +1918,13 @@ ivas_error load_parambin_HRTF_from_binary( ) { FILE *f_hrtf; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; ivas_hrtfs_header_t hrtf_header; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; - int16_t asParam = 0; + Word16 hrtf_id; + Word16 asParam = 0; if ( hrtfReader == NULL || hrtfReader->file == NULL ) { @@ -2016,18 +2016,18 @@ ivas_error load_Crend_HRTF_from_binary( const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ const IVAS_AUDIO_CONFIG OutputConfig, /* i : output audio configuration */ const IVAS_AUDIO_CONFIG hrtf_set_audio_cfg, /* i : HRTF set audio config. */ - const int32_t sampleRate /* i : sample rate */ + const Word32 sampleRate /* i : sample rate */ ) { FILE *f_hrtf; - int32_t hrtf_data_size_max; + Word32 hrtf_data_size_max; char *hrtf_data; ivas_hrtfs_header_t hrtf_header; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; - int16_t hrtf_id; + Word16 hrtf_id; bool load = false; - int16_t asCrend = 0; + Word16 asCrend = 0; BINAURAL_INPUT_AUDIO_CONFIG hrtf_set_binaural_cfg; /* convert audio config. to HRTF binaural config */ @@ -2138,7 +2138,7 @@ void destroy_crend_hrtf( #ifdef FIX_2249_MEMORY_LEAK_IN_SBA ivas_HRTF_CRend_binary_close_fx( hHrtfCrend ); #else - uint16_t i, j; + UWord16 i, j; test(); if ( *hHrtfCrend != NULL && hHrtfCrend != NULL ) -- GitLab