Loading lib_rend/ivas_crend.c +0 −12 Original line number Diff line number Diff line Loading @@ -1392,22 +1392,10 @@ ivas_error ivas_rend_openCrend( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { #ifdef FIX_1053_REVERB_RECONFIGURATION if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), output_Fs ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = ivas_reverb_init( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { return error; } #else if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { return error; } #endif if ( hRendCfg->roomAcoustics.use_er == 1 ) { Loading lib_rend/ivas_prot_rend.h +0 −11 Original line number Diff line number Diff line Loading @@ -980,21 +980,10 @@ void ivas_binaural_reverb_processSubframe( ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ #ifndef FIX_1053_REVERB_RECONFIGURATION const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ #endif const int32_t output_Fs /* i : output sampling rate */ ); #ifdef FIX_1053_REVERB_RECONFIGURATION ivas_error ivas_reverb_init( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ const int32_t output_Fs /* i : output sampling rate */ ); #endif void ivas_reverb_close( REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ Loading lib_rend/ivas_reverb.c +73 −241 Original line number Diff line number Diff line Loading @@ -988,62 +988,11 @@ 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; #ifdef FIX_1053_REVERB_RECONFIGURATION nr_coefs = pParams->t60_filter_order + 1; if ( IVAS_REV_MAX_IIR_FILTER_LENGTH < nr_coefs ) { return IVAS_ERR_INTERNAL; } if ( !hReverb->initialized ) { /* initialize feedback branches */ for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { ivas_rev_delay_line_init( &( hReverb->delay_line[branch_idx] ), hReverb->loop_delay_buffer[branch_idx], init_loop_delay[branch_idx], pParams->pLoop_delays[branch_idx] ); ivas_reverb_iir_filt_init( &( hReverb->t60[branch_idx] ), IVAS_REV_MAX_IIR_FILTER_LENGTH ); hReverb->mixer[0][branch_idx] = 0.0f; hReverb->mixer[1][branch_idx] = 0.0f; } clear_buffers( hReverb ); for ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) { if ( ( error = set_feedback_delay( hReverb, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = set_feedback_gain( hReverb, branch_idx, &( pParams->pLoop_feedback_matrix[branch_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } } for ( channel_idx = 0; channel_idx < pParams->nr_outputs; channel_idx++ ) { if ( ( error = set_mixer_level( hReverb, channel_idx, &( pParams->pLoop_extract_matrix[channel_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } } } for ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) { pCoef_a = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx + nr_coefs]; pCoef_b = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx]; if ( ( error = set_t60_filter( hReverb, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) { return error; } } #else /* initialize feedback branches */ for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { Loading @@ -1063,6 +1012,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]; Loading @@ -1070,6 +1020,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 ) { Loading @@ -1090,17 +1041,15 @@ static ivas_error setup_FDN_branches( return error; } } #endif return error; } #ifdef FIX_1053_REVERB_RECONFIGURATION /*------------------------------------------------------------------------- * ivas_reverb_open() * * Allocate Crend reverberation handle * Allocate and initialize FDN reverberation handle *------------------------------------------------------------------------*/ #else /*------------------------------------------------------------------------- Loading @@ -1112,22 +1061,21 @@ static ivas_error setup_FDN_branches( ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ #ifndef FIX_1053_REVERB_RECONFIGURATION const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ #endif const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; REVERB_HANDLE pState = NULL; #ifdef FIX_1053_REVERB_RECONFIGURATION int16_t subframe_len, output_frame, loop_idx; REVERB_HANDLE pState = *hReverb; int16_t nr_coefs, branch_idx; float *pCoef_a, *pCoef_b; #else int16_t bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; REVERB_HANDLE pState = NULL; #endif int16_t bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; ivas_reverb_params_t params; #ifndef FIX_1053_REVERB_RECONFIGURATION rv_fftwf_type_complex pFft_wf_filter_ch0[RV_LENGTH_NR_FC]; rv_fftwf_type_complex pFft_wf_filter_ch1[RV_LENGTH_NR_FC]; float pColor_target_l[RV_LENGTH_NR_FC]; Loading @@ -1136,213 +1084,75 @@ ivas_error ivas_reverb_open( float freq_step; int16_t fft_hist_size, transition_start, transition_length; int16_t nr_fc_input, nr_fc_fft_filter; #endif error = IVAS_ERR_OK; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; #ifndef FIX_1053_REVERB_RECONFIGURATION predelay_bf_len = output_frame; nr_fc_input = hRenderConfig->roomAcoustics.nBands; #endif #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, "Can not allocate memory for CREND Reverberator" ); 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, "Can not allocate memory for CREND Reverberator" ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" ); } pState->nr_of_branches = IVAS_REV_MAX_NR_BRANCHES; set_fft_and_datablock_sizes( pState, subframe_len ); #ifdef FIX_1053_REVERB_RECONFIGURATION pState->initialized = false; #else 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. */ 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; 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]; params.pHrtf_inter_aural_coherence = &pState->fft_filter_color_1.fft_spectrum[0]; /* 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(...) */ /* set the uniform frequency grid for FFT filtering */ freq_step = 0.5f * output_Fs / ( nr_fc_fft_filter - 1 ); for ( bin_idx = 0; bin_idx < nr_fc_fft_filter; bin_idx++ ) { params.pFc[bin_idx] = freq_step * bin_idx; } set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l; params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r; params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence; /* set reverb acoustic configuration based on renderer config */ #ifdef DEBUGGING pState->pConfig.renderer_type_override = hRenderConfig->renderer_type_override; #endif pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; if ( hRenderConfig->roomAcoustics.use_er == 1 ) { pState->pConfig.roomAcoustics.use_er = hRenderConfig->roomAcoustics.use_er; pState->pConfig.roomAcoustics.lowComplexity = hRenderConfig->roomAcoustics.lowComplexity; } /* set up input downmix */ pState->dmx_gain = calc_dmx_gain(); /* set up predelay - must be after set_base_config() and before compute_t60_coeffs() */ calc_predelay( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay, output_Fs ); /* set up jot reverb 60 filters - must be set up after set_reverb_acoustic_data() */ if ( ( error = compute_t60_coeffs( ¶ms, nr_fc_fft_filter, output_Fs ) ) != IVAS_ERR_OK ) { return error; } /* Compute target levels (gains) for the coloration filters */ ivas_reverb_calc_color_levels( output_Fs, nr_fc_fft_filter, params.nr_loops, params.pFc, params.pDsr, params.pHrtf_avg_pwr_response_l_const, params.pHrtf_avg_pwr_response_r_const, params.pLoop_delays, params.pT60_filter_coeff, pColor_target_l, pColor_target_r ); /* Defining appropriate windowing parameters for FFT filters to prevent aliasing */ fft_hist_size = pState->fft_size - pState->fft_subblock_size; transition_start = (int16_t) roundf( FFT_FILTER_WND_FLAT_REGION * fft_hist_size ); transition_length = (int16_t) roundf( FFT_FILTER_WND_TRANS_REGION * fft_hist_size ); /* Compute the window used for FFT filters */ ivas_reverb_define_window_fft( pTime_window, transition_start, transition_length, nr_fc_fft_filter ); /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ 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; } if ( pState->do_corr_filter ) { /* Computing correlation filters on the basis of target IA coherence */ ivas_reverb_calc_correl_filters( params.pHrtf_inter_aural_coherence_const, pTime_window, pState->fft_size, 0.0f, pFft_wf_filter_ch0, pFft_wf_filter_ch1 ); /* Copying the computed FFT correlation filters to the fft_filter components */ if ( ( error = set_correl_fft_filter( pState, 0, pFft_wf_filter_ch0 ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = set_correl_fft_filter( pState, 1, pFft_wf_filter_ch1 ) ) != IVAS_ERR_OK ) #else /* Allocate memory for feedback delay lines */ for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) { return error; } } /* Computing coloration filters on the basis of target responses */ ivas_reverb_calc_color_filters( pColor_target_l, pColor_target_r, pTime_window, pState->fft_size, 0.0f, pFft_wf_filter_ch0, pFft_wf_filter_ch1 ); /* Copying the computed FFT colorations filters to the fft_filter components */ if ( ( error = set_color_fft_filter( pState, 0, pFft_wf_filter_ch0 ) ) != IVAS_ERR_OK ) if ( ( pState->loop_delay_buffer[loop_idx] = (float *) malloc( params.pLoop_delays[loop_idx] * sizeof( float ) ) ) == NULL ) { return error; return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } if ( ( error = set_color_fft_filter( pState, 1, pFft_wf_filter_ch1 ) ) != IVAS_ERR_OK ) { return error; } /* 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 ) /* Allocate memory for the pre-delay delay line */ if ( ( pState->pPredelay_buffer = (float *) malloc( output_frame * sizeof( float ) ) ) == NULL ) { return error; return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } #endif *hReverb = pState; return error; } #ifdef FIX_1053_REVERB_RECONFIGURATION /*------------------------------------------------------------------------- * ivas_reverb_init() * * initialize Crend reverberation handle *------------------------------------------------------------------------*/ ivas_error ivas_reverb_init( 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 int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; REVERB_HANDLE pState = NULL; int16_t output_frame, predelay_bf_len, nr_fc_fft_filter, bin_idx, nr_fc_input; float freq_step; int16_t fft_hist_size, transition_start, transition_length; ivas_reverb_params_t params; rv_fftwf_type_complex pFft_wf_filter_ch0[RV_LENGTH_NR_FC]; rv_fftwf_type_complex pFft_wf_filter_ch1[RV_LENGTH_NR_FC]; float pColor_target_l[RV_LENGTH_NR_FC]; float pColor_target_r[RV_LENGTH_NR_FC]; float pTime_window[RV_FILTER_MAX_FFT_SIZE]; error = IVAS_ERR_OK; pState = *hReverb; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); predelay_bf_len = output_frame; nr_fc_input = hRenderConfig->roomAcoustics.nBands; 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; /* TODO: ugly; base config is now set in both open() and init() calls */ if ( ( error = set_base_config( ¶ms, output_Fs ) ) != IVAS_ERR_OK ) { return error; } /* === '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. */ Loading Loading @@ -1387,11 +1197,12 @@ ivas_error ivas_reverb_init( /* set up input downmix */ #ifdef FIX_1053_REVERB_RECONFIGURATION if ( !pState->initialized ) 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() */ Loading @@ -1417,7 +1228,9 @@ ivas_error ivas_reverb_init( ivas_reverb_define_window_fft( pTime_window, transition_start, transition_length, nr_fc_fft_filter ); #ifdef FIX_1053_REVERB_RECONFIGURATION if ( !pState->initialized ) /* === 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; Loading @@ -1428,7 +1241,6 @@ ivas_error ivas_reverb_init( } } #else /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ Loading Loading @@ -1472,31 +1284,51 @@ ivas_error ivas_reverb_init( return error; } /* init predelay */ #ifdef FIX_1053_REVERB_RECONFIGURATION if ( !pState->initialized ) 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 ); #endif /* set up feedback delay network */ if ( ( error = setup_FDN_branches( pState, ¶ms ) ) != IVAS_ERR_OK ) { return error; } #endif pState->initialized = true; *hReverb = pState; return error; } #endif /*------------------------------------------------------------------------- * ivas_reverb_close() Loading lib_rend/ivas_stat_rend.h +0 −4 Original line number Diff line number Diff line Loading @@ -839,10 +839,6 @@ typedef struct ivas_reverb_state_t uint16_t fft_subblock_size; /* fft block processing size */ uint16_t num_fft_subblocks; /* number of fft subblocks */ uint16_t full_block_size; /* full block processing size */ #ifdef FIX_1053_REVERB_RECONFIGURATION uint16_t initialized; /* Flag indicating whether the reverb structure was initialized before */ #endif } REVERB_DATA, *REVERB_HANDLE; Loading lib_rend/lib_rend.c +8 −44 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib_rend/ivas_crend.c +0 −12 Original line number Diff line number Diff line Loading @@ -1392,22 +1392,10 @@ ivas_error ivas_rend_openCrend( if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { #ifdef FIX_1053_REVERB_RECONFIGURATION if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), output_Fs ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = ivas_reverb_init( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { return error; } #else if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { return error; } #endif if ( hRendCfg->roomAcoustics.use_er == 1 ) { Loading
lib_rend/ivas_prot_rend.h +0 −11 Original line number Diff line number Diff line Loading @@ -980,21 +980,10 @@ void ivas_binaural_reverb_processSubframe( ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ #ifndef FIX_1053_REVERB_RECONFIGURATION const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ #endif const int32_t output_Fs /* i : output sampling rate */ ); #ifdef FIX_1053_REVERB_RECONFIGURATION ivas_error ivas_reverb_init( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_DATA *pConfig, /* i : Reverb configuration */ const int32_t output_Fs /* i : output sampling rate */ ); #endif void ivas_reverb_close( REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ Loading
lib_rend/ivas_reverb.c +73 −241 Original line number Diff line number Diff line Loading @@ -988,62 +988,11 @@ 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; #ifdef FIX_1053_REVERB_RECONFIGURATION nr_coefs = pParams->t60_filter_order + 1; if ( IVAS_REV_MAX_IIR_FILTER_LENGTH < nr_coefs ) { return IVAS_ERR_INTERNAL; } if ( !hReverb->initialized ) { /* initialize feedback branches */ for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { ivas_rev_delay_line_init( &( hReverb->delay_line[branch_idx] ), hReverb->loop_delay_buffer[branch_idx], init_loop_delay[branch_idx], pParams->pLoop_delays[branch_idx] ); ivas_reverb_iir_filt_init( &( hReverb->t60[branch_idx] ), IVAS_REV_MAX_IIR_FILTER_LENGTH ); hReverb->mixer[0][branch_idx] = 0.0f; hReverb->mixer[1][branch_idx] = 0.0f; } clear_buffers( hReverb ); for ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) { if ( ( error = set_feedback_delay( hReverb, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = set_feedback_gain( hReverb, branch_idx, &( pParams->pLoop_feedback_matrix[branch_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } } for ( channel_idx = 0; channel_idx < pParams->nr_outputs; channel_idx++ ) { if ( ( error = set_mixer_level( hReverb, channel_idx, &( pParams->pLoop_extract_matrix[channel_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } } } for ( branch_idx = 0; branch_idx < pParams->nr_loops; branch_idx++ ) { pCoef_a = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx + nr_coefs]; pCoef_b = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx]; if ( ( error = set_t60_filter( hReverb, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) { return error; } } #else /* initialize feedback branches */ for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { Loading @@ -1063,6 +1012,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]; Loading @@ -1070,6 +1020,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 ) { Loading @@ -1090,17 +1041,15 @@ static ivas_error setup_FDN_branches( return error; } } #endif return error; } #ifdef FIX_1053_REVERB_RECONFIGURATION /*------------------------------------------------------------------------- * ivas_reverb_open() * * Allocate Crend reverberation handle * Allocate and initialize FDN reverberation handle *------------------------------------------------------------------------*/ #else /*------------------------------------------------------------------------- Loading @@ -1112,22 +1061,21 @@ static ivas_error setup_FDN_branches( ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ #ifndef FIX_1053_REVERB_RECONFIGURATION const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ #endif const int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; REVERB_HANDLE pState = NULL; #ifdef FIX_1053_REVERB_RECONFIGURATION int16_t subframe_len, output_frame, loop_idx; REVERB_HANDLE pState = *hReverb; int16_t nr_coefs, branch_idx; float *pCoef_a, *pCoef_b; #else int16_t bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; REVERB_HANDLE pState = NULL; #endif int16_t bin_idx, subframe_len, output_frame, predelay_bf_len, loop_idx; ivas_reverb_params_t params; #ifndef FIX_1053_REVERB_RECONFIGURATION rv_fftwf_type_complex pFft_wf_filter_ch0[RV_LENGTH_NR_FC]; rv_fftwf_type_complex pFft_wf_filter_ch1[RV_LENGTH_NR_FC]; float pColor_target_l[RV_LENGTH_NR_FC]; Loading @@ -1136,213 +1084,75 @@ ivas_error ivas_reverb_open( float freq_step; int16_t fft_hist_size, transition_start, transition_length; int16_t nr_fc_input, nr_fc_fft_filter; #endif error = IVAS_ERR_OK; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; #ifndef FIX_1053_REVERB_RECONFIGURATION predelay_bf_len = output_frame; nr_fc_input = hRenderConfig->roomAcoustics.nBands; #endif #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, "Can not allocate memory for CREND Reverberator" ); 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, "Can not allocate memory for CREND Reverberator" ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for FDN Reverberator" ); } pState->nr_of_branches = IVAS_REV_MAX_NR_BRANCHES; set_fft_and_datablock_sizes( pState, subframe_len ); #ifdef FIX_1053_REVERB_RECONFIGURATION pState->initialized = false; #else 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. */ 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; 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]; params.pHrtf_inter_aural_coherence = &pState->fft_filter_color_1.fft_spectrum[0]; /* 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(...) */ /* set the uniform frequency grid for FFT filtering */ freq_step = 0.5f * output_Fs / ( nr_fc_fft_filter - 1 ); for ( bin_idx = 0; bin_idx < nr_fc_fft_filter; bin_idx++ ) { params.pFc[bin_idx] = freq_step * bin_idx; } set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l; params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r; params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence; /* set reverb acoustic configuration based on renderer config */ #ifdef DEBUGGING pState->pConfig.renderer_type_override = hRenderConfig->renderer_type_override; #endif pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; pState->pConfig.roomAcoustics.nBands = hRenderConfig->roomAcoustics.nBands; if ( hRenderConfig->roomAcoustics.use_er == 1 ) { pState->pConfig.roomAcoustics.use_er = hRenderConfig->roomAcoustics.use_er; pState->pConfig.roomAcoustics.lowComplexity = hRenderConfig->roomAcoustics.lowComplexity; } /* set up input downmix */ pState->dmx_gain = calc_dmx_gain(); /* set up predelay - must be after set_base_config() and before compute_t60_coeffs() */ calc_predelay( ¶ms, hRenderConfig->roomAcoustics.acousticPreDelay, output_Fs ); /* set up jot reverb 60 filters - must be set up after set_reverb_acoustic_data() */ if ( ( error = compute_t60_coeffs( ¶ms, nr_fc_fft_filter, output_Fs ) ) != IVAS_ERR_OK ) { return error; } /* Compute target levels (gains) for the coloration filters */ ivas_reverb_calc_color_levels( output_Fs, nr_fc_fft_filter, params.nr_loops, params.pFc, params.pDsr, params.pHrtf_avg_pwr_response_l_const, params.pHrtf_avg_pwr_response_r_const, params.pLoop_delays, params.pT60_filter_coeff, pColor_target_l, pColor_target_r ); /* Defining appropriate windowing parameters for FFT filters to prevent aliasing */ fft_hist_size = pState->fft_size - pState->fft_subblock_size; transition_start = (int16_t) roundf( FFT_FILTER_WND_FLAT_REGION * fft_hist_size ); transition_length = (int16_t) roundf( FFT_FILTER_WND_TRANS_REGION * fft_hist_size ); /* Compute the window used for FFT filters */ ivas_reverb_define_window_fft( pTime_window, transition_start, transition_length, nr_fc_fft_filter ); /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ 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; } if ( pState->do_corr_filter ) { /* Computing correlation filters on the basis of target IA coherence */ ivas_reverb_calc_correl_filters( params.pHrtf_inter_aural_coherence_const, pTime_window, pState->fft_size, 0.0f, pFft_wf_filter_ch0, pFft_wf_filter_ch1 ); /* Copying the computed FFT correlation filters to the fft_filter components */ if ( ( error = set_correl_fft_filter( pState, 0, pFft_wf_filter_ch0 ) ) != IVAS_ERR_OK ) { return error; } if ( ( error = set_correl_fft_filter( pState, 1, pFft_wf_filter_ch1 ) ) != IVAS_ERR_OK ) #else /* Allocate memory for feedback delay lines */ for ( loop_idx = 0; loop_idx < IVAS_REV_MAX_NR_BRANCHES; loop_idx++ ) { return error; } } /* Computing coloration filters on the basis of target responses */ ivas_reverb_calc_color_filters( pColor_target_l, pColor_target_r, pTime_window, pState->fft_size, 0.0f, pFft_wf_filter_ch0, pFft_wf_filter_ch1 ); /* Copying the computed FFT colorations filters to the fft_filter components */ if ( ( error = set_color_fft_filter( pState, 0, pFft_wf_filter_ch0 ) ) != IVAS_ERR_OK ) if ( ( pState->loop_delay_buffer[loop_idx] = (float *) malloc( params.pLoop_delays[loop_idx] * sizeof( float ) ) ) == NULL ) { return error; return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } if ( ( error = set_color_fft_filter( pState, 1, pFft_wf_filter_ch1 ) ) != IVAS_ERR_OK ) { return error; } /* 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 ) /* Allocate memory for the pre-delay delay line */ if ( ( pState->pPredelay_buffer = (float *) malloc( output_frame * sizeof( float ) ) ) == NULL ) { return error; return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CREND Reverberator" ); } #endif *hReverb = pState; return error; } #ifdef FIX_1053_REVERB_RECONFIGURATION /*------------------------------------------------------------------------- * ivas_reverb_init() * * initialize Crend reverberation handle *------------------------------------------------------------------------*/ ivas_error ivas_reverb_init( 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 int32_t output_Fs /* i : output sampling rate */ ) { ivas_error error; REVERB_HANDLE pState = NULL; int16_t output_frame, predelay_bf_len, nr_fc_fft_filter, bin_idx, nr_fc_input; float freq_step; int16_t fft_hist_size, transition_start, transition_length; ivas_reverb_params_t params; rv_fftwf_type_complex pFft_wf_filter_ch0[RV_LENGTH_NR_FC]; rv_fftwf_type_complex pFft_wf_filter_ch1[RV_LENGTH_NR_FC]; float pColor_target_l[RV_LENGTH_NR_FC]; float pColor_target_r[RV_LENGTH_NR_FC]; float pTime_window[RV_FILTER_MAX_FFT_SIZE]; error = IVAS_ERR_OK; pState = *hReverb; output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); predelay_bf_len = output_frame; nr_fc_input = hRenderConfig->roomAcoustics.nBands; 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; /* TODO: ugly; base config is now set in both open() and init() calls */ if ( ( error = set_base_config( ¶ms, output_Fs ) ) != IVAS_ERR_OK ) { return error; } /* === '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. */ Loading Loading @@ -1387,11 +1197,12 @@ ivas_error ivas_reverb_init( /* set up input downmix */ #ifdef FIX_1053_REVERB_RECONFIGURATION if ( !pState->initialized ) 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() */ Loading @@ -1417,7 +1228,9 @@ ivas_error ivas_reverb_init( ivas_reverb_define_window_fft( pTime_window, transition_start, transition_length, nr_fc_fft_filter ); #ifdef FIX_1053_REVERB_RECONFIGURATION if ( !pState->initialized ) /* === 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; Loading @@ -1428,7 +1241,6 @@ ivas_error ivas_reverb_init( } } #else /* === Now, copy parameters from ivas_reverb_params_t into DSP blocks === */ /* === to be used for subsequent audio signal processing === */ Loading Loading @@ -1472,31 +1284,51 @@ ivas_error ivas_reverb_init( return error; } /* init predelay */ #ifdef FIX_1053_REVERB_RECONFIGURATION if ( !pState->initialized ) 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 ); #endif /* set up feedback delay network */ if ( ( error = setup_FDN_branches( pState, ¶ms ) ) != IVAS_ERR_OK ) { return error; } #endif pState->initialized = true; *hReverb = pState; return error; } #endif /*------------------------------------------------------------------------- * ivas_reverb_close() Loading
lib_rend/ivas_stat_rend.h +0 −4 Original line number Diff line number Diff line Loading @@ -839,10 +839,6 @@ typedef struct ivas_reverb_state_t uint16_t fft_subblock_size; /* fft block processing size */ uint16_t num_fft_subblocks; /* number of fft subblocks */ uint16_t full_block_size; /* full block processing size */ #ifdef FIX_1053_REVERB_RECONFIGURATION uint16_t initialized; /* Flag indicating whether the reverb structure was initialized before */ #endif } REVERB_DATA, *REVERB_HANDLE; Loading