From 7c6c6feb753b54566173b0981580dc1db402dd50 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 2 Sep 2025 18:17:07 +0200 Subject: [PATCH 1/3] fix FIX_1995_REVERB_INIT --- lib_com/options.h | 1 + lib_rend/ivas_reverb_fx.c | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5ef2fe4f5..42600a81f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,6 +85,7 @@ #define FIX_1980_CRASH_FDCNG_ENCODESID /* FhG: Add one bit of headroom in e_fx calculation in FdCng_encodeSID_ivas_fx() */ #define FIX_1987_CRASH_OMASA_ENERGY /* FhG: Replace cldfbAnalysis_ts_fx_fix_q() with cldfbAnalysis_ts_fx_var_q() to avoid assertion error */ #define FIX_1985_SBA_714_HF_LOSS /* Dlb: Fix for issue 1985, improved dirac ref pow precision*/ +#define FIX_1995_REVERB_INIT /* issue 1995: Fix use-of-uninitialized-value in ivas_binaural_reverb_init() */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index aa59e819a..85c91b971 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2426,6 +2426,7 @@ static ivas_error ivas_binaural_reverb_open_fx( * Allocate and initialize binaural room reverberator handle * for CLDFB renderers *------------------------------------------------------------------------*/ + ivas_error ivas_binaural_reverb_init( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ @@ -2434,9 +2435,8 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const Word32 sampling_rate, /* i : sampling rate */ const Word32 *defaultTimes, /* i : default reverberation times */ - const Word32 *defaultEne /* i : default reverberation energies */ - , - Word32 *earlyEne /* i/o: Early part energies to be modified */ + const Word32 *defaultEne, /* i : default reverberation energies */ + Word32 *earlyEne /* i/o: Early part energies to be modified */ ) { ivas_error error; @@ -2455,12 +2455,16 @@ ivas_error ivas_binaural_reverb_init( return error; } - temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( ( IVAS_48k / CLDFB_NO_CHANNELS_MAX ) >> 1 ) ); // Q11 - preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 + temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( ( 48000 / CLDFB_NO_CHANNELS_MAX ) >> 1 ) ); // Q11 + preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 } 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]; move32(); @@ -2470,7 +2474,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. */ @@ -2522,6 +2530,8 @@ ivas_error ivas_binaural_reverb_init( return error; } + + /*------------------------------------------------------------------------- * ivas_binaural_reverb_close_fx() * -- GitLab From d5451aaf0a0dbd32d425a653881f416ed10d85ad Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Sep 2025 10:29:32 +0200 Subject: [PATCH 2/3] improvement, bring it closer to float --- lib_rend/ivas_prot_rend_fx.h | 120 ++++++++++--------- lib_rend/ivas_reverb_fx.c | 224 +++++++++++++++++++++-------------- 2 files changed, 201 insertions(+), 143 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 84af7ab1c..32d3639be 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -914,10 +914,10 @@ ivas_error ivas_rend_crendProcessSubframe( const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ - Word32 *input_f[], /* i : transport channels */ - Word32 *output[], /* i/o: input/output audio channels */ - const Word16 n_samples_to_render, /* i : output frame length per channel */ - const Word32 output_Fs, /* i : output sampling rate */ + Word32 *input_f[], /* i : transport channels */ + Word32 *output[], /* i/o: input/output audio channels */ + const Word16 n_samples_to_render, /* i : output frame length per channel */ + const Word32 output_Fs, /* i : output sampling rate */ const Word16 pos_idx ); @@ -927,16 +927,15 @@ ivas_error ivas_rend_crendProcessSubframe( *----------------------------------------------------------------------------------*/ ivas_error ivas_binaural_reverb_init( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - const Word16 numBins, /* i : number of CLDFB bins */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const Word16 numBins, /* i : number of CLDFB bins */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word32 *defaultTimes, /* i : default reverberation times */ - const Word32 *defaultEne /* i : default reverberation energies */ - , - Word32 *earlyEne /* i/o: Early part energies to be modified */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word32 *defaultTimes, /* i : default reverberation times */ + const Word32 *defaultEne, /* i : default reverberation energies */ + Word32 *earlyEne /* i/o: Early part energies to be modified */ ); void ivas_binaural_reverb_close_fx( @@ -944,83 +943,87 @@ void ivas_binaural_reverb_close_fx( ); void ivas_binaural_reverb_processSubframe_fx( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const Word16 numInChannels, /* i : num inputs to be processed */ - const Word16 numSlots, /* i : number of slots to be processed */ + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const Word16 numInChannels, /* i : num inputs to be processed */ + const Word16 numSlots, /* i : number of slots to be processed */ Word32 inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */ - Word32 inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ - Word32 outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ - Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ + Word32 inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ + Word32 outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ + Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ ); ivas_error ivas_reverb_open_fx( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ - const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ - const Word32 output_Fs /* i : output sampling rate */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + const Word32 output_Fs /* i : output sampling rate */ ); void ivas_reverb_close( REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ ); + ivas_error ivas_reverb_process_fx( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const Word16 mix_signals, /* i : add reverb to output signal */ - Word32 *pcm_in[], /* i (Q11): the PCM audio to apply reverb on */ - Word32 *pcm_out[], /* o : the PCM audio with reverb applied */ - const Word16 i_ts /* i : (Q0) subframe index */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ + const Word16 mix_signals, /* i : add reverb to output signal */ + Word32 *pcm_in[], /* i (Q11): the PCM audio to apply reverb on */ + Word32 *pcm_out[], /* o : the PCM audio with reverb applied */ + const Word16 i_ts /* i : (Q0) subframe index */ ); void ivas_rev_delay_line_init( - ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ - Word32 *memory_buffer, /* i : the memory buffer to use for the delay line Q11 */ - const UWord16 delay, /* i : the delay */ - const UWord16 maxdelay /* i : maximum delay to be supported */ + ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ + Word32 *memory_buffer, /* i : the memory buffer to use for the delay line Q11 */ + const UWord16 delay, /* i : the delay */ + const UWord16 maxdelay /* i : maximum delay to be supported */ ); -/*! r: sample gotten out of delay line, and amplified by set gain */ -Word32 ivas_rev_delay_line_get_sample_fx( /* Q11 */ - ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ + +/*! r: sample gotten out of delay line, and amplified by set gain, Q11 */ +Word32 ivas_rev_delay_line_get_sample_fx( + ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ); void ivas_rev_delay_line_feed_sample_fx( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - Word32 input /* i : the sample to feed Q11 */ + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + Word32 input /* i : the sample to feed Q11 */ ); void ivas_rev_delay_line_get_sample_blk_fx( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - const UWord16 blk_size, /* i : number of samples in the data block */ - Word32 *output /* i/o: amples gotten out of delay line, and amplified by set gainin */ + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + const UWord16 blk_size, /* i : number of samples in the data block */ + Word32 *output /* i/o: amples gotten out of delay line, and amplified by set gainin */ ); void ivas_rev_delay_line_feed_sample_blk_fx( - ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ - const UWord16 blk_size, /* i : number of samples in the input data block */ - Word32 *input /* i : the samples to feed Q11 */ + ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ + const UWord16 blk_size, /* i : number of samples in the input data block */ + Word32 *input /* i : the samples to feed Q11 */ ); + void ivas_reverb_iir_filt_init( ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */ - const UWord16 maxTaps /* i : maximum number of filter taps */ + const UWord16 maxTaps /* i : maximum number of filter taps */ ); - void ivas_reverb_iir_filt_set( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ - UWord16 nr_taps, /* i : number of IIR filter taps */ - const Word16 *coefA, /* i : A filter coefficients to set */ - const Word16 *coefB /* i : the B filter coefficients to set */ + UWord16 nr_taps, /* i : number of IIR filter taps */ + const Word16 *coefA, /* i : A filter coefficients to set */ + const Word16 *coefB /* i : the B filter coefficients to set */ ); + void ivas_reverb_iir_filt_2taps_feed_blk_fx( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ - const UWord16 blk_size, /* i : size */ - const Word32 *input, /* i : input buffer */ + const UWord16 blk_size, /* i : size */ + const Word32 *input, /* i : input buffer */ Word32 *output /* i : output buffer */ ); UWord16 int_log2( UWord32 powerOf2 ); + Word16 ivas_reverb_t2f_f2t_init( ivas_reverb_t2f_f2t_t *t2f_f2t, const Word16 fft_size, @@ -1030,6 +1033,7 @@ Word16 ivas_reverb_t2f_f2t_init( void ivas_reverb_t2f_f2t_ClearHistory( ivas_reverb_t2f_f2t_t *t2f_f2t ); + void ivas_reverb_t2f_f2t_in_fx( ivas_reverb_t2f_f2t_t *t2f_f2t, Word32 *input_L, // i: Qx @@ -1045,6 +1049,7 @@ void ivas_reverb_t2f_f2t_out_fx( Word32 *output_L, // i/o: Qx Word32 *output_R // i/o: Qx ); + Word16 ivas_reverb_fft_filter_init( ivas_reverb_fft_filter_t *fft_filter, const Word16 fft_size @@ -1054,6 +1059,7 @@ void ivas_reverb_fft_filter_ComplexMul_fx( ivas_reverb_fft_filter_t *fft_filter, /* i */ Word32 *buffer /* i/o: Qx */ ); + void ivas_reverb_fft_filter_CrossMix_fx( Word32 *buffer0, // i/o: Qx Word32 *buffer1, // i/o: Qx @@ -1063,7 +1069,9 @@ void ivas_reverb_fft_filter_CrossMix_fx( void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( rv_fftwf_type_complex_fx *spectrum, // i: Qx Word32 *fft_real, // o: Qx - const Word16 fft_size); + const Word16 fft_size +); + void ivas_reverb_define_window_fft_fx( Word32 *pWindow, //output in Q31 const Word16 transitionStart, @@ -1080,6 +1088,7 @@ Word16 ivas_reverb_calc_color_filters_fx( Word16 *q_pBeqL, Word16 *q_pBeqR ); + Word16 ivas_reverb_calc_correl_filters_fx( Word32 *pTargetICC, //input in Q30 const Word32 *pWindow, //input in Q30 @@ -1089,6 +1098,7 @@ Word16 ivas_reverb_calc_correl_filters_fx( Word16 *q_pU, //Output q Word16 *q_pV //output q ); + void ivas_reverb_calc_color_levels_fx( const Word32 output_Fs, const Word16 freq_count, @@ -1100,14 +1110,16 @@ void ivas_reverb_calc_color_levels_fx( const Word16 *pLoop_delays, const Word32 *pT60_filter_coeff, //input in Q31 Word32 *pTarget_color_L, //output in Q30 - Word32 *pTarget_color_R); //output in Q30 + Word32 *pTarget_color_R //output in Q30 +); ivas_error ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const Word32 output_Fs, Word32 *pOutput_t60, - Word32 *pOutput_ene ); + Word32 *pOutput_ene +); void ivas_reverb_interp_on_freq_grid_fx( const Word16 input_table_size, @@ -1117,6 +1129,8 @@ void ivas_reverb_interp_on_freq_grid_fx( const Word32 *pOutput_fc, Word32 *pOutput_grid //output in the same Q-format as input ); + + /*---------------------------------------------------------------------------------* * Shoebox Prototypes *-----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 85c91b971..996de0cf6 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -41,24 +41,6 @@ #include "wmc_auto.h" #include "debug.h" -static Word16 wrap_rad_fixed( - Word32 angle /* Q13 */ ) -{ - Word32 L_tmp = angle; - move32(); - - /* Wrap azimuth value */ - WHILE( GT_32( L_tmp, EVS_PI_FX ) ) - { - L_tmp = L_sub( L_tmp, EVS_2PI_FX ); - } - WHILE( LE_32( L_tmp, -EVS_PI_FX ) ) - { - L_tmp = L_add( L_tmp, EVS_2PI_FX ); - } - - return extract_l( L_tmp ); -} /* The reverberator structure implemented here is described in detail in: * Vilkamo, J., Neugebauer, B., & Plogsties, J. (2012). Sparse frequency-domain reverberator. @@ -78,22 +60,14 @@ static Word16 wrap_rad_fixed( #define INNER_BLK_SIZE 80 /* size of data blocks used for more efficient delay line and IIR filter processing */ /* should be a divisor of the frame length at any sampling rate and an even number*/ -#define FFT_FILTER_WND_FLAT_REGION ( 0.40f ) /* flat section (==1) length of FFT filter window, in proportion to overlap */ -#define FFT_FILTER_WND_TRANS_REGION ( 0.15f ) /* transition (1->0) length of FFT filter window, in proportion to overlap */ #define FFT_FILTER_WND_FLAT_REGION_FX ( 26214 ) /*Q16 flat section (==1) length of FFT filter window, in proportion to overlap */ #define FFT_FILTER_WND_TRANS_REGION_FX ( 9830 ) /*Q16 transition (1->0) length of FFT filter window, in proportion to overlap */ -#define REF_LF_MIN ( 100.0f ) -#define REF_LF_MAX ( 250.0f ) -#define REF_HF_MIN ( 5000.0f ) -#define REF_HF_MAX ( 7950.0f ) #define REF_LF_MIN_FX ( 100 ) #define REF_LF_MAX_FX ( 250 ) #define REF_HF_MIN_FX ( 5000 ) #define REF_HF_MAX_FX ( 7950 ) -#define LF_BIAS ( 0.5f ) -#define DEFAULT_SRC_DIST ( 1.5f ) /* default source distance [m] for reverb dmx factor computing */ #define DMX_GAIN ( 1410542208 ) #define IVAS_REVERB_FFT_SIZE_48K ( 512 ) #define IVAS_REVERB_FFT_SIZE_32K ( 512 ) @@ -109,27 +83,30 @@ static Word16 wrap_rad_fixed( #define M120Q8 ( -30720 ) //-120 in Q8 #endif -const Word16 init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 }; -const Word16 default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1861, 1523, 1259, 1069, 919, 809, 719 }; -const Word16 default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; -const Word16 default_loop_delay_16k[IVAS_REV_MAX_NR_BRANCHES] = { 769, 619, 509, 421, 353, 307, 269, 239 }; +static const Word16 init_loop_delay[IVAS_REV_MAX_NR_BRANCHES] = { 37, 31, 29, 23, 19, 17, 13, 11 }; +static const Word16 default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1861, 1523, 1259, 1069, 919, 809, 719 }; +static const Word16 default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; +static const Word16 default_loop_delay_16k[IVAS_REV_MAX_NR_BRANCHES] = { 769, 619, 509, 421, 353, 307, 269, 239 }; + /*------------------------------------------------------------------------------------------* * Local Struct definition *------------------------------------------------------------------------------------------*/ + typedef struct ivas_reverb_params_t { - Word16 pre_delay; /* Delay of the FDC reverb, first peak after pre_delay samples. Note that */ - /* there may be non-zero samples earlier due to the filters being */ - /* linear-phase. */ - Word16 nr_loops; /* Number of feedback loops (= L) */ - Word16 pLoop_delays[IVAS_REV_MAX_NR_BRANCHES]; /* Delay for each feedback loop in samples. */ /* Feedback [L][L] matrix that mixes the signals of the loops. */ - Word32 pLoop_feedback_matrix_fx[IVAS_REV_MAX_NR_BRANCHES * IVAS_REV_MAX_NR_BRANCHES]; /* Feedback [L][L] matrix that mixes the signals of the loops. */ - Word16 nr_outputs; /* Nr of signals extracted from the loops (= S). */ - /* Currently this is fixed to 2. */ /* Mix [S][L] matrix from feedback loops to outputs. */ - Word16 pLoop_extract_matrix_fx[MAX_NR_OUTPUTS * IVAS_REV_MAX_NR_BRANCHES]; /* Mix [S][L] matrix from feedback loops to outputs. */ /* In Matlab: [S x L] - Currently S=2, later may be more than 2 for speaker playback. */ - Word16 t60_filter_order; /* Filter order (length of vector) */ - Word16 pT60_filter_coeff_fx[MAX_NR_OUTPUTS * IVAS_REV_MAX_NR_BRANCHES * IVAS_REV_MAX_IIR_FILTER_LENGTH]; + Word16 pre_delay; /* Delay of the FDC reverb, first peak after pre_delay samples. Note that */ + /* there may be non-zero samples earlier due to the filters being */ + /* linear-phase. */ + Word16 nr_loops; /* Number of feedback loops (= L) */ + Word16 pLoop_delays[IVAS_REV_MAX_NR_BRANCHES]; /* Delay for each feedback loop in samples. */ + Word32 pLoop_feedback_matrix_fx[IVAS_REV_MAX_NR_BRANCHES * IVAS_REV_MAX_NR_BRANCHES]; /* Feedback [L][L] matrix that mixes the signals of the loops. */ + Word16 nr_outputs; /* Nr of signals extracted from the loops (= S). */ + /* Currently this is fixed to 2. */ + Word16 pLoop_extract_matrix_fx[MAX_NR_OUTPUTS * IVAS_REV_MAX_NR_BRANCHES]; /* Mix [S][L] matrix from feedback loops to outputs. */ + /* In Matlab: [S x L] - Currently S=2, later may be more than 2 for speaker playback. */ + Word16 t60_filter_order; /* Filter order (length of vector) */ + Word16 pT60_filter_coeff_fx[MAX_NR_OUTPUTS * IVAS_REV_MAX_NR_BRANCHES * IVAS_REV_MAX_IIR_FILTER_LENGTH]; /* Filters [][] in feedback loops, controlling T60. */ /* In Matlab: IIR: [(2 * L) x ( + 1)] (odd: b-vector, even: a-vector) */ /* In Matlab: FIR: [L x ] */ Word32 *pFc_fx; /* Center frequencies for FFT filter design */ @@ -146,12 +123,40 @@ typedef struct ivas_reverb_params_t /* when nr_outputs != 2 correlation filtering is never supported). */ } ivas_reverb_params_t; + /*------------------------------------------------------------------------------------------* * Static functions declarations *------------------------------------------------------------------------------------------*/ static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, const UWord16 nrFrequencies, Word16 *pFrequencies_fx, Word16 *pCoeffA_fx, Word16 *pCoeffB_fx, const Word16 fNyquist_fx ); + +/*------------------------------------------------------------------------- + * wrap_rad_fixed() + * + * + *------------------------------------------------------------------------*/ + +static Word16 wrap_rad_fixed( + Word32 angle /* Q13 */ ) +{ + Word32 L_tmp = angle; + move32(); + + /* Wrap azimuth value */ + WHILE( GT_32( L_tmp, EVS_PI_FX ) ) + { + L_tmp = L_sub( L_tmp, EVS_2PI_FX ); + } + WHILE( LE_32( L_tmp, -EVS_PI_FX ) ) + { + L_tmp = L_add( L_tmp, EVS_2PI_FX ); + } + + return extract_l( L_tmp ); +} + + /*------------------------------------------------------------------------- * binRend_rand() * @@ -208,7 +213,6 @@ static void ivas_binaural_reverb_setPreDelay_fx( * *------------------------------------------------------------------------*/ - static void ivas_binaural_reverb_setReverbTimes_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word32 output_Fs, /* i : sampling_rate */ @@ -217,7 +221,6 @@ static void ivas_binaural_reverb_setReverbTimes_fx( ) { Word16 bin, ch, tap, sample; - Word32 binCenterFreq_fx, diffuseFieldICC_fx, tmpVal_fx, attenuationFactorPerSample_fx, L_tmp; Word32 intendedEnergy_fx, actualizedEnergy_fx, energyBuildup_fx, currentEnergy_fx, attenuationFactorPerSampleSq_fx; Word16 tmp, tmp_exp, scale, tmpVal_exp, attenuationFactorPerSample_exp, attenuationFactorPerSampleSq_exp, energyBuildup_exp, currentEnergy_exp, intendedEnergy_exp, actualizedEnergy_exp; @@ -338,7 +341,6 @@ static void ivas_binaural_reverb_setReverbTimes_fx( /* Design sparse decorrelation filters. The decorrelation filters, due to random procedures involved, * may affect the spectrum of the output. The spectral effect is therefore monitored and compensated for. */ - intendedEnergy_fx = 0; move32(); intendedEnergy_exp = 0; @@ -350,7 +352,6 @@ static void ivas_binaural_reverb_setReverbTimes_fx( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - energyBuildup_fx = 0; move32(); energyBuildup_exp = 0; @@ -447,9 +448,11 @@ static void ivas_binaural_reverb_setReverbTimes_fx( hReverb->reverbEqGains_fx[bin] = L_shl( hReverb->reverbEqGains_fx[bin], reverb_exp ); // making as Q31 move32(); } + return; } + /*-----------------------------------------------------------------------------------------* * Function compute_feedback_matrix() * @@ -484,7 +487,6 @@ static ivas_error compute_feedback_matrix_fx( } } - return IVAS_ERR_OK; } @@ -516,6 +518,8 @@ static void compute_2_out_extract_matrix_fx( return; } + + /*-----------------------------------------------------------------------------------------* * Function set_base_config() * @@ -569,6 +573,7 @@ static ivas_error set_base_config_fx( } compute_2_out_extract_matrix_fx( pParams->pLoop_extract_matrix_fx, pParams->nr_loops ); + /* pre-set the various filters; they will be set later based on reverb configuration */ pParams->t60_filter_order = 1; /* set to 1 in base config. */ move16(); @@ -587,17 +592,22 @@ static ivas_error set_base_config_fx( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function calc_dmx_gain() * * Computes the downmix gain *-----------------------------------------------------------------------------------------*/ + static Word32 calc_dmx_gain_fx( void ) { const Word32 gain = DMX_GAIN; // Q23 move32(); + return gain; } + + /*-----------------------------------------------------------------------------------------* * Function calc_predelay() * @@ -610,6 +620,7 @@ static void calc_predelay_fx( const Word32 output_Fs ) { Word16 predelay, fbdelay, output_frame; + predelay = round_fx( L_shl( Mult_32_32( L_shl( output_Fs, 15 ), acoustic_predelay_sec ), 5 ) ); output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); fbdelay = pParams->pLoop_delays[sub( pParams->nr_loops, 1 )]; @@ -630,16 +641,17 @@ static void calc_predelay_fx( pParams->pre_delay = predelay; // Q0 move16(); - move16(); - move16(); + return; } + /*-----------------------------------------------------------------------------------------* * Function compute_t60_coeffs() * * Calculate Jot reverb's T60 filter coefficients *-----------------------------------------------------------------------------------------*/ + static ivas_error compute_t60_coeffs_fx( ivas_reverb_params_t *pParams, const Word16 nr_fc_fft_filter, /*Q0*/ @@ -764,6 +776,7 @@ static ivas_error compute_t60_coeffs_fx( pParams->pLoop_delays[loop_idx] = sub( pParams->pLoop_delays[loop_idx], len ); // Q0 move16(); } + return error; } @@ -774,7 +787,6 @@ static ivas_error compute_t60_coeffs_fx( * Calculate 1st order low shelf filter *-----------------------------------------------------------------------------------------*/ - static void calc_low_shelf_first_order_filter_fx( Word16 *pNum, /* Q14 */ Word16 *pDen, /* Q14 */ @@ -897,6 +909,7 @@ static void calc_low_shelf_first_order_filter_fx( move16(); pDen[0] = shl( 1, 14 ); // Q14 move16(); + return; } @@ -907,7 +920,6 @@ static void calc_low_shelf_first_order_filter_fx( * Calculate Jot reverb's T60 filters *-----------------------------------------------------------------------------------------*/ - static ivas_error calc_jot_t60_coeffs_fx( Word16 *pH_dB_fx, Word16 pH_dB_exp, @@ -1033,23 +1045,25 @@ static ivas_error calc_jot_t60_coeffs_fx( move16(); } #endif + /* call low-pass iir shelf */ calc_low_shelf_first_order_filter_fx( pCoeffB_fx, pCoeffA_fx, f0_fx, lin_gain_lf_fx, lin_gain_hf_fx ); + return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function initialize_reverb_filters() * * Set the number of branches (feedback loops) and Initializes the memory structure (pointers to data) *-----------------------------------------------------------------------------------------*/ + static ivas_error initialize_reverb_filters_fx( REVERB_HANDLE hReverb ) { ivas_error error; - error = IVAS_ERR_OK; - /* init correlation and coloration filters */ IF( NE_32( ( error = ivas_reverb_t2f_f2t_init( &hReverb->fft_filter_ols, hReverb->fft_size, hReverb->fft_subblock_size ) ), IVAS_ERR_OK ) ) { @@ -1076,9 +1090,10 @@ static ivas_error initialize_reverb_filters_fx( return error; } - return error; + return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function set_t60_filter() * @@ -1107,6 +1122,7 @@ static ivas_error set_t60_filter( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function set_feedback_delay() * @@ -1128,6 +1144,8 @@ static ivas_error set_feedback_delay_fx( return IVAS_ERR_OK; } + + /*-----------------------------------------------------------------------------------------* * Function set_feedback_gain() * @@ -1153,6 +1171,8 @@ static ivas_error set_feedback_gain_fx( return IVAS_ERR_OK; } + + /*-----------------------------------------------------------------------------------------* * Function set_correl_fft_filter() * @@ -1236,6 +1256,8 @@ static ivas_error set_mixer_level_fx( return IVAS_ERR_OK; } + + /*-----------------------------------------------------------------------------------------* * Function clear_buffers_fx() * @@ -1265,6 +1287,7 @@ static void clear_buffers_fx( return; } + /*-----------------------------------------------------------------------------------------* * Function set_fft_and_datablock_sizes_fx() * @@ -1308,6 +1331,7 @@ static void set_fft_and_datablock_sizes_fx( return; } + /*-----------------------------------------------------------------------------------------* * Function set_reverb_acoustic_data_fx() * @@ -1338,8 +1362,7 @@ static void set_reverb_acoustic_data_fx( ivas_reverb_interp_on_freq_grid_fx( nr_fc_input, pFc_input_fx, pAcoustic_rt60_fx, nr_fc_fft_filter, pFc_fx, pRt60_fx ); // Q26 ivas_reverb_interp_on_freq_grid_fx( nr_fc_input, pFc_input_fx, pAcoustic_dsr_fx, nr_fc_fft_filter, pFc_fx, pDsr_fx ); // Q30 - ///* adjust DSR for the delay difference */ - + /* adjust DSR for the delay difference */ delay_diff_fx = L_sub( pRoomAcoustics->inputPreDelay_fx, pRoomAcoustics->acousticPreDelay_fx ); // Q27 ln_1e6_inverted_fx = 155440049; // Q31 /* 1.0f / logf( 1e06f ) */ @@ -1371,6 +1394,7 @@ static void set_reverb_acoustic_data_fx( pDsr_fx[bin_idx] = L_tmp; move32(); } + return; } @@ -1432,16 +1456,19 @@ static ivas_error setup_FDN_branches_fx( return error; } + /*------------------------------------------------------------------------- * ivas_reverb_open_fx() * * Allocate and initialize FDN reverberation handle *------------------------------------------------------------------------*/ + ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ - const Word32 output_Fs ) + const Word32 output_Fs /* i : output sampling rate */ +) { ivas_error error; REVERB_HANDLE pState = *hReverb; @@ -1458,7 +1485,6 @@ ivas_error ivas_reverb_open_fx( rv_fftwf_type_complex_fx pFft_wf_filter_ch0_fx[RV_LENGTH_NR_FC]; rv_fftwf_type_complex_fx pFft_wf_filter_ch1_fx[RV_LENGTH_NR_FC]; - error = IVAS_ERR_OK; output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); subframe_len = shr( output_frame, 2 ); /*output_frame / MAX_PARAM_SPATIAL_SUBFRAMES*/ predelay_bf_len = output_frame; @@ -1472,10 +1498,12 @@ ivas_error ivas_reverb_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" ); } } + IF( NE_32( ( error = set_base_config_fx( ¶ms, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } + IF( *hReverb == NULL ) { /* Allocate memory for feedback delay lines */ @@ -1493,6 +1521,7 @@ ivas_error ivas_reverb_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } } + pState->nr_of_branches = IVAS_REV_MAX_NR_BRANCHES; move16(); set_fft_and_datablock_sizes_fx( pState, subframe_len ); @@ -1527,7 +1556,6 @@ ivas_error ivas_reverb_open_fx( params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; params.pHrtf_inter_aural_coherence_const_fx = hHrtfStatistics->inter_aural_coherence; - /* set reverb acoustic configuration based on renderer config */ pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; move16(); @@ -1549,11 +1577,11 @@ ivas_error ivas_reverb_open_fx( calc_predelay_fx( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay_fx, output_Fs ); /* set up jot reverb 60 filters - must be set up after set_reverb_acoustic_data() */ - IF( NE_32( ( error = compute_t60_coeffs_fx( ¶ms, nr_fc_fft_filter, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } + /* Compute target levels (gains) for the coloration filters */ Word32 *pHrtf_avg_pwr_response_l_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) ); Word32 *pHrtf_avg_pwr_response_r_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) ); @@ -1592,7 +1620,7 @@ ivas_error ivas_reverb_open_fx( /* === Copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ - if ( *hReverb == NULL ) + IF( *hReverb == NULL ) { pState->do_corr_filter = params.do_corr_filter; move16(); @@ -1608,7 +1636,6 @@ ivas_error ivas_reverb_open_fx( move16(); move16(); - IF( pState->do_corr_filter ) { /* Computing correlation filters on the basis of target IA coherence */ @@ -1619,11 +1646,17 @@ ivas_error ivas_reverb_open_fx( } Word32 *pHrtf_inter_aural_coherence_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 ) ); + IF( pHrtf_inter_aural_coherence_const == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); + } + FOR( i = 0; i < nr_fc_fft_filter; i++ ) { pHrtf_inter_aural_coherence_const[i] = L_shl( params.pHrtf_inter_aural_coherence_const_fx[i], 4 ); /*Scaling up to Q30*/ move32(); } + ivas_reverb_calc_correl_filters_fx( pHrtf_inter_aural_coherence_const, pTime_window_fx, pState->fft_size, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx ); free( pHrtf_inter_aural_coherence_const ); @@ -1642,6 +1675,7 @@ ivas_error ivas_reverb_open_fx( pFft_wf_filter_ch1_fx[i][1] = L_shl( pFft_wf_filter_ch1_fx[i][1], sub( 31, q_pFft_wf_filter_ch1_fx ) ); // Scale to Q31 move32(); } + /* Copying the computed FFT correlation filters to the fft_filter components */ IF( NE_32( ( error = set_correl_fft_filter_fx( pState, 0, pFft_wf_filter_ch0_fx ) ), IVAS_ERR_OK ) ) { @@ -1683,38 +1717,42 @@ ivas_error ivas_reverb_open_fx( return error; } - if ( *hReverb == NULL ) + IF( *hReverb == NULL ) { /* init predelay */ ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer_fx, params.pre_delay, predelay_bf_len ); /* set up feedback delay network */ - if ( ( error = setup_FDN_branches_fx( pState, ¶ms ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = setup_FDN_branches_fx( pState, ¶ms ) ), IVAS_ERR_OK ) ) { return error; } } - else + ELSE { pState->predelay_line.Delay = params.pre_delay; + move16(); } nr_coefs = params.t60_filter_order + 1; - for ( branch_idx = 0; branch_idx < params.nr_loops; branch_idx++ ) + FOR( branch_idx = 0; branch_idx < params.nr_loops; branch_idx++ ) { pCoef_a = ¶ms.pT60_filter_coeff_fx[2 * nr_coefs * branch_idx + nr_coefs]; pCoef_b = ¶ms.pT60_filter_coeff_fx[2 * nr_coefs * branch_idx]; - if ( ( error = set_t60_filter( pState, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = set_t60_filter( pState, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ), IVAS_ERR_OK ) ) { return error; } } + *hReverb = pState; - return error; + return IVAS_ERR_OK; } + + /*------------------------------------------------------------------------- * ivas_reverb_close() * @@ -1753,6 +1791,8 @@ void ivas_reverb_close( return; } + + /*-----------------------------------------------------------------------------------------* * Function post_fft_filter() * @@ -1778,12 +1818,15 @@ static void post_fft_filter_fx( { ivas_reverb_t2f_f2t_in_fx( &hReverb->fft_filter_ols, input_L_fx, input_R_fx, buffer_L_fx, buffer_R_fx ); } + ivas_reverb_fft_filter_ComplexMul_fx( &hReverb->fft_filter_color_0, buffer_L_fx ); ivas_reverb_fft_filter_ComplexMul_fx( &hReverb->fft_filter_color_1, buffer_R_fx ); ivas_reverb_t2f_f2t_out_fx( &hReverb->fft_filter_ols, buffer_L_fx, buffer_R_fx, input_L_fx, input_R_fx ); return; } + + /*-----------------------------------------------------------------------------------------* * Function reverb_block() * @@ -1925,6 +1968,8 @@ static void reverb_block_fx( return; } + + /*-----------------------------------------------------------------------------------------* * Function downmix_input_block() * @@ -1941,6 +1986,7 @@ static ivas_error downmix_input_block_fx( Word16 i, s, nchan_transport; Word32 dmx_gain_fx = hReverb->dmx_gain_fx; move32(); + SWITCH( input_audio_config ) { case IVAS_AUDIO_CONFIG_STEREO: @@ -1986,6 +2032,8 @@ static ivas_error downmix_input_block_fx( return IVAS_ERR_OK; } + + /*-----------------------------------------------------------------------------------------* * Function predelay_block() * @@ -1999,6 +2047,7 @@ static void predelay_block_fx( { UWord16 i, idx, n_samples, blk_size; UWord16 max_blk_size = (UWord16) hReverb->predelay_line.Delay; + IF( LT_32( max_blk_size, 2 ) ) { IF( max_blk_size == 0 ) /* zero-length delay line: just copy the data from input to output */ @@ -2044,6 +2093,8 @@ static void predelay_block_fx( return; } + + /*-----------------------------------------------------------------------------------------* * Function mix_output_block() * @@ -2069,6 +2120,8 @@ static void mix_output_block_fx( return; } + + /*-----------------------------------------------------------------------------------------* * ivas_reverb_process() * @@ -2076,12 +2129,12 @@ static void mix_output_block_fx( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_reverb_process_fx( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const Word16 mix_signals, /* i : add reverb to output signal */ - Word32 *pcm_in_fx[], /* i Q11 : the PCM audio to apply reverb on */ - Word32 *pcm_out_fx[], /* o Q11 : the PCM audio with reverb applied */ - const Word16 i_ts /* i : subframe index */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ + const Word16 mix_signals, /* i : add reverb to output signal */ + Word32 *pcm_in_fx[], /* i : the PCM audio to apply reverb on, Q11 */ + Word32 *pcm_out_fx[], /* o : the PCM audio with reverb applied, Q11 */ + const Word16 i_ts /* i : subframe index */ ) { Word32 tmp0_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp1_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp2_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -2102,22 +2155,16 @@ ivas_error ivas_reverb_process_fx( } ELSE { - MVR2R_WORD32( tmp1_fx, &pcm_out_fx[0][i_mult( i_ts, hReverb->full_block_size )], hReverb->full_block_size ); - MVR2R_WORD32( tmp2_fx, &pcm_out_fx[1][i_mult( i_ts, hReverb->full_block_size )], hReverb->full_block_size ); + Copy32( tmp1_fx, &pcm_out_fx[0][i_mult( i_ts, hReverb->full_block_size )], hReverb->full_block_size ); + Copy32( tmp2_fx, &pcm_out_fx[1][i_mult( i_ts, hReverb->full_block_size )], hReverb->full_block_size ); } return IVAS_ERR_OK; } -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_processSubFrame() - * - * Compute the reverberation - room effect - *------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------- - * ivas_binaural_reverb_processSubFrame_fx() + * ivas_binaural_reverb_processSubFrame() * * Compute the reverberation - room effect *------------------------------------------------------------------------*/ @@ -2296,11 +2343,13 @@ void ivas_binaural_reverb_processSubframe_fx( return; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_open() * * Allocate and initialize binaural room reverberator handle *------------------------------------------------------------------------*/ + static ivas_error ivas_binaural_reverb_open_fx( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const Word16 numBins, /* i : Q0 number of CLDFB bins */ @@ -2412,19 +2461,16 @@ static ivas_error ivas_binaural_reverb_open_fx( ivas_binaural_reverb_setReverbTimes_fx( hReverb, sampling_rate, revTimes_fx, revEnes_fx ); - /*free(revTimes_fx); - free(revEnes_fx);*/ - ivas_binaural_reverb_setPreDelay_fx( hReverb, preDelay ); 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( @@ -2445,16 +2491,14 @@ ivas_error ivas_binaural_reverb_init( Word32 revEne[CLDFB_NO_CHANNELS_MAX]; Word32 temp32; - error = IVAS_ERR_OK; - IF( roomAcoustics != NULL ) { - IF( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ) ) != IVAS_ERR_OK ) { return error; } + /* Convert preDelay from seconds to CLDFB slots as needed by binaural reverb */ temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( ( 48000 / CLDFB_NO_CHANNELS_MAX ) >> 1 ) ); // Q11 preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 } -- GitLab From db58bd418cc56d5b17a0a632017e6fc611b3378a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 3 Sep 2025 10:41:43 +0200 Subject: [PATCH 3/3] use CLDFB_SLOTS_PER_SECOND macro --- lib_rend/ivas_reverb_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 996de0cf6..b836af9e4 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2499,8 +2499,8 @@ ivas_error ivas_binaural_reverb_init( } /* Convert preDelay from seconds to CLDFB slots as needed by binaural reverb */ - temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( ( 48000 / CLDFB_NO_CHANNELS_MAX ) >> 1 ) ); // Q11 - preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 + temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, ( CLDFB_SLOTS_PER_SECOND >> 1 ) ); // Q11 + preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 } ELSE { -- GitLab