From c9124511d0a98668c8d2d2fd8dbbbd7532a6e0d2 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 30 Aug 2024 16:23:06 +0200 Subject: [PATCH 1/6] [fix] default room acoustics parameters in all renderers and BINAURAL_ROOM_REVERB output format --- apps/decoder.c | 2 ++ apps/renderer.c | 2 ++ lib_com/common_api_types.h | 2 ++ lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal.c | 18 +++++++++++ lib_dec/lib_dec.c | 4 +++ lib_rend/ivas_dirac_dec_binaural_functions.c | 34 ++++++++++++++++++++ lib_rend/ivas_render_config.c | 2 ++ lib_rend/ivas_reverb.c | 6 ++++ lib_rend/lib_rend.c | 31 +++++++++++++++++- 10 files changed, 101 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index d8889fcb9e..81595c25a5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -671,7 +671,9 @@ int main( fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); goto cleanup; } +#ifndef FIX_587_DEFAULT_REVERB renderConfig.roomAcoustics.override = true; +#endif } /* ISAR frame size is set from command line, not renderer config file. diff --git a/apps/renderer.c b/apps/renderer.c index cfbc27df37..fd6c4a71dd 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1050,7 +1050,9 @@ int main( fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); exit( -1 ); } +#ifndef FIX_587_DEFAULT_REVERB renderConfig.roomAcoustics.override = 1; +#endif } /* ISAR frame size is set from command line, not renderer config file. diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 279e00b986..ce4a7c1e24 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -300,7 +300,9 @@ typedef enum typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG { +#ifndef FIX_587_DEFAULT_REVERB int16_t override; +#endif int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ diff --git a/lib_com/options.h b/lib_com/options.h index 4be89f112d..2eebc04109 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +173,7 @@ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ #define FIX_1166_TDREND_DIV0 /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */ #define FIX_835_PARAMMC_BUFFER_VALUES /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */ +#define FIX_587_DEFAULT_REVERB /* Philips: issue 587: inconsistent default reverb parameters across renderers */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 98cf52caf8..e8b3972785 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1333,6 +1333,23 @@ ivas_error ivas_binRenderer_open( } } +#ifdef FIX_587_DEFAULT_REVERB + /* Allocate and initialize the reverberator */ + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + { + if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, NULL, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + 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, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else /* 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 ) ) { @@ -1341,6 +1358,7 @@ ivas_error ivas_binRenderer_open( return error; } } +#endif else { hBinRenderer->hReverb = NULL; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index cf62708e87..9526e1c2fa 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2072,7 +2072,9 @@ static ivas_error copyRendererConfigStruct( break; } #endif +#ifndef FIX_587_DEFAULT_REVERB hRCout->roomAcoustics.override = hRCin->roomAcoustics.override; +#endif hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; hRCout->roomAcoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; @@ -2160,7 +2162,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_CREND; } #endif +#ifndef FIX_587_DEFAULT_REVERB hRenderConfig->roomAcoustics.override = renderConfig.roomAcoustics.override; +#endif hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.roomAcoustics.inputPreDelay; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 55e5cf2dc9..664c314d7b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -217,6 +217,39 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ { +#ifdef FIX_587_DEFAULT_REVERB + /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ + if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || + ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) + { + ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); + } + + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); + + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ + { + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ + { + 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, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + +#else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); @@ -240,6 +273,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } +#endif } else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) { diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 124b5e5767..eabaf2d4cb 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -113,7 +113,9 @@ ivas_error ivas_render_config_init_from_rom( #ifdef DEBUGGING ( *hRenderConfig )->renderer_type_override = IVAS_RENDER_TYPE_OVERRIDE_NONE; #endif +#ifndef FIX_587_DEFAULT_REVERB ( *hRenderConfig )->roomAcoustics.override = FALSE; +#endif ( *hRenderConfig )->roomAcoustics.nBands = IVAS_REVERB_DEFAULT_N_BANDS; ( *hRenderConfig )->roomAcoustics.acousticPreDelay = IVAS_REVERB_DEFAULT_PRE_DELAY; ( *hRenderConfig )->roomAcoustics.inputPreDelay = IVAS_REVERB_DEFAULT_INPUT_DELAY; diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 7ea38fe2a7..34bf2f3bb6 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1116,7 +1116,9 @@ ivas_error ivas_reverb_open( #ifdef DEBUGGING pState->pConfig.renderer_type_override = hRenderConfig->renderer_type_override; #endif +#ifndef FIX_587_DEFAULT_REVERB pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; +#endif pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; if ( hRenderConfig->roomAcoustics.use_er == 1 ) @@ -1873,7 +1875,11 @@ ivas_error ivas_binaural_reverb_init( error = IVAS_ERR_OK; +#ifdef FIX_587_DEFAULT_REVERB + if ( ( roomAcoustics != NULL ) && ( defaultTimes == NULL || defaultEne == NULL ) ) +#else if ( ( roomAcoustics != NULL ) && roomAcoustics->override ) +#endif { revTimes = t60; revEne = ene; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3efafb6a29..1f551fd4a1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4273,7 +4273,9 @@ ivas_error IVAS_REND_GetRenderConfig( break; } #endif +#ifndef FIX_587_DEFAULT_REVERB hRCout->roomAcoustics.override = hRCin->roomAcoustics.override; +#endif hRCout->roomAcoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->roomAcoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; hRCout->roomAcoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; @@ -4330,8 +4332,9 @@ ivas_error IVAS_REND_FeedRenderConfig( #ifdef DEBUGGING hRenderConfig->renderer_type_override = renderConfig.renderer_type_override; #endif - +#ifndef FIX_587_DEFAULT_REVERB hRenderConfig->roomAcoustics.override = renderConfig.roomAcoustics.override; +#endif hRenderConfig->roomAcoustics.nBands = renderConfig.roomAcoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.roomAcoustics.acousticPreDelay; hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.roomAcoustics.inputPreDelay; @@ -8523,6 +8526,31 @@ static ivas_error ivas_masa_ext_rend_parambin_init( } else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ { +#ifdef FIX_587_DEFAULT_REVERB + if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { + mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); + + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ + { + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else + { + set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); + if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ + { + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } +#else if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); @@ -8539,6 +8567,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( return error; } } +#endif } else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) { -- GitLab From ac72f20613c51491ffc5220bd4ee900efd7372c9 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 30 Aug 2024 16:28:39 +0200 Subject: [PATCH 2/6] [cleanup] a space lost in space... --- lib_dec/ivas_binRenderer_internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index e8b3972785..e7ee2bbb9d 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1335,7 +1335,7 @@ ivas_error ivas_binRenderer_open( #ifdef FIX_587_DEFAULT_REVERB /* Allocate and initialize the reverberator */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, NULL, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK ) { -- GitLab From 39f1c885784ff9e71aa78891636f04ba77933aa0 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Sep 2024 21:33:24 +0200 Subject: [PATCH 3/6] Control logic simplification --- lib_dec/ivas_binRenderer_internal.c | 27 ++++-------- lib_rend/ivas_dirac_dec_binaural_functions.c | 44 +++++--------------- lib_rend/ivas_reverb.c | 2 +- lib_rend/lib_rend.c | 36 +++++----------- 4 files changed, 30 insertions(+), 79 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index a28747b444..8725b62ddd 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1075,6 +1075,9 @@ ivas_error ivas_binRenderer_open( BINAURAL_RENDERER_HANDLE hBinRenderer; int16_t convBand, k; ivas_error error; +#ifdef FIX_587_DEFAULT_REVERB + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL; +#endif error = IVAS_ERR_OK; @@ -1211,32 +1214,20 @@ ivas_error ivas_binRenderer_open( } } -#ifdef FIX_587_DEFAULT_REVERB - /* Allocate and initialize the reverberator */ - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) - { - if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, NULL, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - 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, NULL, NULL ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#else /* 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 FIX_587_DEFAULT_REVERB + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics ); + } +#endif 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 ) { return error; } } -#endif else { hBinRenderer->hReverb = NULL; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index d9884c2941..3241531490 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -143,6 +143,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( ivas_error error; float frequency_axis[CLDFB_NO_CHANNELS_MAX]; int16_t num_poses, pos_idx; +#ifdef FIX_587_DEFAULT_REVERB + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL; +#endif num_poses = 1; if ( st_ivas->hSplitBinRend != NULL ) @@ -217,39 +220,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( } else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ { -#ifdef FIX_587_DEFAULT_REVERB - /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ - if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || - ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) - { - ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); - } - - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); - - if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ - { - if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ - { - 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, NULL, NULL ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - -#else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); @@ -257,6 +227,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( else { set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); +#ifdef FIX_587_DEFAULT_REVERB + pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics ); +#endif } /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ @@ -268,12 +241,15 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ { +#ifdef FIX_587_DEFAULT_REVERB + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, pRoomAcoustics, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else 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, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#endif { return error; } } -#endif } else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) { diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 34bf2f3bb6..eb3c05a0cc 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1876,7 +1876,7 @@ ivas_error ivas_binaural_reverb_init( error = IVAS_ERR_OK; #ifdef FIX_587_DEFAULT_REVERB - if ( ( roomAcoustics != NULL ) && ( defaultTimes == NULL || defaultEne == NULL ) ) + if ( roomAcoustics != NULL ) #else if ( ( roomAcoustics != NULL ) && roomAcoustics->override ) #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index af4461fd6a..f2b49d0fc0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8312,6 +8312,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init( ivas_error error; float frequency_axis[CLDFB_NO_CHANNELS_MAX]; int16_t pos_idx; +#ifdef FIX_587_DEFAULT_REVERB + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL; +#endif error = IVAS_ERR_OK; @@ -8387,31 +8390,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( } else if ( renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Indication of binaural rendering with room effect */ { -#ifdef FIX_587_DEFAULT_REVERB - if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { - mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); - - if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ - { - if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - else - { - set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); - if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ - { - if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } -#else if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); @@ -8419,16 +8397,22 @@ static ivas_error ivas_masa_ext_rend_parambin_init( else { set_f( hDiracDecBin->earlyPartEneCorrection, 1.0f, CLDFB_NO_CHANNELS_MAX ); +#ifdef FIX_587_DEFAULT_REVERB + pRoomAcoustics = &( hRendCfg->roomAcoustics ); +#endif } if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ { +#ifdef FIX_587_DEFAULT_REVERB + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, pRoomAcoustics, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#endif { return error; } } -#endif } else if ( renderer_type == RENDERER_STEREO_PARAMETRIC ) { -- GitLab From ce05229b06a0f695bfc270e252a5626372de0645 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Sep 2024 21:40:24 +0200 Subject: [PATCH 4/6] Updated room acoustics pointer assignment --- lib_dec/ivas_binRenderer_internal.c | 7 ++----- lib_rend/ivas_dirac_dec_binaural_functions.c | 5 ++++- lib_rend/lib_rend.c | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 8725b62ddd..dae5bccb05 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1076,7 +1076,7 @@ ivas_error ivas_binRenderer_open( int16_t convBand, k; ivas_error error; #ifdef FIX_587_DEFAULT_REVERB - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; #endif error = IVAS_ERR_OK; @@ -1218,10 +1218,7 @@ ivas_error ivas_binRenderer_open( 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 FIX_587_DEFAULT_REVERB - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics ); - } + pRoomAcoustics = ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ? &( st_ivas->hRenderConfig->roomAcoustics ) : NULL; #endif 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 ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 3241531490..a2ccadbfbc 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -144,7 +144,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( float frequency_axis[CLDFB_NO_CHANNELS_MAX]; int16_t num_poses, pos_idx; #ifdef FIX_587_DEFAULT_REVERB - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; #endif num_poses = 1; @@ -223,6 +223,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); +#ifdef FIX_587_DEFAULT_REVERB + pRoomAcoustics = NULL; +#endif } else { diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f2b49d0fc0..24e8378a35 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8313,7 +8313,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( float frequency_axis[CLDFB_NO_CHANNELS_MAX]; int16_t pos_idx; #ifdef FIX_587_DEFAULT_REVERB - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics = NULL; + IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; #endif error = IVAS_ERR_OK; @@ -8393,6 +8393,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init( if ( *inputMasa->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { mvr2r( ( *phHrtfParambin )->parametricEarlyPartEneCorrection, hDiracDecBin->earlyPartEneCorrection, nBins ); +#ifdef FIX_587_DEFAULT_REVERB + pRoomAcoustics = NULL; +#endif } else { -- GitLab From d75728f90876736451683e21f7ee4457dcbd66dc Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Sep 2024 21:44:39 +0200 Subject: [PATCH 5/6] Updated call to ivas_binaural_reverb_init() --- lib_dec/ivas_binRenderer_internal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index dae5bccb05..a876a6ca0e 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1219,8 +1219,10 @@ ivas_error ivas_binRenderer_open( { #ifdef FIX_587_DEFAULT_REVERB pRoomAcoustics = ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ? &( st_ivas->hRenderConfig->roomAcoustics ) : NULL; -#endif + if ( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, pRoomAcoustics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else 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 ) +#endif { return error; } -- GitLab From b931cac1287b4c034a2ebf95d72dc13d6f0fba91 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 1 Oct 2024 09:42:37 +0200 Subject: [PATCH 6/6] Using constant pointers to room acoustics configuration data structure --- lib_dec/ivas_binRenderer_internal.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 2 +- lib_rend/lib_rend.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index a876a6ca0e..7bab860ae7 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1076,7 +1076,7 @@ ivas_error ivas_binRenderer_open( int16_t convBand, k; ivas_error error; #ifdef FIX_587_DEFAULT_REVERB - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; #endif error = IVAS_ERR_OK; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index a2ccadbfbc..4e23dc51e9 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -144,7 +144,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( float frequency_axis[CLDFB_NO_CHANNELS_MAX]; int16_t num_poses, pos_idx; #ifdef FIX_587_DEFAULT_REVERB - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; #endif num_poses = 1; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 24e8378a35..264b68bf12 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8313,7 +8313,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( float frequency_axis[CLDFB_NO_CHANNELS_MAX]; int16_t pos_idx; #ifdef FIX_587_DEFAULT_REVERB - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; #endif error = IVAS_ERR_OK; -- GitLab