From 9b4f2ec753c773885bdb5bb4d7de9a69a4db7a9f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Sep 2025 09:28:12 +0200 Subject: [PATCH 1/4] fix FIX_1995_REVERB_INIT --- lib_com/options.h | 1 + lib_rend/ivas_prot_rend.h | 3 +-- lib_rend/ivas_reverb.c | 30 +++++++++++++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 62cb9b3b78..83a32c2eab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,6 +163,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ +#define FIX_1995_REVERB_INIT /* issue 1995: Fix use-of-uninitialized-value in ivas_binaural_reverb_init() */ /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 2268f62add..126112a7db 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -945,8 +945,7 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const int32_t sampling_rate, /* i : sampling rate */ const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ - , + const float *defaultEne, /* i : default reverberation energies */ float *earlyEne /* i/o: Early part energies to be modified */ ); diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index c12fa8488b..7d78522e84 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1859,12 +1859,13 @@ static ivas_error ivas_binaural_reverb_open( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_init() * - * Allocate and initialize binaural room reverberator handle - * for CLDFB renderers + * Initialize binaural room reverberator handle for FastConv renderer *------------------------------------------------------------------------*/ + ivas_error ivas_binaural_reverb_init( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ @@ -1873,9 +1874,8 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const int32_t sampling_rate, /* i : sampling rate */ const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ - , - float *earlyEne /* i/o: Early part energies to be modified */ + const float *defaultEne, /* i : default reverberation energies */ + float *earlyEne /* i/o: Early part energies to be modified */ ) { ivas_error error; @@ -1883,24 +1883,23 @@ ivas_error ivas_binaural_reverb_init( float revTimes[CLDFB_NO_CHANNELS_MAX]; float revEne[CLDFB_NO_CHANNELS_MAX]; - error = IVAS_ERR_OK; - if ( roomAcoustics != NULL ) { - - if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, - hHrtfStatistics, - sampling_rate, - revTimes, - revEne ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ) ) != IVAS_ERR_OK ) { return error; } + + /* preDelay parameter = acousticPreDelay * sampling_rate / numBins */ preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); } else { +#ifdef FIX_1995_REVERB_INIT + for ( bin = 0; bin < numBins; bin++ ) +#else for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) +#endif { revTimes[bin] = defaultTimes[bin]; revEne[bin] = defaultEne[bin]; @@ -1908,7 +1907,11 @@ ivas_error ivas_binaural_reverb_init( preDelay = 10; } +#ifdef FIX_1995_REVERB_INIT + for ( bin = 0; bin < numBins; bin++ ) +#else for ( bin = 0; bin < CLDFB_NO_CHANNELS_MAX; bin++ ) +#endif { /* Adjust the room effect parameters when the reverberation time is less than a threshold value, to avoid spectral artefacts with the synthetic reverberator. */ @@ -1943,6 +1946,7 @@ ivas_error ivas_binaural_reverb_init( return error; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() * -- GitLab From fa419702187c48f47f6e82b0a5809f6e533ed112 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Sep 2025 09:53:39 +0200 Subject: [PATCH 2/4] update comment --- lib_rend/ivas_reverb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 7d78522e84..a6ade569bc 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1890,7 +1890,7 @@ ivas_error ivas_binaural_reverb_init( return error; } - /* preDelay parameter = acousticPreDelay * sampling_rate / numBins */ + /* Convert preDelay from seconds to CLDFB slots as needed by binaural reverb */ preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); } else -- GitLab From 67463e132433ad91dd69a0530e135f81e2d56bc1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Sep 2025 10:13:20 +0200 Subject: [PATCH 3/4] improvement --- lib_rend/ivas_reverb.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index a6ade569bc..052c238589 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -79,10 +79,10 @@ #define MAX_NR_OUTPUTS ( 2 ) -const int16_t init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 }; -const int16_t default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1861, 1523, 1259, 1069, 919, 809, 719 }; -const int16_t default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; -const int16_t default_loop_delay_16k[IVAS_REV_MAX_NR_BRANCHES] = { 769, 619, 509, 421, 353, 307, 269, 239 }; +static const int16_t init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 }; +static const int16_t default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1861, 1523, 1259, 1069, 919, 809, 719 }; +static const int16_t default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; +static const int16_t default_loop_delay_16k[IVAS_REV_MAX_NR_BRANCHES] = { 769, 619, 509, 421, 353, 307, 269, 239 }; /*------------------------------------------------------------------------------------------* * Local Struct definition @@ -682,8 +682,6 @@ static ivas_error initialize_reverb_filters( { ivas_error error; - error = IVAS_ERR_OK; - /* init correlation and coloration filters */ if ( ( error = ivas_reverb_t2f_f2t_init( &hReverb->fft_filter_ols, hReverb->fft_size, hReverb->fft_subblock_size ) ) != IVAS_ERR_OK ) { @@ -710,7 +708,7 @@ static ivas_error initialize_reverb_filters( return error; } - return error; + return IVAS_ERR_OK; } @@ -1060,7 +1058,6 @@ ivas_error ivas_reverb_open( int16_t fft_hist_size, transition_start, transition_length; int16_t nr_fc_input, nr_fc_fft_filter; - error = IVAS_ERR_OK; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; predelay_bf_len = output_frame; @@ -1240,7 +1237,7 @@ ivas_error ivas_reverb_open( *hReverb = pState; - return error; + return IVAS_ERR_OK; } -- GitLab From 4e3192936c282de45fdd0e5ef5f1da6c8293d061 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Sep 2025 10:40:46 +0200 Subject: [PATCH 4/4] use CLDFB_SLOTS_PER_SECOND macro --- lib_rend/ivas_reverb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 052c238589..b4adf013fb 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1888,7 +1888,7 @@ ivas_error ivas_binaural_reverb_init( } /* Convert preDelay from seconds to CLDFB slots as needed by binaural reverb */ - preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); + preDelay = (int16_t) roundf( roomAcoustics->acousticPreDelay * CLDFB_SLOTS_PER_SECOND ); } else { -- GitLab