From 5f546048cd76277040ce8b4631dc7cc5f58f75be Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 13 Jun 2025 10:56:26 +0200 Subject: [PATCH 01/17] First commit - decalred compiler switch and constants for MR 1489 --- lib_com/options.h | 1 + lib_dec/ivas_rom_dec.h | 4 ++-- lib_rend/ivas_stat_rend.h | 2 ++ lib_rend/lib_rend.c | 12 ++++++++++++ lib_util/render_config_reader.c | 6 ++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index aebec0014..d9053bd8c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -208,6 +208,7 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ +#define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 82f8ee3cf..c77e3db4f 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -96,13 +96,13 @@ extern const uint16_t *const sym_freq_ECSQ_tab_abs_lsbs[1 + 4]; extern const float dirac_dithering_azi_scale[DIRAC_DIFFUSE_LEVELS]; extern const float dirac_dithering_ele_scale[DIRAC_DIFFUSE_LEVELS]; - +#ifndef FIX_1053_REVERB_RECONFIGURATION /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ extern const float dmxmtx_table[BINAURAL_CHANNELS][11]; - +#endif /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 41ece382e..e1c5626f9 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -480,7 +480,9 @@ typedef struct ivas_binaural_reverb_struct uint32_t binRend_RandNext; int16_t highestBinauralCoherenceBin; +#ifndef FIX_1053_REVERB_RECONFIGURATION float dmxmtx[BINAURAL_CHANNELS][MAX_OUTPUT_CHANNELS]; +#endif float foa_enc[MAX_OUTPUT_CHANNELS][FOA_CHANNELS]; } REVERB_STRUCT, *REVERB_STRUCT_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 08a2e3286..a07f44fd7 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4504,8 +4504,17 @@ int16_t IVAS_REND_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; +#ifdef FIX_1053_REVERB_RECONFIGURATION + uint16_t i; + input_ism *pIsmInput; + input_masa *pMasaInput; + input_mc *pMcInput; + input_sba *pSbaInput; + ivas_error error; +#else #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error error; +#endif #endif if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) @@ -4537,6 +4546,9 @@ int16_t IVAS_REND_FeedRenderConfig( mvr2r( renderConfig.roomAcoustics.AbsCoeff, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF ); } +#ifdef FIX_1053_REVERB_RECONFIGURATION +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT hRenderConfig->split_rend_config = renderConfig.split_rend_config; /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 64f195b1e..f00f80776 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2842,6 +2842,12 @@ ivas_error RenderConfigReader_getAcousticEnvironment( pAcEnv->AbsCoeff[j] = pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[j]; } } +#ifdef FIX_1053_REVERB_RECONFIGURATION + else + { + pAcEnv->use_er = false; + } +#endif return IVAS_ERR_OK; } } -- GitLab From 6d224bb5b403a326d82b1e6970f369c0610e2ad6 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 13 Jun 2025 12:31:50 +0200 Subject: [PATCH 02/17] Activated new hrtf format compiler switch + changes in lib_rend.c --- lib_com/options.h | 6 +- lib_rend/ivas_reverb.c | 14 +++-- lib_rend/lib_rend.c | 135 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 145 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d9053bd8c..c5dc315ad 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -187,11 +187,11 @@ #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 */ +#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 */ +#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 diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 87400c5df..67c782fdf 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -105,12 +105,14 @@ typedef struct ivas_reverb_params_t float *pFc; /* Center frequencies for FFT filter design */ float *pRt60; /* RT60 values at these frequencies */ float *pDsr; /* DSR values at these frequencies */ - float *pHrtf_avg_pwr_response_l; /* The HRTF set's average left ear power response */ - float *pHrtf_avg_pwr_response_r; /* The HRTF set's average right ear power response */ - float *pHrtf_inter_aural_coherence; /* The HRTF set's inter-aural coherence for diffuse sound */ - const float *pHrtf_avg_pwr_response_l_const; /* The HRTF set's average left ear power response */ - const float *pHrtf_avg_pwr_response_r_const; /* The HRTF set's average right ear power response */ - const float *pHrtf_inter_aural_coherence_const; /* The HRTF set's inter-aural coherence for diffuse sound */ +#ifndef FIX_1053_REVERB_RECONFIGURATION + float *pHrtf_avg_pwr_response_l; /* The HRTF set's average left ear power response */ + float *pHrtf_avg_pwr_response_r; /* The HRTF set's average right ear power response */ + float *pHrtf_inter_aural_coherence; /* The HRTF set's inter-aural coherence for diffuse sound */ +#endif + const float *pHrtf_avg_pwr_response_l_const; /* The HRTF set's average left ear power response */ + const float *pHrtf_avg_pwr_response_r_const; /* The HRTF set's average right ear power response */ + const float *pHrtf_inter_aural_coherence_const; /* The HRTF set's inter-aural coherence for diffuse sound */ int16_t do_corr_filter; /* Flag indicating whether correlation filters should be used. */ /* Correlation only supported and needed for binaural playback (i.e. */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a07f44fd7..460da7d93 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4547,6 +4547,139 @@ int16_t IVAS_REND_FeedRenderConfig( } #ifdef FIX_1053_REVERB_RECONFIGURATION + /* Re-initialise reverb instance if already available */ + /* ISM inputs */ + for ( i = 0, pIsmInput = hIvasRend->inputsIsm; i < RENDERER_MAX_BIN_INPUTS; ++i, ++pIsmInput ) + + { + if ( pIsmInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + /* Skip inactive inputs */ + continue; + } + if ( pIsmInput->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &pIsmInput->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } + if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend != NULL ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = ivas_reverb_open( &pIsmInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_reverb_open( &pIsmInput->crendWrapper->hCrend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) +#endif + { + return error; + } + } + } + + /*MASA inputs */ + for ( i = 0, pMasaInput = hIvasRend->inputsMasa; i < RENDERER_MAX_MASA_INPUTS; ++i, ++pMasaInput ) + { + if ( pMasaInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + /* Skip inactive inputs */ + continue; + } + + if ( pMasaInput->hMasaExtRend != NULL ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMasaInput->hMasaExtRend->hDiracDecBin != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); + if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else + if ( pMasaInput->hMasaExtRend->hDiracDecBin != NULL && pMasaInput->hMasaExtRend->hDiracDecBin->hReverb != NULL ) + { + ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin->hReverb ); + if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + if ( pMasaInput->hMasaExtRend->hReverb != NULL ) + { + ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hReverb ); + if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } + + /* Multi-channel inputs */ + for ( i = 0, pMcInput = hIvasRend->inputsMc; i < RENDERER_MAX_MC_INPUTS; ++i, ++pMcInput ) + { + if ( pMcInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + /* Skip inactive inputs */ + continue; + } + + if ( pMcInput->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &pMcInput->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &pMcInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else + if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend && pMcInput->crendWrapper->hCrend->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &pMcInput->crendWrapper->hCrend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + } + + /* SBA inputs */ + for ( i = 0, pSbaInput = hIvasRend->inputsSba; i < RENDERER_MAX_SBA_INPUTS; ++i, ++pSbaInput ) + { + if ( pSbaInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) + { + /* Skip inactive inputs */ + continue; + } + +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( pSbaInput->crendWrapper != NULL && pSbaInput->crendWrapper->hCrend != NULL && pSbaInput->crendWrapper->hCrend[0]->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &pSbaInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pSbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else + if ( pSbaInput->crendWrapper != NULL && pSbaInput->crendWrapper->hCrend != NULL && pSbaInput->crendWrapper->hCrend->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &pSbaInput->crendWrapper->hCrend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pSbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + } #endif #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -7832,7 +7965,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From f55cb4781c235a2b0d30f19ab37c3a4582650d3b Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 13 Jun 2025 12:50:10 +0200 Subject: [PATCH 03/17] All changes - ivas_reverb.c --- lib_rend/ivas_reverb.c | 113 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 67c782fdf..a4d2e940f 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1037,7 +1037,9 @@ static ivas_error setup_FDN_branches( { int16_t nr_coefs, branch_idx, channel_idx; ivas_error error; +#ifndef FIX_1053_REVERB_RECONFIGURATION float *pCoef_a, *pCoef_b; +#endif error = IVAS_ERR_OK; /* initialize feedback branches */ @@ -1059,6 +1061,7 @@ static ivas_error setup_FDN_branches( { for ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) { +#ifndef FIX_1053_REVERB_RECONFIGURATION pCoef_a = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx + nr_coefs]; pCoef_b = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx]; @@ -1066,7 +1069,7 @@ static ivas_error setup_FDN_branches( { return error; } - +#endif if ( ( error = set_feedback_delay( hReverb, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) { return error; @@ -1091,12 +1094,19 @@ static ivas_error setup_FDN_branches( } +#ifdef FIX_1053_REVERB_RECONFIGURATION +/*------------------------------------------------------------------------- + * ivas_reverb_open() + * + * Allocate and initialize FDN reverberation handle + *------------------------------------------------------------------------*/ +#else /*------------------------------------------------------------------------- * ivas_reverb_open() * * Allocate and initialize Crend reverberation handle *------------------------------------------------------------------------*/ - +#endif ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES @@ -1111,7 +1121,14 @@ ivas_error ivas_reverb_open( ) { ivas_error error; + +#ifdef FIX_1053_REVERB_RECONFIGURATION + REVERB_HANDLE pState = *hReverb; + int16_t nr_coefs, branch_idx; + float *pCoef_a, *pCoef_b; +#else REVERB_HANDLE pState = NULL; +#endif int16_t bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; ivas_reverb_params_t params; rv_fftwf_type_complex pFft_wf_filter_ch0[RV_LENGTH_NR_FC]; @@ -1129,17 +1146,47 @@ ivas_error ivas_reverb_open( predelay_bf_len = output_frame; nr_fc_input = hRenderConfig->roomAcoustics.nBands; +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( *hReverb == NULL ) + { + /* Allocate main reverb. handle */ + if ( ( pState = (REVERB_HANDLE) malloc( sizeof( REVERB_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator " ); + } + } +#else /* Allocate main reverb. handle */ if ( ( pState = (REVERB_HANDLE) malloc( sizeof( REVERB_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Reverberator " ); } +#endif if ( ( error = set_base_config( ¶ms, output_Fs ) ) != IVAS_ERR_OK ) { return error; } +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( *hReverb == NULL ) + { + /* Allocate memory for feedback delay lines */ + for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) + { + if ( ( pState->loop_delay_buffer[loop_idx] = (float *) malloc( params.pLoop_delays[loop_idx] * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" ); + } + } + + /* Allocate memory for the pre-delay delay line */ + if ( ( pState->pPredelay_buffer = (float *) malloc( output_frame * sizeof( float ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" ); + } + } +#else /* Allocate memory for feedback delay lines */ for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) { @@ -1154,20 +1201,26 @@ ivas_error ivas_reverb_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } +#endif pState->nr_of_branches = IVAS_REV_MAX_NR_BRANCHES; set_fft_and_datablock_sizes( pState, subframe_len ); + nr_fc_fft_filter = ( pState->fft_size >> 1 ) + 1; /* === 'Control logic': compute the reverb processing parameters from the === */ /* === room, source and listener acoustic information provided in the reverb config === */ /* Setting up shared temporary buffers for fc, RT60, DSR, etc. */ +#ifndef FIX_1053_REVERB_RECONFIGURATION params.pHrtf_avg_pwr_response_l = &pFft_wf_filter_ch0[0][0]; params.pHrtf_avg_pwr_response_r = params.pHrtf_avg_pwr_response_l + nr_fc_fft_filter; +#endif params.pRt60 = &pFft_wf_filter_ch1[0][0]; params.pDsr = params.pRt60 + nr_fc_fft_filter; params.pFc = &pState->fft_filter_color_0.fft_spectrum[0]; +#ifndef FIX_1053_REVERB_RECONFIGURATION params.pHrtf_inter_aural_coherence = &pState->fft_filter_color_1.fft_spectrum[0]; +#endif /* Note: these temp buffers can only be used before the final step of the FFT filter design : */ /* before calls to ivas_reverb_calc_correl_filters(...) or to ivas_reverb_calc_color_filters(...) */ @@ -1209,7 +1262,15 @@ ivas_error ivas_reverb_open( } /* set up input downmix */ +#ifdef FIX_1053_REVERB_RECONFIGURATION + if (*hReverb == NULL) + { + pState->dmx_gain = calc_dmx_gain(); + } +#else + /* set up input downmix */ pState->dmx_gain = calc_dmx_gain(); +#endif /* set up predelay - must be after set_base_config() and before compute_t60_coeffs() */ calc_predelay( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay, output_Fs ); @@ -1233,6 +1294,20 @@ ivas_error ivas_reverb_open( /* Compute the window used for FFT filters */ ivas_reverb_define_window_fft( pTime_window, transition_start, transition_length, nr_fc_fft_filter ); +#ifdef FIX_1053_REVERB_RECONFIGURATION + /* === Copy parameters from ivas_reverb_params_t into DSP blocks === */ + /* === to be used for subsequent audio signal processing === */ + if ( *hReverb == NULL ) + { + pState->do_corr_filter = params.do_corr_filter; + + /* clear & init jot reverb fft filters */ + if ( ( error = initialize_reverb_filters( pState ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ @@ -1244,6 +1319,8 @@ ivas_error ivas_reverb_open( { return error; } +#endif + if ( pState->do_corr_filter ) { @@ -1276,6 +1353,37 @@ ivas_error ivas_reverb_open( return error; } +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( *hReverb == NULL ) + { + /* init predelay */ + ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer, params.pre_delay, predelay_bf_len ); + + /* set up feedback delay network */ + if ( ( error = setup_FDN_branches( pState, ¶ms ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else + { + pState->predelay_line.Delay = params.pre_delay; + } + + nr_coefs = params.t60_filter_order + 1; + + for ( branch_idx = 0; branch_idx < params.nr_loops; branch_idx++ ) + { + pCoef_a = ¶ms.pT60_filter_coeff[2 * nr_coefs * branch_idx + nr_coefs]; + pCoef_b = ¶ms.pT60_filter_coeff[2 * nr_coefs * branch_idx]; + + if ( ( error = set_t60_filter( pState, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else + /* init predelay */ ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer, params.pre_delay, predelay_bf_len ); @@ -1284,6 +1392,7 @@ ivas_error ivas_reverb_open( { return error; } +#endif *hReverb = pState; -- GitLab From bfbdc93a4d14b1c4b2d9ee8656a29d390040e67a Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 13 Jun 2025 13:12:56 +0200 Subject: [PATCH 04/17] All changes in lib_dec + clang formatting --- lib_dec/ivas_binRenderer_internal.c | 35 +++++++++++++- lib_dec/ivas_rom_dec.c | 3 +- lib_dec/lib_dec.c | 75 +++++++++++++++++++++++++++++ lib_rend/ivas_reverb.c | 2 +- 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index f3fe81dcd..b94fac2e5 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -47,6 +47,19 @@ #endif #include "wmc_auto.h" +#ifdef FIX_1053_REVERB_RECONFIGURATION + +/*------------------------------------------------------------------------- + * Local constants + *------------------------------------------------------------------------*/ + +#define REVERB_INPUT_DOWNMIX_CHANNELS ( 11 ) +/* Downmix table for sparse frequency domain reverberator */ +const float dmxmtx_table[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { + { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, +}; +#endif /*------------------------------------------------------------------------- * ivas_binRenderer_filterModule() @@ -891,8 +904,11 @@ static void ivas_binaural_obtain_DMX( for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + float dmxConst = dmxmtx_table[chOutIdx][chIdx]; +#else float dmxConst = hBinRenderer->hReverb->dmxmtx[chOutIdx][chIdx]; - +#endif for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { for ( k = 0; k < numTimeSlots; k++ ) @@ -1076,7 +1092,11 @@ ivas_error ivas_binRenderer_open( ) { BINAURAL_RENDERER_HANDLE hBinRenderer; +#ifdef FIX_1053_REVERB_RECONFIGURATION + int16_t convBand, k; +#else int16_t convBand, chIdx, k; +#endif ivas_error error; error = IVAS_ERR_OK; @@ -1236,7 +1256,19 @@ ivas_error ivas_binRenderer_open( return error; } +#ifdef FIX_1053_REVERB_RECONFIGURATION /* initialize the dmx matrix */ + if ( hBinRenderer->nInChannels != HOA3_CHANNELS ) + { + for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + { + for ( k = 0; k < hBinRenderer->nInChannels; k++ ) + { + hBinRenderer->hReverb->dmxmtx[chIdx][k] = dmxmtx_table[chIdx][k]; + } + } + } +#else #ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM if ( hBinRenderer->nInChannels != HOA3_CHANNELS ) #endif @@ -1249,6 +1281,7 @@ ivas_error ivas_binRenderer_open( } } } +#endif } else { diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 35e5c4687..a909faf40 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -390,6 +390,7 @@ const float dirac_dithering_ele_scale[DIRAC_DIFFUSE_LEVELS] = 6.716062e-01f, 1.011804e+00f, 1.796875e+00f, 2.804382e+00f, 4.623130e+00f, 7.802667e+00f, 1.045446e+01f, 1.379538e+01f }; +#ifndef FIX_1053_REVERB_RECONFIGURATION /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ @@ -399,7 +400,7 @@ const float dmxmtx_table[BINAURAL_CHANNELS][11] = { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, }; - +#endif /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2150caa03..e5b705bf2 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2176,8 +2176,12 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; +#ifdef FIX_1053_REVERB_RECONFIGURATION + ivas_error error; +#else #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error error; +#endif #endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) @@ -2217,6 +2221,77 @@ ivas_error IVAS_DEC_FeedRenderConfig( mvr2r( renderConfig.roomAcoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.roomAcoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef FIX_1053_REVERB_RECONFIGURATION + /* Re-initialize reverb instance if already available */ + +#ifdef SPLIT_REND_WITH_HEAD_ROT + /* TD renderer Jot reverberator */ + if ( hIvasDec->st_ivas->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* CREND Jot reverberator */ + if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0] != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend[0]->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* FB reverberator */ + if ( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#else + /* TD renderer Jot reverberator */ + if ( hIvasDec->st_ivas->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* CREND Jot reverberator */ + if ( hIvasDec->st_ivas->hCrendWrapper != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend != NULL && hIvasDec->st_ivas->hCrendWrapper->hCrend->hReverb != NULL ) + { + if ( ( error = ivas_reverb_open( &hIvasDec->st_ivas->hCrendWrapper->hCrend->hReverb, hIvasDec->st_ivas->hHrtfStatistics, hRenderConfig, hIvasDec->st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* DirAC CLDFB reverberator */ + if ( hIvasDec->st_ivas->hDiracDecBin != NULL && hIvasDec->st_ivas->hDiracDecBin->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hDiracDecBin->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + /* Fastconv CLDFB reverberator */ + if ( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); + if ( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); #ifdef SPLIT_REND_WITH_HEAD_ROT diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index a4d2e940f..b970fbdc8 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1263,7 +1263,7 @@ ivas_error ivas_reverb_open( /* set up input downmix */ #ifdef FIX_1053_REVERB_RECONFIGURATION - if (*hReverb == NULL) + if ( *hReverb == NULL ) { pState->dmx_gain = calc_dmx_gain(); } -- GitLab From a532bbaf2d49f9243743eba1738ebbb1c7ca473e Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:19:04 +0200 Subject: [PATCH 05/17] All changes in apps/renderer.c --- apps/renderer.c | 185 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 181 insertions(+), 4 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 1decda322..568be3967 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -142,6 +142,18 @@ typedef struct IVAS_CUSTOM_LS_DATA outSetupCustom; } OutputConfig; +#ifdef FIX_1053_REVERB_RECONFIGURATION +typedef struct +{ + uint16_t *pID; + uint16_t *pValidity; + uint16_t count; + uint16_t selected; + uint16_t frameCounter; +} AcousticEnvironmentSequence; +#endif + + typedef struct { char executableName[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -181,7 +193,11 @@ typedef struct float syncMdDelay; IVAS_RENDER_FRAMESIZE render_framesize; uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS]; +#ifdef FIX_1053_REVERB_RECONFIGURATION + AcousticEnvironmentSequence aeSequence; +#else uint16_t acousticEnvironmentId; +#endif } CmdlnArgs; typedef enum @@ -314,10 +330,12 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "lp", .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees.\nIf specified, overrides the default behavior which attempts to map input to output LFE channel(s)", }, - { .id = CmdlnOptionId_lfeMatrix, - .match = "lfe_matrix", - .matchShort = "lm", - .description = "LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). \nIf specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s)" }, + { + .id = CmdlnOptionId_lfeMatrix, + .match = "lfe_matrix", + .matchShort = "lm", + .description = "LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). \nIf specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s)", + }, { .id = CmdLnOptionId_noDelayCmp, .match = "no_delay_compensation", @@ -382,7 +400,11 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_acousticEnvironmentId, .match = "acoustic_environment_id", .matchShort = "aeid", +#ifdef FIX_1053_REVERB_RECONFIGURATION + .description = "Acoustic environment ID( number > 0 ) or a sequence thereof in the format [ID1:duration1,ID2:duration2...] without braces and spaces, with ':' character separating ID from duration and ',' separating ID and duration pairs, where duration is specified in frames for BINAURAL_ROOM_REVERB output configuration.", +#else .description = "Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration", +#endif }, }; @@ -715,6 +737,9 @@ int main( int16_t zeroPadToWrite = 0; int32_t delayTimeScale = 0; int16_t i, numChannels; +#ifdef FIX_1053_REVERB_RECONFIGURATION + uint16_t aeID; +#endif ivas_error error = IVAS_ERR_OK; #ifdef WMOPS @@ -1170,7 +1195,12 @@ int main( if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + aeID = args.aeSequence.count > 0 ? args.aeSequence.pID[0] : 65535; + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) +#else if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.acousticEnvironmentId, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) +#endif { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { @@ -1180,7 +1210,11 @@ int main( } else { +#ifdef FIX_1053_REVERB_RECONFIGURATION + fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); +#else fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", args.acousticEnvironmentId ); +#endif exit( -1 ); } renderConfig.roomAcoustics.override = 1; @@ -1631,6 +1665,40 @@ int main( num_in_channels = inBuffer.config.numChannels; const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && renderConfigReader != NULL && + args.aeSequence.count > 0 && args.aeSequence.pValidity[args.aeSequence.selected] != 0 ) + { + if ( ++args.aeSequence.frameCounter >= args.aeSequence.pValidity[args.aeSequence.selected] ) + { + IVAS_RENDER_CONFIG_DATA renderConfig; + + if ( ++args.aeSequence.selected >= args.aeSequence.count ) + { + args.aeSequence.selected = 0; + } + args.aeSequence.frameCounter = 0; + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.aeSequence.pID[args.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) + { + if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid acoustic environment configuratoin parameters\n\n" ); + goto cleanup; + } + } + else + { + fprintf( stderr, "Failed to get acoustic environment with ID %d\n\n", args.aeSequence.pID[args.aeSequence.selected] ); + goto cleanup; + } + if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n\n", ivas_error_to_string( error ) ); + goto cleanup; + } + } + } +#endif numSamplesRead = 0; /* Read the input data */ @@ -2130,6 +2198,13 @@ cleanup: { free( bitsBufferData ); } +#endif +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( args.aeSequence.count > 0 ) + { + free( args.aeSequence.pID ); + free( args.aeSequence.pValidity ); + } #endif for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { @@ -2607,6 +2682,93 @@ static bool parseLfePositionConfig( } +#ifdef FIX_1053_REVERB_RECONFIGURATION +static bool parseAcousticEnvironmentIds( + const char *value, + AcousticEnvironmentSequence *aeSequence ) +{ + uint16_t k; + char config_string[RENDERER_MAX_METADATA_LINE_LENGTH]; + char *s; + char *token; + + strncpy( config_string, value, RENDERER_MAX_METADATA_LINE_LENGTH ); + s = config_string; + token = config_string; + + if ( !is_digits_only( config_string ) ) + { + + for ( k = 0; s[k]; ) + { + s[k] == ',' ? k++ : *s++; + } + k++; + + if ( k == 0 ) + { + fprintf( stdout, "Error: Invalid acoustic environment sequence specified: %s\n\n", config_string ); + return false; + } + + if ( NULL == ( aeSequence->pID = malloc( sizeof( uint16_t ) * k ) ) || + NULL == ( aeSequence->pValidity = malloc( sizeof( uint16_t ) * k ) ) ) + { + fprintf( stdout, "Error: Unable to allocate memory for acoustic environment sequence: %s\n\n", config_string ); + return false; + } + + aeSequence->count = k; + + k = 0; + + token = strtok( config_string, ":" ); + + while ( token != NULL ) + { + if ( !is_number( token ) ) + { + fprintf( stdout, "Error: Invalid token %s found in acoustic environment sequence: %s\n\n", token, config_string ); + return false; + } + aeSequence->pID[k] = (uint16_t) atoi( token ); + + token = strtok( NULL, "," ); + if ( !is_number( token ) ) + { + fprintf( stdout, "Error: Invalid token %s found in acoustic environment sequence: %s\n\n", token, config_string ); + return false; + } + aeSequence->pValidity[k] = (uint16_t) atoi( token ); + + token = strtok( NULL, ":" ); + k++; + } + + if ( k != aeSequence->count ) + { + fprintf( stdout, "Error while parsing acoustic environment sequence: %s\n\n", config_string ); + return false; + } + } + else + { + /* A single acoustic environment */ + if ( NULL == ( aeSequence->pID = malloc( sizeof( uint16_t ) ) ) || + NULL == ( aeSequence->pValidity = malloc( sizeof( uint16_t ) ) ) ) + { + fprintf( stdout, "Error: Unable to allocate memory for acoustic environment sequence: %s\n\n", config_string ); + return false; + } + aeSequence->count = 1; + aeSequence->pID[0] = (int16_t) atoi( config_string ); + aeSequence->pValidity[0] = 0; + } + + return true; +} +#endif + static bool checkRequiredArgs( CmdlnArgs args ) { @@ -2715,7 +2877,15 @@ static CmdlnArgs defaultArgs( args.directivityPatternId[i] = 65535; } +#ifdef FIX_1053_REVERB_RECONFIGURATION + args.aeSequence.count = 0; + args.aeSequence.pID = NULL; + args.aeSequence.pValidity = NULL; + args.aeSequence.selected = 0; + args.aeSequence.frameCounter = 0; +#else args.acousticEnvironmentId = 65535; +#endif return args; } @@ -2887,12 +3057,19 @@ static void parseOption( break; case CmdLnOptionId_acousticEnvironmentId: assert( numOptionValues == 1 ); +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( !parseAcousticEnvironmentIds( optionValues[0], &args->aeSequence ) ) + { + fprintf( stderr, "Invalid acoustic environment ID specified: %s\n", optionValues[0] ); + } +#else if ( !is_digits_only( optionValues[0] ) ) { fprintf( stderr, "Invalid acousting environment ID specified: %s\n", optionValues[0] ); exit( -1 ); } args->acousticEnvironmentId = (int16_t) strtol( optionValues[0], NULL, 10 ); +#endif break; case CmdLnOptionId_syncMdDelay: assert( numOptionValues == 1 ); -- GitLab From e216c1ce5ecdd88a92ca354327f5050eda47feb2 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:30:44 +0200 Subject: [PATCH 06/17] All changes in apps/decoder.c - all changes porte (yet to test) --- apps/decoder.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 72854f50d..f376eb7e9 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -90,6 +90,18 @@ static * Local structure for storing cmdln arguments *------------------------------------------------------------------------------------------*/ + +#ifdef FIX_1053_REVERB_RECONFIGURATION +typedef struct +{ + uint16_t *pID; + uint16_t *pValidity; + uint16_t count; + uint16_t selected; + uint16_t frameCounter; +} AcousticEnvironmentSequence; +#endif + typedef struct { char *inputBitstreamFilename; @@ -141,7 +153,11 @@ typedef struct uint16_t tsmScale; #endif #endif +#ifdef FIX_1053_REVERB_RECONFIGURATION + AcousticEnvironmentSequence aeSequence; +#else uint16_t acousticEnvironmentId; +#endif int16_t Opt_dpid_on; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; @@ -440,8 +456,15 @@ int main( *------------------------------------------------------------------------------------------*/ asked_frame_size = arg.renderFramesize; + +#ifdef FIX_1053_REVERB_RECONFIGURATION + uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, + arg.Opt_dpid_on, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.Opt_dpid_on, arg.acousticEnvironmentId, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -671,7 +694,11 @@ int main( if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, aeID, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) +#else if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.acousticEnvironmentId, &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) +#endif { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { @@ -681,7 +708,11 @@ int main( } else { +#ifdef FIX_1053_REVERB_RECONFIGURATION + fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); +#else fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", arg.acousticEnvironmentId ); +#endif goto cleanup; } renderConfig.roomAcoustics.override = true; @@ -966,6 +997,14 @@ cleanup: free( pcmBuf ); +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( arg.aeSequence.count > 0 ) + { + free( arg.aeSequence.pID ); + free( arg.aeSequence.pValidity ); + } +#endif + #ifdef DEBUG_SBA_AUDIO_DUMP IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels ); @@ -1187,7 +1226,15 @@ static bool parseCmdlIVAS_dec( arg->tsmScaleFileName = NULL; #endif #endif +#ifdef FIX_1053_REVERB_RECONFIGURATION + arg->aeSequence.count = 0; + arg->aeSequence.pID = NULL; + arg->aeSequence.pValidity = NULL; + arg->aeSequence.selected = 0; + arg->aeSequence.frameCounter = 0; +#else arg->acousticEnvironmentId = 65535; +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { arg->directivityPatternId[i] = 65535; @@ -1571,11 +1618,91 @@ static bool parseCmdlIVAS_dec( if ( !is_digits_only( argv[i] ) ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + uint16_t k; + char *s = argv[i]; + char *token = argv[i]; + + for ( k = 0; s[k]; ) + { + s[k] == ',' ? k++ : *s++; + } + k++; + + if ( k == 0 ) + { + fprintf( stdout, "Error: Invalid acoustic environment sequence specified: %s\n\n", argv[i] ); + usage_dec(); + return false; + } + + if ( NULL == ( arg->aeSequence.pID = malloc( sizeof( uint16_t ) * k ) ) || + NULL == ( arg->aeSequence.pValidity = malloc( sizeof( uint16_t ) * k ) ) ) + { + fprintf( stdout, "Error: Unable to allocate memory for acoustic environment sequence: %s\n\n", argv[i] ); + usage_dec(); + return false; + } + + arg->aeSequence.count = k; + + k = 0; + token = strtok( argv[i++], ":" ); + + while ( token != NULL ) + { + if ( !is_number( token ) ) + { + fprintf( stdout, "Error: Invalid token %s found in acoustic environment sequence: %s\n\n", token, argv[i] ); + usage_dec(); + return false; + } + arg->aeSequence.pID[k] = (uint16_t) atoi( token ); + + token = strtok( NULL, "," ); + if ( !is_number( token ) ) + { + fprintf( stdout, "Error: Invalid token %s found in acoustic environment sequence: %s\n\n", token, argv[i] ); + usage_dec(); + return false; + } + arg->aeSequence.pValidity[k] = (uint16_t) atoi( token ); + + token = strtok( NULL, ":" ); + k++; + } + + if ( k != arg->aeSequence.count ) + { + fprintf( stdout, "Error while parsing acoustic environment sequence: %s\n\n", argv[i] ); + usage_dec(); + return false; + } +#else fprintf( stdout, "Error: Invalid acoustic environment ID specified: %s\n\n", argv[i] ); usage_dec(); return false; +#endif + } + +#ifdef FIX_1053_REVERB_RECONFIGURATION + else + { + /* A single acoustic environment */ + if ( NULL == ( arg->aeSequence.pID = malloc( sizeof( uint16_t ) ) ) || + NULL == ( arg->aeSequence.pValidity = malloc( sizeof( uint16_t ) ) ) ) + { + fprintf( stdout, "Error: Unable to allocate memory for acoustic environment sequence: %s\n\n", argv[i] ); + usage_dec(); + return false; + } + arg->aeSequence.count = 1; + arg->aeSequence.pID[0] = (int16_t) atoi( argv[i++] ); + arg->aeSequence.pValidity[0] = 0; } +#else arg->acousticEnvironmentId = (int16_t) atoi( argv[i++] ); +#endif } else if ( strcmp( argv_to_upper, "-DPID" ) == 0 ) { @@ -1822,7 +1949,15 @@ static void usage_dec( void ) fprintf( stdout, " output configuration. ID1, ID2, ID3, ID4 specify the directivity pattern IDs used for\n" ); fprintf( stdout, " ISMs 1,2,3 and 4 respectively. This options needs to be accompanied by a render_config file,\n" ); fprintf( stdout, " otherwise a default directivity pattern is used.\n" ); +#ifdef FIX_1053_REVERB_RECONFIGURATION + fprintf( stdout, "-aeid ID : Acoustic environment ID (number > 0) or\n" ); + fprintf( stdout, " a sequence thereof in the format [ID1:duration1,ID2:duration2...]\n" ); + fprintf( stdout, " without braces and spaces, with ':' character separating ID from duration and ',' separating\n" ); + fprintf( stdout, " ID and duration pairs, where duration is specified in frames\n" ); + fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" ); +#else fprintf( stdout, "-aeid ID : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration\n" ); +#endif fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); @@ -2246,7 +2381,31 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; #endif +#ifdef FIX_1053_REVERB_RECONFIGURATION + IVAS_RENDER_CONFIG_DATA renderConfig; + RenderConfigReader *renderConfigReader = NULL; + + if ( arg.renderConfigEnabled ) + { + if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename ); + goto cleanup; + } + + if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( RenderConfigReader_read( renderConfigReader, arg.renderConfigFilename, &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename ); + goto cleanup; + } + } +#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; @@ -2456,6 +2615,38 @@ static ivas_error decodeG192( { if ( needNewFrame ) { +#ifdef FIX_1053_REVERB_RECONFIGURATION + if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && renderConfigReader != NULL && + arg.aeSequence.count > 0 && arg.aeSequence.pValidity[arg.aeSequence.selected] != 0 ) + { + if ( ++arg.aeSequence.frameCounter >= arg.aeSequence.pValidity[arg.aeSequence.selected] ) + { + if ( ++arg.aeSequence.selected >= arg.aeSequence.count ) + { + arg.aeSequence.selected = 0; + } + arg.aeSequence.frameCounter = 0; + if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.aeSequence.pID[arg.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) + { + if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Invalid acoustic environment configuratoin parameters\n\n" ); + goto cleanup; + } + } + else + { + fprintf( stderr, "Failed to get acoustic environment with ID %d\n\n", arg.aeSequence.pID[arg.aeSequence.selected] ); + goto cleanup; + } + if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + } + } +#endif #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING if ( arg.tsmScaleFileEnabled ) @@ -2884,6 +3075,10 @@ static ivas_error decodeG192( cleanup: +#ifdef FIX_1053_REVERB_RECONFIGURATION + RenderConfigReader_close( &renderConfigReader ); +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT split_rend_reader_writer_close( &splitRendWriter ); #endif -- GitLab From 2092c67b63957c5e21f55ec3ce35e12e6ccc3203 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:38:40 +0200 Subject: [PATCH 07/17] formatting changes --- apps/decoder.c | 1 - lib_com/options.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index f376eb7e9..4ee5edcfe 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3078,7 +3078,6 @@ cleanup: #ifdef FIX_1053_REVERB_RECONFIGURATION RenderConfigReader_close( &renderConfigReader ); #endif - #ifdef SPLIT_REND_WITH_HEAD_ROT split_rend_reader_writer_close( &splitRendWriter ); #endif diff --git a/lib_com/options.h b/lib_com/options.h index c5dc315ad..4b860e415 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -208,7 +208,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ @@ -225,6 +224,7 @@ #define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to actiate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on )*/ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ +#define FIX_1053_REVERB_RECONFIGURATION /* Philips: issue 1053: fix for dynamic switching of acoustic environment */ /* #################### End BASOP porting switches ############################ */ -- GitLab From f0c43c1556f576bf961bef5d731778235a9f12fa Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:00:02 +0200 Subject: [PATCH 08/17] Fixed build error and clang error - ready for draft push --- lib_dec/ivas_binRenderer_internal.c | 3 +-- lib_rend/lib_rend.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index b94fac2e5..77400b130 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1256,7 +1256,7 @@ ivas_error ivas_binRenderer_open( return error; } -#ifdef FIX_1053_REVERB_RECONFIGURATION +#ifndef FIX_1053_REVERB_RECONFIGURATION /* initialize the dmx matrix */ if ( hBinRenderer->nInChannels != HOA3_CHANNELS ) { @@ -1268,7 +1268,6 @@ ivas_error ivas_binRenderer_open( } } } -#else #ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM if ( hBinRenderer->nInChannels != HOA3_CHANNELS ) #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 460da7d93..636d0dda0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7965,7 +7965,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 1a4b4f7f20986c176eb249469d451205c71fba71 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:35:48 +0200 Subject: [PATCH 09/17] formatting fix --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 636d0dda0..d96c1798c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7965,7 +7965,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t ) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 16d58f89b49802eff3c7ea34aae7857f623a1164 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:45:37 +0200 Subject: [PATCH 10/17] clang format fix --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d96c1798c..53c6ac21d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7965,7 +7965,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t ) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From 58bef8c027cd0354c0232d32fcd1ed1dbbbf4670 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:03:44 +0200 Subject: [PATCH 11/17] lib_rend fixes --- lib_rend/lib_rend.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 53c6ac21d..7bec6a68a 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4547,10 +4547,9 @@ int16_t IVAS_REND_FeedRenderConfig( } #ifdef FIX_1053_REVERB_RECONFIGURATION - /* Re-initialise reverb instance if already available */ + /* Re-initialize reverb instance if already available */ /* ISM inputs */ - for ( i = 0, pIsmInput = hIvasRend->inputsIsm; i < RENDERER_MAX_BIN_INPUTS; ++i, ++pIsmInput ) - + for ( i = 0, pIsmInput = hIvasRend->inputsIsm; i < RENDERER_MAX_ISM_INPUTS; ++i, ++pIsmInput ) { if ( pIsmInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) { @@ -4577,7 +4576,7 @@ int16_t IVAS_REND_FeedRenderConfig( } } - /*MASA inputs */ + /* MASA inputs */ for ( i = 0, pMasaInput = hIvasRend->inputsMasa; i < RENDERER_MAX_MASA_INPUTS; ++i, ++pMasaInput ) { if ( pMasaInput->base.inConfig == IVAS_AUDIO_CONFIG_INVALID ) -- GitLab From 26a91ef23a05fe232df457bfe4236058bb4284f6 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:22:00 +0200 Subject: [PATCH 12/17] restart pipeline -- GitLab From b93ad8b2011c5ba07a71aa1a0da6abbe42bfe9b9 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 20 Jun 2025 16:26:13 +0200 Subject: [PATCH 13/17] clang patch --- lib_rend/lib_rend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8181bbd05..29d38910d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4401,7 +4401,6 @@ int16_t IVAS_REND_FeedRenderConfig( return error; } } - } /* SBA inputs */ -- GitLab From 7cd114d2cd75372844db56986d59724a505ad63e Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:59:21 +0200 Subject: [PATCH 14/17] Activated pre-computed hrtf compiler switch and fixed logical errors --- lib_com/options.h | 4 ++-- lib_rend/lib_rend.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 67e926e01..cc7b04766 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -184,8 +184,8 @@ #define FIX_960_SYN_OUTPUT /* VA: issue 960: unused function syn_output() is removed */ #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the 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 */ -//#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format */ +#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 FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 29d38910d..30c81304c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4338,7 +4338,7 @@ int16_t IVAS_REND_FeedRenderConfig( return error; } } - if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend != NULL ) + if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend[0] != NULL ) { if ( ( error = ivas_reverb_open( &pIsmInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { @@ -4358,7 +4358,7 @@ int16_t IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend != NULL ) { - if ( pMasaInput->hMasaExtRend->hDiracDecBin != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) + if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL ) ) != IVAS_ERR_OK ) @@ -4394,7 +4394,7 @@ int16_t IVAS_REND_FeedRenderConfig( } } - if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) + if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pMcInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { @@ -4412,7 +4412,7 @@ int16_t IVAS_REND_FeedRenderConfig( continue; } - if ( pSbaInput->crendWrapper != NULL && pSbaInput->crendWrapper->hCrend != NULL && pSbaInput->crendWrapper->hCrend[0]->hReverb != NULL ) + if ( pSbaInput->crendWrapper != NULL && pSbaInput->crendWrapper->hCrend[0] != NULL && pSbaInput->crendWrapper->hCrend[0]->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pSbaInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pSbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { -- GitLab From b603bd87d63938f5e1672f875eb4c9f1a1f4b5ce Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 4 Jul 2025 15:32:00 +0200 Subject: [PATCH 15/17] Cleanup --- apps/decoder.c | 1 - apps/renderer.c | 3 +-- lib_dec/lib_dec.c | 4 ---- lib_rend/ivas_prot_rend.h | 2 +- lib_rend/ivas_reverb.c | 1 - lib_rend/lib_rend.c | 3 +-- 6 files changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0557564ef..091a9a6d5 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -443,7 +443,6 @@ int main( if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.Opt_dpid_on, arg.acousticEnvironmentId, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) #endif - { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/renderer.c b/apps/renderer.c index 6b5dc95c2..bdece9e0d 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -151,7 +151,6 @@ typedef struct } AcousticEnvironmentSequence; #endif - typedef struct { char executableName[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -1115,7 +1114,7 @@ int main( else { #ifdef FIX_1053_REVERB_RECONFIGURATION - fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", aeID ); + fprintf( stderr, "\nFailed to get acoustic environment with ID: %d\n\n", aeID ); #else fprintf( stderr, "\nFailed to get acoustic environment with ID: %d\n\n", args.acousticEnvironmentId ); #endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 68c243f8a..998a1d85a 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2105,11 +2105,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; -#ifdef FIX_1053_REVERB_RECONFIGURATION - ivas_error error; -#else ivas_error error; -#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hRenderConfig == NULL ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 3bf8bfb31..3e22e257d 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -968,7 +968,7 @@ 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 */ + 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 */ diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index b970fbdc8..5d2ba3f56 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1383,7 +1383,6 @@ ivas_error ivas_reverb_open( } } #else - /* init predelay */ ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer, params.pre_delay, predelay_bf_len ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 5acaf5ae0..d20542e28 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4393,8 +4393,7 @@ int16_t IVAS_REND_FeedRenderConfig( return error; } } - - if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) + if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] != NULL && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pMcInput->crendWrapper->hCrend[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pMcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { -- GitLab From 0f3cb0409d20617785007672dafacbde279fa62b Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 4 Jul 2025 15:34:50 +0200 Subject: [PATCH 16/17] Cleanup --- readme.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 9b1ab852d..31904ee6a 100644 --- a/readme.txt +++ b/readme.txt @@ -314,7 +314,11 @@ Options: -exof File : External orientation trajectory File for simulation of external orientations -dpid ID : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration --aeid ID : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output config. +-aeid ID : Acoustic environment ID (number > 0) or + a sequence thereof in the format [ID1:duration1,ID2:duration2...] + without braces and spaces, with ':' character separating ID from duration and ',' separating + ID and duration pairs, where duration is specified in frames + for BINAURAL_ROOM_REVERB output configuration. -lp Position : Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees. If specified, overrides the default behavior which attempts to map input to output LFE channel(s) -- GitLab From 22a78afb8391f2374cc6b630113aa8f0f4715c99 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 4 Aug 2025 17:48:43 +0200 Subject: [PATCH 17/17] trigger pipeline -- GitLab