From b7d3febd86b4fa73df1065bfab494819ccab18ef Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 14:58:45 +0200 Subject: [PATCH 01/20] Added pre-computed hrtf properties compiler switch in options.h --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index bc577060b..954569d02 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -202,7 +202,7 @@ #define NONBE_FIX_947_STEREO_DMX_EVS_POC /* Orange: Fix clicks on POC */ #define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ #define NONBE_FIX_951_MCMASA_5MS_RENDERING /* Nokia: issue #951: Differences for 5ms and 20ms rendering for McMASA at 13.2kbps to BINAURAL */ - +#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ -- GitLab From edc68675fb41ce9213a00b381581e13326156e97 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 15:05:17 +0200 Subject: [PATCH 02/20] Added reverb tables compiler switch in options.h --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 954569d02..83324a55f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -203,7 +203,7 @@ #define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ #define NONBE_FIX_951_MCMASA_5MS_RENDERING /* Nokia: issue #951: Differences for 5ms and 20ms rendering for McMASA at 13.2kbps to BINAURAL */ #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ - +#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format */ #define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ -- GitLab From a9012d004817a2c2726f2594dc2b888c64da0387 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 15:08:01 +0200 Subject: [PATCH 03/20] hrtf statistics handle in common api types --- lib_com/common_api_types.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 49d0c64d6..4d9535471 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -169,6 +169,9 @@ typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; +#endif typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE; -- GitLab From acfbcc3e58731602a232a2c87e99abb411aa3b75 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 15:18:44 +0200 Subject: [PATCH 04/20] declared hrtf statistics struct --- lib_dec/ivas_stat_dec.h | 3 +++ lib_dec/lib_dec.h | 7 +++++++ lib_rend/ivas_stat_rend.h | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 663525161..165de91da 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1108,6 +1108,9 @@ typedef struct Decoder_Struct HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics; /* HRTF statistics handle */ +#endif LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ float *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 22d1e2c96..f9c4e4a07 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -440,6 +440,13 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +); +#endif + /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 2f5b7e0ac..69c82cac9 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1058,8 +1058,11 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ float latency_s; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else const float *lr_energy_and_iac[3]; /* left/right energy and interaural coherence for late reverb */ float *lr_energy_and_iac_dyn[3]; +#endif } TDREND_HRFILT_FiltSet_t; @@ -1332,6 +1335,15 @@ typedef struct ivas_hrtfs_parambin_struct } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +typedef struct ivas_hrtfs_statistics_struct +{ + float *average_energy_l; + float *average_energy_r; + float *inter_aural_coherence; + int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ +} HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* -- GitLab From 9246174744a88f8240c42af1e36c943bce0c7d03 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 15:41:54 +0200 Subject: [PATCH 05/20] All changes in lib_dec .c files --- lib_dec/ivas_binRenderer_internal.c | 6 +++- lib_dec/ivas_init_dec.c | 45 ++++++++++++++++++++++++++++- lib_dec/ivas_ism_dec.c | 15 +++++++++- lib_dec/ivas_mct_dec.c | 8 +++++ lib_dec/lib_dec.c | 24 +++++++++++++++ 5 files changed, 95 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index a9b25710d..3cb3ab0b6 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1227,8 +1227,12 @@ ivas_error ivas_binRenderer_open( /* Allocate memories needed for reverb module */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_binaural_reverb_open_fastconv( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) - { +#endif + { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6cdbd760a..21bf509e1 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1040,6 +1040,13 @@ ivas_error ivas_init_decoder_front( { return error; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif } /*-------------------------------------------------------------------* @@ -1194,6 +1201,20 @@ ivas_error ivas_init_decoder( } } + #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /*--------------------------------------------------------------------* + * Allocate and initialize HRTF Statistics handle + *--------------------------------------------------------------------*/ + + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + if ( ( error = ivas_HRTF_statistics_init( &st_ivas->hHrtfStatistics, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * Initialize binuaral split rendering @@ -1942,8 +1963,13 @@ ivas_error ivas_init_decoder( if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { +#endif + { return error; } } @@ -1981,11 +2007,20 @@ ivas_error ivas_init_decoder( } #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif #endif { return error; @@ -2432,6 +2467,9 @@ void ivas_initialize_handles_dec( st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + st_ivas->hHrtfStatistics = NULL; +#endif st_ivas->hoa_dec_mtx = NULL; st_ivas->hMasaIsmData = NULL; st_ivas->hSbaIsmData = NULL; @@ -2669,6 +2707,11 @@ void ivas_destroy_dec( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /* HRTF statistics */ + ivas_HRTF_statistics_close( &st_ivas->hHrtfStatistics ); +#endif + /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0a424c24c..5280d2c40 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -201,8 +201,13 @@ static ivas_error ivas_ism_bitrate_switching_dec( } if ( st_ivas->hIntSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { +#endif + + { return error; } } @@ -230,9 +235,17 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Open Crend Binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif #endif { return error; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index adcfdaa4e..06f2e4e8e 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1296,9 +1296,17 @@ static ivas_error ivas_mc_dec_reconfig( else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif #endif { return error; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fd5f57385..bc00c70a5 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2040,6 +2040,30 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * IVAS_DEC_GetHrtfStatisticsHandle( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; + + return IVAS_ERR_OK; +} +#endif + /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * -- GitLab From 0a5e6a0c000429b95a41e7fa4519dcd706f01dc8 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 15:55:36 +0200 Subject: [PATCH 06/20] Changes in hrtf file reader header in util --- lib_util/hrtf_file_reader.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 9a06a4e3b..38ca914f0 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -102,7 +102,12 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); #endif @@ -200,4 +205,17 @@ void destroy_td_hrtf( IVAS_DEC_HRTF_HANDLE *hHRTF /* i/o: HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * free memory allocated for HRTF statistics binary data + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif + + #endif /* IVAS_HRTF_FILE_READER_H */ -- GitLab From abad75acf0d52d75e05bb1b2bf9d20869319db05 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 16:07:40 +0200 Subject: [PATCH 07/20] added function definitons in hrtf_file_reader.c --- lib_util/hrtf_file_reader.c | 80 ++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 418c77306..383a7b3b7 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -463,6 +463,7 @@ static ivas_error LoadBSplineBinary( } #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * set_default_reverb_iac_energy() * @@ -556,6 +557,7 @@ static ivas_error set_default_reverb_iac_energy( return IVAS_ERR_OK; } +#endif #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES @@ -566,11 +568,18 @@ static ivas_error set_default_reverb_iac_energy( --------------------------------------------------------------------*/ static ivas_error load_reverb_from_binary( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ +#endif + FILE *f_hrtf /* i : HR filter data file handle */ ) { +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES int16_t i; +#endif bool is_reverb; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; @@ -581,14 +590,22 @@ static ivas_error load_reverb_from_binary( #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( hHrtfStatistics == NULL ) +#else if ( HrFiltSet_p == NULL ) - { +#endif + { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } lr_iac_len = LR_IAC_LENGTH_NR_FC; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( sampleRate == 16000 ) +#else if ( HrFiltSet_p->SampleRate == 16000 ) - { +#endif + { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif @@ -645,6 +662,21 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hHrtfStatistics->average_energy_l = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->average_energy_r = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->inter_aural_coherence = (float *) malloc( lr_iac_len * sizeof( float ) ); + + if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_r, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->inter_aural_coherence, sizeof( const float ), lr_iac_len, f_hrtf ); + + hHrtfStatistics->fromROM = FALSE; +#else /* left/right energy and interaural coherence for late reverb */ for ( i = 0; i < 3; i++ ) { @@ -670,14 +702,17 @@ static ivas_error load_reverb_from_binary( HrFiltSet_p->lr_energy_and_iac[i] = (const float *) HrFiltSet_p->lr_energy_and_iac_dyn[i]; #endif } +#endif } else { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else if ( ( header_check_result = set_default_reverb_iac_energy( HrFiltSet_p ) ) != IVAS_ERR_OK ) { return header_check_result; } - +#endif return IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA; } @@ -692,13 +727,22 @@ static ivas_error load_reverb_from_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) { fseek( hrtfReader->file, 0, SEEK_SET ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + return load_reverb_from_binary( hHrtfStatistics, sampleRate, hrtfReader->file ); +#else return load_reverb_from_binary( hHrtf, hrtfReader->file ); +#endif } #endif @@ -954,10 +998,13 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL ); free( ( *hHrtf )->ModelEval.hrfModR ); + +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES for ( i = 0; i < 3; i++ ) { free( ( *hHrtf )->lr_energy_and_iac_dyn[i] ); } +#endif } ivas_HRTF_binary_close( hHrtf ); @@ -2114,3 +2161,26 @@ void destroy_parambin_hrtf( return; } + + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +{ + if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == FALSE ) + { + free( ( *hHrtfStatistics )->average_energy_l ); + free( ( *hHrtfStatistics )->average_energy_r ); + free( ( *hHrtfStatistics )->inter_aural_coherence ); + } + ivas_HRTF_statistics_close( hHrtfStatistics ); + return IVAS_ERR_OK; +} +#endif -- GitLab From 066472b9ad01d3fef697059d0a9f7abda66ee483 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 17:09:50 +0200 Subject: [PATCH 08/20] changes in lib_rend header files --- lib_rend/ivas_prot_rend.h | 54 ++++++++++++++++++++++++++++++++++++++- lib_rend/lib_rend.h | 15 ++++++++--- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index d37f770ca..548b65767 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -585,6 +585,21 @@ void ivas_HRTF_CRend_binary_close( HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_HRTF_statistics_init( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ + int32_t sampleRate /* i : Sample rate */ +); + +void ivas_HRTF_statistics_close( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); + +ivas_error ivas_HRTF_statistics_binary_open( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); + +#endif /*----------------------------------------------------------------------------------* * TD object renderer @@ -857,6 +872,9 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT const int32_t output_Fs, const int16_t num_poses @@ -912,16 +930,35 @@ ivas_error ivas_rend_crendProcessSubframe( * Reverberator *----------------------------------------------------------------------------------*/ + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_binaural_reverb_init( +#else ivas_error ivas_binaural_reverb_open_fastconv( +#endif REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else +#endif const int16_t numBins, /* i : number of CLDFB bins */ const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ +#else IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const AUDIO_CONFIG internal_config, /* i : internal audio config for FastConv */ +#endif const int32_t sampling_rate, /* i : sampling rate */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const float *defaultTimes, /* i : default reverberation times */ + const float *defaultEne /* i : default reverberation energies */ +#else const HRTFS_FASTCONV_HANDLE hHrtfFastConv /* i : FastConv HRTF handle */ +#endif ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_binaural_reverb_open_parambin( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const int16_t numBins, /* i : number of CLDFB bins */ @@ -930,6 +967,7 @@ ivas_error ivas_binaural_reverb_open_parambin( const int32_t sampling_rate, /* i : sampling rate */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ); +#endif void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ @@ -947,9 +985,13 @@ void ivas_binaural_reverb_processSubframe( ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ const float *lr_energy_and_iac[], /* i : precomuputed lr energies and iac */ +#endif RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ const int32_t output_Fs /* i : output sampling rate */ ); @@ -1106,6 +1148,14 @@ void ivas_reverb_calc_color_levels( float *pTarget_color_R ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_reverb_prepare_cldfb_params( + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, + const int32_t output_Fs, + float *pOutput_t60, + float *pOutput_ene ); +#else ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, @@ -1114,6 +1164,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ); +#endif void ivas_reverb_interpolate_acoustic_data( const int16_t input_table_size, @@ -1126,6 +1177,7 @@ void ivas_reverb_interpolate_acoustic_data( float *pOutput_dsr ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES void ivas_reverb_get_hrtf_set_properties( float **ppHrtf_set_L_re, float **ppHrtf_set_L_im, @@ -1139,7 +1191,7 @@ void ivas_reverb_get_hrtf_set_properties( float *pOut_avg_pwr_R, float *pOut_i_a_coherence ); - +#endif /*---------------------------------------------------------------------------------* * Shoebox Prototypes diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index b25076ac8..5cf173c37 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -186,26 +186,33 @@ ivas_error IVAS_REND_GetDelay( /*! r: error code */ ivas_error IVAS_REND_GetHrtfHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS render handle */ IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ ); /*! r: error code */ ivas_error IVAS_REND_GetHrtfCRendHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF /* o : Set of HRTF handle */ ); ivas_error IVAS_REND_GetHrtfFastConvHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_FASTCONV_HANDLE **hHrtfFastConv /* o : FASTCONV HRTF handle */ ); ivas_error IVAS_REND_GetHrtfParamBinHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error IVAS_REND_GetHrtfStatisticsHandle( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +); +#endif + /* Functions to be called during rendering */ ivas_error IVAS_REND_FeedInputAudio( -- GitLab From c90af971df818213033a241da6f45c6f7da1c97a Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 17:10:13 +0200 Subject: [PATCH 09/20] midway commit - changes in lib_rend.c --- lib_rend/lib_rend.c | 78 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3d1f9b518..f52dff33e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -200,6 +200,9 @@ typedef struct hrtf_handles IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv; IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin; IVAS_DEC_HRTF_HANDLE hHrtfTD; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics; +#endif } hrtf_handles; struct IVAS_REND @@ -245,8 +248,11 @@ struct IVAS_REND * Local function prototypes *-------------------------------------------------------------------*/ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, const RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hHrtfs ); +#else static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, hrtf_handles *hHrtfs ); - +#endif static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1391,7 +1397,11 @@ static ivas_error setRendInputActiveIsm( #endif { #ifndef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1431,7 +1441,11 @@ static ivas_error setRendInputActiveIsm( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -1444,14 +1458,22 @@ static ivas_error setRendInputActiveIsm( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } } else if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2138,6 +2160,9 @@ static ivas_error initMcBinauralRendering( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, IVAS_DEC_HRTF_CREND_HANDLE hMixconv, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif uint8_t reconfigureFlag ) { ivas_error error; @@ -2234,7 +2259,11 @@ static ivas_error initMcBinauralRendering( #endif if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && inputMc->hReverb == NULL ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -2244,13 +2273,22 @@ static ivas_error initMcBinauralRendering( { /* open CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, + outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, outSampleRate ) ) != IVAS_ERR_OK ) +#endif #endif { return error; @@ -2448,10 +2486,15 @@ static ivas_error setRendInputActiveMc( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, FALSE ) ) != IVAS_ERR_OK ) +#else if ( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, FALSE ) ) != IVAS_ERR_OK ) - { +#endif + + { return error; } } @@ -2616,7 +2659,11 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, - IVAS_DEC_HRTF_CREND_HANDLE hMixconv ) + IVAS_DEC_HRTF_CREND_HANDLE hMixconv, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics +#endif +) { ivas_error error; AUDIO_CONFIG inConfig; @@ -2666,10 +2713,18 @@ static ivas_error updateSbaPanGains( case IVAS_AUDIO_CONFIG_BINAURAL: { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) - { +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif + { return error; } } @@ -2694,9 +2749,18 @@ static ivas_error updateSbaPanGains( return error; } #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #endif { return error; @@ -2808,8 +2872,12 @@ static ivas_error setRendInputActiveSba( } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK ) +#else if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF ) ) != IVAS_ERR_OK ) - { +#endif + { return error; } -- GitLab From 937e5c42aa166a09291f1cbcc5679027a3e0a15c Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 17:33:05 +0200 Subject: [PATCH 10/20] all changes lib_rend.c --- lib_rend/lib_rend.c | 97 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 7 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f52dff33e..74175c5ec 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2920,8 +2920,11 @@ static ivas_error setRendInputActiveMasa( const IVAS_REND_InputId id, RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hrtfs - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +) +#else ) /* Todo: This is not used at all within MASA. Support might be better to do after refactoring. */ +#endif { ivas_error error; rendering_context rendCtx; @@ -2932,7 +2935,9 @@ static ivas_error setRendInputActiveMasa( inputMasa = (input_masa *) input; rendCtx = inputMasa->base.ctx; outConfig = *rendCtx.pOutConfig; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES (void) hRendCfg; /* Suppress warning */ +#endif if ( !isIoConfigPairSupported( inConfig, outConfig ) ) { @@ -2960,8 +2965,12 @@ static ivas_error setRendInputActiveMasa( } else { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hRendCfg, hrtfs ) ) != IVAS_ERR_OK ) +#else if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ) != IVAS_ERR_OK ) - { +#endif + { return error; } @@ -3157,6 +3166,9 @@ ivas_error IVAS_REND_Open( hIvasRend->hHrtfs.hHrtfParambin = NULL; hIvasRend->hHrtfs.hHrtfTD = NULL; hIvasRend->hHrtfs.hSetOfHRTF = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics = NULL; +#endif if ( asHrtfBinary ) { if ( ( error = ivas_HRTF_binary_open( &( hIvasRend->hHrtfs.hHrtfTD ) ) ) != IVAS_ERR_OK ) @@ -3175,7 +3187,20 @@ ivas_error IVAS_REND_Open( { return error; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_HRTF_statistics_binary_open( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ) != IVAS_ERR_OK ) + { + return error; } +#endif return IVAS_ERR_OK; } @@ -3320,8 +3345,12 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( /* Input inactive, skip. */ continue; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL, NULL ) ) != IVAS_ERR_OK ) +#else if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL ) ) != IVAS_ERR_OK ) - { +#endif + { return error; } } @@ -3799,6 +3828,10 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif FALSE ) ) != IVAS_ERR_OK ) { return error; @@ -4582,6 +4615,9 @@ ivas_error IVAS_REND_SetHeadRotation( hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif TRUE ) ) != IVAS_ERR_OK ) { return error; @@ -4647,6 +4683,10 @@ ivas_error IVAS_REND_DisableHeadRotation( hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif TRUE ) ) != IVAS_ERR_OK ) { @@ -7967,6 +8007,9 @@ void IVAS_REND_Close( ivas_HRTF_CRend_binary_close( &( hIvasRend->hHrtfs.hSetOfHRTF ) ); ivas_HRTF_fastconv_binary_close( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close( &( hIvasRend->hHrtfs.hHrtfParambin ) ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_HRTF_statistics_close( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#endif free( hIvasRend ); *phIvasRend = NULL; @@ -8208,6 +8251,30 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * IVAS_REND_GetHrtfStatisticsHandle( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_REND_GetHrtfStatisticsHandle( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasRend == NULL || hIvasRend->hHrtfs.hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + *hHrtfStatistics = &hIvasRend->hHrtfs.hHrtfStatistics; + + return IVAS_ERR_OK; +} +#endif + static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) { @@ -8569,7 +8636,13 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } static ivas_error ivas_masa_ext_rend_parambin_init( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + input_masa *inputMasa, /* i/o: MASA external renderer structure */ + const RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration data handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i : HRTF statistics */ +#else input_masa *inputMasa /* i/o: MASA external renderer structure */ +#endif ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; @@ -8665,8 +8738,12 @@ static ivas_error ivas_masa_ext_rend_parambin_init( if ( hDiracDecBin->hReverb == NULL ) #endif { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK ) +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else + /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ + if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -8720,6 +8797,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init( static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const RENDER_CONFIG_DATA *hRendCfg, +#endif hrtf_handles *hrtfs ) { int16_t i; @@ -8844,9 +8924,12 @@ static ivas_error initMasaExtRenderer( return error; } } - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ) != IVAS_ERR_OK ) - { +#endif + { return error; } } -- GitLab From 1c71bcc5f745b94d89c89d1fc62cc74c234f64a4 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 20 May 2025 17:47:46 +0200 Subject: [PATCH 11/20] all changes reverb_utils.c in lib_rend --- lib_rend/ivas_reverb_utils.c | 51 ++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index b1f9822fd..89d36dd4e 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -67,8 +67,11 @@ typedef struct cldfb_convolver_state float filter_states_im[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX]; } cldfb_convolver_state; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +static void ivas_reverb_set_energies( const float *avg_pwr_l, const float *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); +#else static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); - +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_prepare_cldfb_params() @@ -77,10 +80,16 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCO *-----------------------------------------------------------------------------------------*/ ivas_error ivas_reverb_prepare_cldfb_params( + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#else IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, +#endif const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ) @@ -92,7 +101,9 @@ ivas_error ivas_reverb_prepare_cldfb_params( float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; +#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -113,10 +124,14 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= expf( exp_argument ); } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); +#else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { return error; } +#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -127,6 +142,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-----------------------------------------------------------------------------------------* * Function ivas_cldfb_convolver() * @@ -470,8 +486,22 @@ static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( return IVAS_ERR_OK; } +#endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*-----------------------------------------------------------------------------------------* + * Function ivas_reverb_set_energies() + * + * Function gets the precalculated left/right energies and computes average + * left/right energies to CLDFB bin center frequencies. + *-----------------------------------------------------------------------------------------*/ + +static void ivas_reverb_set_energies( + const float *avg_pwr_l, + const float *avg_pwr_r, +#else + /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_get_fastconv_hrtf_set_energies() * @@ -484,28 +514,44 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, +#endif const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ) { int16_t freq_idx; const int16_t cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES float avg_pwr_left_fft[FFT_SPECTRUM_SIZE]; float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; +#endif float input_fc[FFT_SPECTRUM_SIZE]; float output_fc[CLDFB_NO_CHANNELS_MAX]; + +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; +#endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; + for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) + { + input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); + } +#else for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) { input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( FFT_SPECTRUM_SIZE - 1 ) ); } +#endif for ( freq_idx = 0; freq_idx < CLDFB_NO_CHANNELS_MAX; freq_idx++ ) { output_fc[freq_idx] = (float) ( ( 2 * freq_idx + 1 ) * cldfb_freq_halfstep ); } - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); +#else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) { return error; @@ -514,4 +560,5 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( ivas_reverb_interpolate_acoustic_data( FFT_SPECTRUM_SIZE, input_fc, avg_pwr_left_fft, avg_pwr_right_fft, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); return IVAS_ERR_OK; +#endif } -- GitLab From cca5f5e58c3cf3ddc3c4dc287ced67d68b46cae7 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 21 May 2025 12:26:01 +0200 Subject: [PATCH 12/20] added cldfb reverb compiler switch + changes in reverb_filter_design.c --- lib_com/options.h | 4 ++++ lib_rend/ivas_reverb_filter_design.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 83324a55f..88b04081a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -181,6 +181,10 @@ #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #endif #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ +#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM +#define NONBE_FIX_AVG_IAC_CLDFB_REVERB +#endif + //#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT diff --git a/lib_rend/ivas_reverb_filter_design.c b/lib_rend/ivas_reverb_filter_design.c index 0dd7e4d5c..64cda8141 100644 --- a/lib_rend/ivas_reverb_filter_design.c +++ b/lib_rend/ivas_reverb_filter_design.c @@ -655,6 +655,7 @@ void ivas_reverb_interpolate_acoustic_data( } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * ivas_reverb_get_hrtf_set_properties() * @@ -830,3 +831,4 @@ void ivas_reverb_get_hrtf_set_properties( return; } +#endif -- GitLab From 14899ead0c774f8566a4f06e64bd416bfd28d160 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 21 May 2025 12:37:43 +0200 Subject: [PATCH 13/20] changes in ivas_reverb.c --- lib_rend/ivas_reverb.c | 82 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index a72df8603..04f5fe30b 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -939,15 +939,27 @@ static void set_fft_and_datablock_sizes( static void set_reverb_acoustic_data( ivas_reverb_params_t *pParams, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else const AUDIO_CONFIG input_audio_config, const HRTFS_HANDLE hHrtf, +#endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics, +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const int16_t subframe_len, +#endif const int16_t nr_fc_input, const int16_t nr_fc_fft_filter ) { + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + int16_t bin_idx; +#else int16_t nr_out_ch, hrtf_idx, offset, iter_idx, bin_idx; +#endif float ln_1e6_inverted, delay_diff, exp_argument; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else float *pHrtf_set_l_re[MAX_INTERN_CHANNELS]; float *pHrtf_set_l_im[MAX_INTERN_CHANNELS]; float *pHrtf_set_r_re[MAX_INTERN_CHANNELS]; @@ -989,6 +1001,7 @@ static void set_reverb_acoustic_data( pParams->pHrtf_avg_pwr_response_r_const = (const float *) pParams->pHrtf_avg_pwr_response_r; pParams->pHrtf_inter_aural_coherence_const = (const float *) pParams->pHrtf_inter_aural_coherence; } +#endif /* interpolate input table data for T60 and DSR to the FFT filter grid */ ivas_reverb_interpolate_acoustic_data( nr_fc_input, pRoomAcoustics->pFc_input, pRoomAcoustics->pAcoustic_rt60, pRoomAcoustics->pAcoustic_dsr, @@ -1083,12 +1096,16 @@ static ivas_error setup_FDN_branches( *------------------------------------------------------------------------*/ ivas_error ivas_reverb_open( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ const float *lr_energy_and_iac[], /* i : precomuputed lr energies and iac */ - RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ - const int32_t output_Fs /* i : output sampling rate */ +#endif + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; @@ -1160,6 +1177,12 @@ ivas_error ivas_reverb_open( params.pFc[bin_idx] = freq_step * bin_idx; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); + params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l; + params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r; + params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence; +#else if ( hHrtf == NULL && lr_energy_and_iac != NULL ) { params.pHrtf_avg_pwr_response_l_const = lr_energy_and_iac[0]; @@ -1168,6 +1191,7 @@ ivas_error ivas_reverb_open( } /* set up reverb acoustic data on the basis of HRTF data and renderer config */ set_reverb_acoustic_data( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); +#endif /* set reverb acoustic configuration based on renderer config */ #ifdef DEBUGGING @@ -1880,6 +1904,56 @@ static ivas_error ivas_binaural_reverb_open( return IVAS_ERR_OK; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_init() + * + * Allocate and initialize binaural room reverberator handle + * for CLDFB renderers + *------------------------------------------------------------------------*/ +ivas_error ivas_binaural_reverb_init( + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const int16_t numBins, /* i : number of CLDFB bins */ + const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ + const int32_t sampling_rate, /* i : sampling rate */ + const float *defaultTimes, /* i : default reverberation times */ + const float *defaultEne /* i : default reverberation energies */ +) +{ + ivas_error error; + const float *revTimes; + const float *revEne; + float t60[CLDFB_NO_CHANNELS_MAX]; + float ene[CLDFB_NO_CHANNELS_MAX]; + int16_t preDelay; + + error = IVAS_ERR_OK; + + if ( ( roomAcoustics != NULL ) && roomAcoustics->override ) + { + revTimes = t60; + revEne = ene; + + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + { + return error; + } + preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); + } + else + { + revTimes = defaultTimes; + revEne = defaultEne; + preDelay = 10; + } + + error = ivas_binaural_reverb_open( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); + + return error; +} +#else /*------------------------------------------------------------------------- * ivas_binaural_reverb_open_fastconv() @@ -1975,7 +2049,7 @@ ivas_error ivas_binaural_reverb_open_parambin( return error; } - +#endif /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() -- GitLab From 244399056d0daaa8147bf2f83778277dcf67469a Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 21 May 2025 13:13:54 +0200 Subject: [PATCH 14/20] all .c files in lib_rend --- lib_rend/ivas_crend.c | 11 +++ lib_rend/ivas_dirac_dec_binaural_functions.c | 4 + lib_rend/ivas_hrtf.c | 98 ++++++++++++++++++++ lib_rend/ivas_objectRenderer_mix.c | 4 + 4 files changed, 117 insertions(+) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 11b9202e8..88dcebf71 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -1360,7 +1360,11 @@ ivas_rend_openMultiBinCrend( ivas_error error; #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) #endif @@ -1385,6 +1389,9 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT const int32_t output_Fs, const int16_t num_poses @@ -1556,7 +1563,11 @@ ivas_error ivas_rend_openCrend( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 396afca14..052f47329 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -246,8 +246,12 @@ ivas_error ivas_dirac_dec_init_binaural_data( #endif ) /* open reverb only for the main direction */ { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index 5e4e0bdf8..a4168fc9f 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -37,6 +37,9 @@ #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_prot.h" +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#include "ivas_rom_binaural_crend_head.h" +#endif /*-----------------------------------------------------------------------* * ivas_HRTF_binary_open() @@ -210,3 +213,98 @@ void ivas_HRTF_parambin_binary_close( return; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_binary_open() + * + * Allocate HRTF binary handle for statistics handler + *-----------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_statistics_binary_open( + HRTFS_STATISTICS **hHrtfStatistics ) +{ + *hHrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ); + if ( *hHrtfStatistics == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_close() + * + * Close HRTF binary handle for statistics handler + *-----------------------------------------------------------------------*/ + +void ivas_HRTF_statistics_close( + HRTFS_STATISTICS **hHrtfStatistics ) +{ + if ( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) + { + return; + } + + free( *hHrtfStatistics ); + *hHrtfStatistics = NULL; + + return; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_init() + * + * Allocates HRTF statistics handle and initializes from ROM + *-----------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_statistics_init( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, + int32_t sampleRate ) +{ + HRTFS_STATISTICS *HrtfStatistics; + + if ( hHrtfStatistics != NULL && *hHrtfStatistics != NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_OK; + } + + /* Initialise tables from ROM */ + if ( ( HrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + HrtfStatistics->average_energy_l = NULL; + HrtfStatistics->average_energy_r = NULL; + HrtfStatistics->inter_aural_coherence = NULL; + + switch ( sampleRate ) + { + case 48000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz; + break; + case 32000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz; + break; + case 16000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz; + break; + } + HrtfStatistics->fromROM = TRUE; + + *hHrtfStatistics = HrtfStatistics; + + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index 7088640c8..2f5ee1995 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -393,6 +393,8 @@ static ivas_error DefaultBSplineModel( model = &( HrFiltSet_p->ModelParams ); modelITD = &( HrFiltSet_p->ModelParamsITD ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else switch ( output_Fs ) { case 48000: @@ -411,6 +413,8 @@ static ivas_error DefaultBSplineModel( HrFiltSet_p->lr_energy_and_iac[2] = defaultHRIR_coherence_16kHz; break; } +#endif + /* Set ROM flag for correct deallocation */ model->modelROM = TRUE; -- GitLab From 36dfe9937c714bdb85bba46dde3c6d938e33e1d3 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 21 May 2025 13:43:18 +0200 Subject: [PATCH 15/20] changes in renderer.c --- apps/renderer.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/renderer.c b/apps/renderer.c index 8e9812c30..1decda322 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -676,6 +676,9 @@ int main( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#endif IsmPositionProvider *positionProvider; LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS]; RenderConfigReader *renderConfigReader = NULL; @@ -961,6 +964,7 @@ int main( } } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) { @@ -970,6 +974,7 @@ int main( goto cleanup; } } +#endif #endif if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK ) @@ -1051,6 +1056,28 @@ int main( destroy_parambin_hrtf( hHrtfParambin ); } } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES + if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); + goto cleanup; + } + if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath ); + goto cleanup; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } + } +#endif +#endif } hrtfFileReader_close( &hrtfFileReader ); @@ -2139,6 +2166,9 @@ cleanup: { destroy_td_hrtf( hHrtfTD ); } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + destroy_hrtf_statistics( hHrtfStatistics ); +#endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); RenderConfigReader_close( &renderConfigReader ); -- GitLab From 41476abd51016a68a96fffacf490de3d54e8b23b Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 21 May 2025 14:11:28 +0200 Subject: [PATCH 16/20] changes in decoder.c --- apps/decoder.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 84bf97845..dd601571a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -199,6 +199,9 @@ int main( IVAS_RENDER_FRAMESIZE asked_frame_size; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#endif #ifdef DEBUGGING int32_t noClipping; int32_t cnt_frames_limited; @@ -769,6 +772,7 @@ int main( } } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) { @@ -784,6 +788,7 @@ int main( fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#endif if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { @@ -861,6 +866,35 @@ int main( destroy_parambin_hrtf( hHrtfParambin ); } } + + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } + } +#else + if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } +#endif +#endif } /*------------------------------------------------------------------------------------------* @@ -947,6 +981,10 @@ cleanup: { destroy_SetOfHRTF( hSetOfHRTF ); } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ); + destroy_hrtf_statistics( hHrtfStatistics ); +#endif } IVAS_DEC_Close( &hIvasDec ); -- GitLab From fcccecdb35659f04b29603789b661a2c7a0dde8c Mon Sep 17 00:00:00 2001 From: marc emerit Date: Wed, 21 May 2025 16:41:28 +0200 Subject: [PATCH 17/20] fix switch --- apps/decoder.c | 3 ++- lib_com/options.h | 9 ++++++-- lib_dec/ivas_ism_dec.c | 4 ++-- lib_dec/ivas_mct_dec.c | 2 +- lib_rend/ivas_stat_rend.h | 13 ++++++----- lib_rend/lib_rend.c | 38 +++++++++++++++---------------- lib_util/hrtf_file_reader.c | 45 +++++++++++++++++++++++-------------- lib_util/hrtf_file_reader.h | 4 ++-- 8 files changed, 69 insertions(+), 49 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index dd601571a..1500f7ca8 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -783,12 +783,13 @@ int main( } } #endif +#endif + if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } -#endif if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/options.h b/lib_com/options.h index 88b04081a..9af800fe4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -188,6 +188,13 @@ //#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT +#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format */ +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#define NONBE_FIX_AVG_IAC_CLDFB_REVERB +#endif +#endif #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #define NONBE_FIX_AVG_IAC_CLDFB_REVERB @@ -206,8 +213,6 @@ #define NONBE_FIX_947_STEREO_DMX_EVS_POC /* Orange: Fix clicks on POC */ #define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ #define NONBE_FIX_951_MCMASA_5MS_RENDERING /* Nokia: issue #951: Differences for 5ms and 20ms rendering for McMASA at 13.2kbps to BINAURAL */ -#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ -#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format */ #define NONBE_FIX_979_OSBA_STEREO_5MS /* FhG : issue #979 : 5ms and 20ms output different for OSBA and stereo */ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5280d2c40..070f36ecd 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -207,7 +207,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - { + { return error; } } @@ -236,7 +236,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Open Crend Binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 06f2e4e8e..a0cad3214 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1297,7 +1297,7 @@ static ivas_error ivas_mc_dec_reconfig( { #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 69c82cac9..69426e706 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1335,15 +1335,18 @@ typedef struct ivas_hrtfs_parambin_struct } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES typedef struct ivas_hrtfs_statistics_struct { - float *average_energy_l; - float *average_energy_r; - float *inter_aural_coherence; + const float *average_energy_l; + const float *average_energy_r; + const float *inter_aural_coherence; + float *average_energy_l_dyn; + float *average_energy_r_dyn; + float *inter_aural_coherence_dyn; int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; -#endif +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 74175c5ec..9c4147a01 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2494,7 +2494,7 @@ static ivas_error setRendInputActiveMc( FALSE ) ) != IVAS_ERR_OK ) #endif - { + { return error; } } @@ -2659,10 +2659,11 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, - IVAS_DEC_HRTF_CREND_HANDLE hMixconv, + IVAS_DEC_HRTF_CREND_HANDLE hMixconv #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + , IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics -#endif +#endif ) { ivas_error error; @@ -2713,18 +2714,10 @@ static ivas_error updateSbaPanGains( case IVAS_AUDIO_CONFIG_BINAURAL: { #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#else if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) -#endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) -#endif - { + { return error; } } @@ -2732,9 +2725,17 @@ static ivas_error updateSbaPanGains( #endif { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif #endif { return error; @@ -2753,7 +2754,6 @@ static ivas_error updateSbaPanGains( if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) - #endif #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES @@ -2876,8 +2876,8 @@ static ivas_error setRendInputActiveSba( if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK ) #else if ( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF ) ) != IVAS_ERR_OK ) -#endif - { +#endif + { return error; } @@ -2970,7 +2970,7 @@ static ivas_error setRendInputActiveMasa( #else if ( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ) != IVAS_ERR_OK ) #endif - { + { return error; } @@ -3350,7 +3350,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( #else if ( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL ) ) != IVAS_ERR_OK ) #endif - { + { return error; } } @@ -8928,8 +8928,8 @@ static ivas_error initMasaExtRenderer( if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ) != IVAS_ERR_OK ) -#endif - { +#endif + { return error; } } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 383a7b3b7..1a0f1eaa0 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -595,7 +595,7 @@ static ivas_error load_reverb_from_binary( #else if ( HrFiltSet_p == NULL ) #endif - { + { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -604,8 +604,8 @@ static ivas_error load_reverb_from_binary( if ( sampleRate == 16000 ) #else if ( HrFiltSet_p->SampleRate == 16000 ) -#endif - { +#endif + { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } #endif @@ -663,18 +663,20 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - hHrtfStatistics->average_energy_l = (float *) malloc( lr_iac_len * sizeof( float ) ); - hHrtfStatistics->average_energy_r = (float *) malloc( lr_iac_len * sizeof( float ) ); - hHrtfStatistics->inter_aural_coherence = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->average_energy_l_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->average_energy_r_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->inter_aural_coherence_dyn = (float *) malloc( lr_iac_len * sizeof( float ) ); - if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL ) + 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" ); } - fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->average_energy_r, sizeof( const float ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->inter_aural_coherence, sizeof( const float ), lr_iac_len, f_hrtf ); - + hHrtfStatistics->average_energy_l = hHrtfStatistics->average_energy_l_dyn; + hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; + hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; + fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); hHrtfStatistics->fromROM = FALSE; #else /* left/right energy and interaural coherence for late reverb */ @@ -2170,17 +2172,26 @@ void destroy_parambin_hrtf( * Destroy the HRTF statistics set. *---------------------------------------------------------------------*/ -ivas_error destroy_hrtf_statistics( +void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { - if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == FALSE ) + if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { - free( ( *hHrtfStatistics )->average_energy_l ); - free( ( *hHrtfStatistics )->average_energy_r ); - free( ( *hHrtfStatistics )->inter_aural_coherence ); + if ( ( *hHrtfStatistics )->average_energy_l != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } } + ivas_HRTF_statistics_close( hHrtfStatistics ); - return IVAS_ERR_OK; } #endif diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 38ca914f0..673ce38b3 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -96,7 +96,7 @@ ivas_error load_HRTF_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES /*---------------------------------------------------------------------* - * load_reverb_from_binary() + * load_reverb_binary() * * Load reverb binary data into the HRTF handle *---------------------------------------------------------------------*/ @@ -212,7 +212,7 @@ void destroy_td_hrtf( * free memory allocated for HRTF statistics binary data *---------------------------------------------------------------------*/ -ivas_error destroy_hrtf_statistics( +void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ); #endif -- GitLab From b2af7d6aafbcae10a8f8c918bfea76b66de60186 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 22 May 2025 10:41:46 +0200 Subject: [PATCH 18/20] fix code format --- lib_dec/ivas_binRenderer_internal.c | 2 +- lib_dec/ivas_init_dec.c | 4 ++-- lib_rend/ivas_dirac_dec_binaural_functions.c | 4 ++-- lib_rend/ivas_reverb.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 3cb3ab0b6..768f06fc8 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1232,7 +1232,7 @@ ivas_error ivas_binRenderer_open( #else if ( ( error = ivas_binaural_reverb_open_fastconv( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ) != IVAS_ERR_OK ) #endif - { + { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 21bf509e1..1db61ff8c 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1201,7 +1201,7 @@ ivas_error ivas_init_decoder( } } - #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*--------------------------------------------------------------------* * Allocate and initialize HRTF Statistics handle *--------------------------------------------------------------------*/ @@ -1969,7 +1969,7 @@ ivas_error ivas_init_decoder( #else if ( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - { + { return error; } } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 052f47329..68fbcd844 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -249,8 +249,8 @@ ivas_error ivas_dirac_dec_init_binaural_data( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) #else - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ + if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 04f5fe30b..87400c5df 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1096,9 +1096,9 @@ static ivas_error setup_FDN_branches( *------------------------------------------------------------------------*/ ivas_error ivas_reverb_open( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ #else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ -- GitLab From c75f8c2bfc637aa9d598299013eda51ca79f06b4 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 15:52:34 +0200 Subject: [PATCH 19/20] Activated compiler switch --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9af800fe4..f4ce73b89 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -186,7 +186,7 @@ #endif -//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -- GitLab From 16f126e69dba7d1db7f1193e91e7f851c55d9153 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 17:01:55 +0200 Subject: [PATCH 20/20] deactivated compiler switch --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5ae2218d6..550a0543b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -186,7 +186,7 @@ #endif -#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -- GitLab