From 449edfe8bb3b5ffb1ae4f3f5139c79498b683812 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 14 May 2024 11:32:31 +0530 Subject: [PATCH] ivas_dirac_dec_render_sf_fx cleanup --- lib_dec/ivas_dirac_dec.c | 2168 +++++++------------- lib_rend/ivas_dirac_output_synthesis_dec.c | 2 + lib_rend/ivas_dirac_rend.c | 2 +- 3 files changed, 741 insertions(+), 1431 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 9a5e1e5a5..b7ae00511 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3587,10 +3587,10 @@ void ivas_dirac_dec_render_sf_fx( int16_t slot_idx_start, slot_idx_start_cldfb_synth, md_idx; /*CLDFB: last output channels reserved to LFT for CICPx*/ - float Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Binaural[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; + Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; int16_t index = 0, num_freq_bands = 0; /* local copies of azi, ele, diffuseness */ @@ -3605,32 +3605,19 @@ void ivas_dirac_dec_render_sf_fx( Word32 surCohEner_fx; Word32 surCohRatio_fx[CLDFB_NO_CHANNELS_MAX]; Word16 surCohRatio_q_fx = 0, temp_q = 0; - Word16 diffuse_power_factor_q = 0, direct_power_factor_q = 0; Word32 Cldfb_RealBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Temp_fx[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word16 cldfb_buf_q; Word16 offset; Word32 pppQMfFrame_ts_re_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 pppQMfFrame_ts_im_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - set_zero_fx(surCohRatio_fx, CLDFB_NO_CHANNELS_MAX); + set_zero_fx( surCohRatio_fx, CLDFB_NO_CHANNELS_MAX ); Word16 q_cldfb, q_temp_cldfb = 0; Word16 proto_length = 0; - //Word32 proto_frame_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; - - Word32 proto_direct_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; - Word32 proto_power_smooth_fx[2 * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; - Word32 reference_power_fix[5 * CLDFB_NO_CHANNELS_MAX]; - Word32 onset_filter_subframe_fix[2 * CLDFB_NO_CHANNELS_MAX]; Word32 proto_diffuse_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX]; - //set_zero_fx( &proto_frame_f_fx[0], 2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ); - set_zero_fx( &proto_direct_buffer_f_fx[0], 2 * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS ); - set_zero_fx( &proto_power_smooth_fx[0], 2 * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS ); - set_zero_fx( &reference_power_fix[0], 5 * CLDFB_NO_CHANNELS_MAX ); set_zero_fx( &proto_diffuse_buffer_f_fx[0], 2 * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS ); + Word16 q_proto_direct_buffer[CLDFB_SLOTS_PER_SUBFRAME]; + Word16 q_proto_diffuse_buffer[CLDFB_SLOTS_PER_SUBFRAME]; #endif DIRAC_DEC_STACK_MEM DirAC_mem; @@ -3641,6 +3628,12 @@ void ivas_dirac_dec_render_sf_fx( #endif uint16_t coherence_flag; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; + Word16 q_onset_filter = 0; + Word16 scale = 0; + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; + DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; + Word16 num_channels_dir, exp; + Word16 q_diffuseness_vector = Q31, q_reference_power_smooth = Q31; push_wmops( "ivas_dirac_dec_render" ); @@ -3655,20 +3648,20 @@ void ivas_dirac_dec_render_sf_fx( reference_power_smooth = ( DirAC_mem.reference_power == NULL ) ? NULL : DirAC_mem.reference_power + hSpatParamRendCom->num_freq_bands; onset_filter = DirAC_mem.onset_filter; onset_filter_subframe = ( DirAC_mem.onset_filter == NULL ) ? NULL : DirAC_mem.onset_filter + hSpatParamRendCom->num_freq_bands; -#ifdef IVAS_FLOAT_FIXED reference_power_fx = DirAC_mem.reference_power_fx; reference_power_smooth_fx = ( DirAC_mem.reference_power_fx == NULL ) ? NULL : DirAC_mem.reference_power_fx + hSpatParamRendCom->num_freq_bands; onset_filter_fx = DirAC_mem.onset_filter_fx; onset_filter_subframe_fx = ( DirAC_mem.onset_filter_fx == NULL ) ? NULL : DirAC_mem.onset_filter_fx + hSpatParamRendCom->num_freq_bands; q_cldfb = Q11; move16(); + set_s( q_proto_direct_buffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); + set_s( q_proto_diffuse_buffer, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, CLDFB_SLOTS_PER_SUBFRAME ); + //////////////////////////////////////////////////////////////////////////// to be removed /////////////////////////////////////////////////////////////////// - reference_power_smooth_fx = &reference_power_fix[hSpatParamRendCom->num_freq_bands]; - onset_filter_subframe_fx = &onset_filter_subframe_fix[hSpatParamRendCom->num_freq_bands]; IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) { mvr2r( hSpatParamRendCom->diffuseness_vector[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], diffuseness_vector, hSpatParamRendCom->num_freq_bands ); - //Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); + // Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); floatToFixed_arrL32( diffuseness_vector, hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]], Q30, hSpatParamRendCom->num_freq_bands ); md_idx = hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->subframes_rendered]; } @@ -3745,7 +3738,7 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); IF( hDirACRend->masa_stereo_type_detect ) { IF( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db == -INFINITY ) @@ -3768,16 +3761,16 @@ void ivas_dirac_dec_render_sf_fx( case 8: case 6: case 4: - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); BREAK; case 2: IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) { - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); } ELSE { - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); IF( hDirACRend->masa_stereo_type_detect ) { IF( hDirACRend->masa_stereo_type_detect->subtract_target_ratio_db == -INFINITY ) @@ -3792,13 +3785,13 @@ void ivas_dirac_dec_render_sf_fx( } BREAK; case 1: - floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); BREAK; } } IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { - //Word16 val = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + // Word16 val = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; FOR( i = 0; i < 32; i++ ) { Word16 exp1 = 0, exp2 = 0, exp3 = 0; @@ -3813,6 +3806,54 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->q_buffer_energy[i] = sub( 31, hDirACRend->q_buffer_energy[i] ); } } + + IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) + { + if ( hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0 ) + { + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state ); + f2me_buf( state->proto_power_diff_smooth, state->proto_power_diff_smooth_fx, &state->proto_power_diff_smooth_q, state->proto_power_diff_smooth_len ); + state->proto_power_diff_smooth_q = 31 - state->proto_power_diff_smooth_q; + } + } + + h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); + h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); + num_channels_dir = hDirACRend->num_outputs_dir; + hodirac_flag = ivas_get_hodirac_flag_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) + { + num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; + } + + if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) + { + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); + } + } + + if ( h_dirac_output_synthesis_params->use_onset_filters && ( hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + + floatToFixed_arrL( hDirACRend->stack_mem.onset_filter, hDirACRend->stack_mem.onset_filter_fx, Q30, ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ? hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands : 2 * hSpatParamRendCom->num_freq_bands ); + } + + if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// hodirac_flag = ivas_get_hodirac_flag_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); @@ -3868,657 +3909,68 @@ void ivas_dirac_dec_render_sf_fx( } IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) - { - p_Rmat_fx = &st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; - - IF( EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) - { - num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; - move16(); - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) - { - rotateAziEle_DirAC_fx( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat_fx ); - } - } - } - ELSE - { - p_Rmat_fx = 0; - } - - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) - { - /* compute response */ - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - ivas_dirac_dec_compute_power_factors_fx( hSpatParamRendCom->num_freq_bands, - diffuseness_vector_fx, - hDirACRend->h_output_synthesis_psd_params.max_band_decorr, - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx ); - - direct_power_factor_q = Q29; - move16(); - diffuse_power_factor_q = Q29; - move16(); - - IF( coherence_flag ) - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - dirEne_fx = hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i]; // Q29 - move32(); - surCohEner_fx = Mpy_32_16_1( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); // Q29 + Q15 - Q15 = Q29 - - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i] = L_sub( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], surCohEner_fx ); // Q29 - move32(); - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i] = L_add( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], surCohEner_fx ); // Q29 - move32(); - - surCohRatio_fx[i] = BASOP_Util_Divide3232_Scale( surCohEner_fx, ( L_add( EPSILLON_FX, L_add( dirEne_fx, surCohEner_fx ) ) ), &temp_q ); - move32(); - surCohRatio_fx[i] = L_shl( surCohRatio_fx[i], temp_q ); - move32(); - } - } - ELSE - { - set_zero_fx( surCohRatio_fx, hSpatParamRendCom->num_freq_bands ); - } - surCohRatio_q_fx = Q15; - move16(); - } - ELSE - { - Word16 max_exp_direct = 0, max_exp_diffusion = 0; - ivas_dirac_dec_compute_gain_factors_fx( hSpatParamRendCom->num_freq_bands, - hSpatParamRendCom->diffuseness_vector_fx[md_idx], - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, - &max_exp_direct, &max_exp_diffusion ); - - direct_power_factor_q = sub( Q31, max_exp_direct ); - diffuse_power_factor_q = sub( Q31, max_exp_diffusion ); - - IF( coherence_flag ) - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - surCohRatio_fx[i] = (Word32) hSpatParamRendCom->surroundingCoherence_fx[md_idx][i]; - move32(); - } - } - ELSE - { - set_zero_fx( surCohRatio_fx, hSpatParamRendCom->num_freq_bands ); - } - surCohRatio_q_fx = Q15; - move16(); - } - - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 1 ) ) - { - ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio_fx, - surCohRatio_q_fx, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat_fx, - hodirac_flag ); - } - ELSE - { - ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio_fx, - surCohRatio_q_fx, - 0, - NULL, - hodirac_flag ); - } - } - - IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) - { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - index_slot = add( slot_idx_start, slot_idx ); - offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); - /* CLDFB Analysis*/ - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - q_temp_cldfb = Q11; - move16(); - cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], - Cldfb_RealBuffer_Temp_fx[ch][slot_idx], - Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); - } - q_cldfb = q_temp_cldfb; - move16(); - } - - IF( L_and( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ), NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) - { - ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); - } - } - - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - index_slot = add( slot_idx_start, slot_idx ); - IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) - { - md_idx = hSpatParamRendCom->render_to_md_map[index_slot]; - move16(); - } - ELSE - { - md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; - move16(); - } - IF( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) - { - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - Copy32( pppQMfFrame_ts_re_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - Copy32( pppQMfFrame_ts_im_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - } - q_cldfb = Q6; - move16(); - } - ELSE IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) - { - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); - } - } - ELSE - { - /* CLDFB Analysis*/ - offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - q_temp_cldfb = Q11; - move16(); - cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], - Cldfb_RealBuffer_fx[ch][0], - Cldfb_ImagBuffer_fx[ch][0], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); - } - q_cldfb = q_temp_cldfb; - move16(); - } - - /* CNG in DirAC, extra CLDFB ana for CNA*/ - IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) ) - { - Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - Word16 Q_input = Q11; - move16(); - q_temp_cldfb = Q11; - generate_masking_noise_dirac_ivas_fx( st->hFdCngDec->hFdCngCom, - st_ivas->cldfbAnaDec[1], - st_ivas->hTcBuffer->tc_fx[1], - Cldfb_RealBuffer_fx[1][0], - Cldfb_ImagBuffer_fx[1][0], - index_slot, - st->cna_dirac_flag && st->flag_cna, - ( L_or( EQ_32( st->core_brate, FRAME_NO_DATA ), EQ_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->cng_type, FD_CNG ) && st->cng_sba_flag, Q_input, &q_temp_cldfb ); - Scale_sig32( Cldfb_RealBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); - Scale_sig32( Cldfb_ImagBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); - } - - /* LFE synthesis */ - IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled && !( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( hDirACRend->hOutSetup.num_lfe, 0 ) ) ) - { - ivas_lfe_synth_with_cldfb_fx( st_ivas->hMasa->hMasaLfeSynth, - Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1], - slot_idx, - md_idx, - nchan_transport, q_cldfb ); - } - - /*-----------------------------------------------------------------* - * protoype signal computation - *-----------------------------------------------------------------*/ - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) - { - protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - proto_diffuse_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - reference_power_fix, &DirAC_mem.reference_power_q, - slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - p_Rmat_fx, q_cldfb ); - } - ELSE - { - protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - proto_diffuse_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - reference_power_fix, &DirAC_mem.reference_power_q, - slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - 0, q_cldfb ); - } - } - ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) - { - protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, - &hDirACRend->proto_frame_f_q, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - reference_power_fix, - &DirAC_mem.reference_power_q, - proto_power_smooth_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect, - q_cldfb ); - } - ELSE - { - SWITCH( nchan_transport ) - { - case 11: - case 8: - case 6: - case 4: - protoSignalComputation4_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - hDirACRend->proto_frame_f_fx, - &hDirACRend->proto_frame_f_q, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - reference_power_fix, - &DirAC_mem.reference_power_q, - proto_power_smooth_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - slot_idx, hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - hDirACRend->hoa_decoder, - nchan_transport, - hDirACRend->sba_map_tc, q_cldfb ); - BREAK; - case 2: - protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, - &hDirACRend->proto_frame_f_q, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - reference_power_fix, - &DirAC_mem.reference_power_q, - proto_power_smooth_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - hDirACRend->hOutSetup.is_loudspeaker_setup, - slot_idx, - hSpatParamRendCom->num_freq_bands, - hDirACRend->masa_stereo_type_detect, - q_cldfb ); - BREAK; - case 1: - protoSignalComputation1_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - hDirACRend->proto_frame_f_fx, - &hDirACRend->proto_frame_f_q, - proto_direct_buffer_f_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, - reference_power_fix, - &DirAC_mem.reference_power_q, - proto_power_smooth_fx, - &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, - slot_idx, - hDirACRend->num_protos_diff, - hSpatParamRendCom->num_freq_bands, q_cldfb ); - BREAK; - default: - return; - } - } - - /*-----------------------------------------------------------------* - * Compute DirAC parameters at decoder side - *-----------------------------------------------------------------*/ - IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) - { - Copy( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); - Copy( &hSpatParamRendCom->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); - IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) - { - num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; - move16(); - rotateAziEle_DirAC_fx( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat_fx ); - } - - /*hDirACRend->index_buffer_intensity = ( hDirACRend->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1 */ - IF( EQ_16( hDirACRend->index_buffer_intensity, 0 ) ) - { - hDirACRend->index_buffer_intensity = 1; - } - ELSE - { - hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( idiv1616( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ - } - - index = hDirACRend->index_buffer_intensity; - move16(); - num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; - move16(); - - computeIntensityVector_dec_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, - q_cldfb, num_freq_bands, - hDirACRend->buffer_intensity_real_fx[0][sub( index, 1 )], - hDirACRend->buffer_intensity_real_fx[1][sub( index, 1 )], - hDirACRend->buffer_intensity_real_fx[2][sub( index, 1 )], - &hDirACRend->q_buffer_intensity_real[sub( index, 1 )] ); - - computeDirectionAngles_fx( hDirACRend->buffer_intensity_real_fx[0][sub( index, 1 )], - hDirACRend->buffer_intensity_real_fx[1][sub( index, 1 )], - hDirACRend->buffer_intensity_real_fx[2][sub( index, 1 )], - hDirACRend->q_buffer_intensity_real[sub( index, 1 )], - num_freq_bands, azimuth, elevation ); - - Copy32( reference_power_fix, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); - hDirACRend->q_buffer_energy[sub( index, 1 )] = DirAC_mem.reference_power_q; - move16(); - - computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); - } - ////////////////////////////////////////////// to be removed /////////////////////////////////////////////////////////////// - IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) && EQ_16( slot_idx, 0 ) ) - { - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); - } - ELSE - { - me2f_buf( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, 31 - diffuse_power_factor_q, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hSpatParamRendCom->num_freq_bands ); - me2f_buf( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, 31 - direct_power_factor_q, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hSpatParamRendCom->num_freq_bands ); - } - } - - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - - IF( hodirac_flag ) - { - fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - ELSE - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - - IF( !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) - { - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - fixedToFloat_arrL32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, st_ivas->cldfbAnaDec[ch]->cldfb_state, Q11, ( st_ivas->cldfbAnaDec[ch]->p_filter_length - st_ivas->cldfbAnaDec[ch]->no_channels ) ); - } - } - - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - fixedToFloat_arrL32( Cldfb_RealBuffer_fx[ch][0], Cldfb_RealBuffer[ch][0], Q6, hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[ch][0], Cldfb_ImagBuffer[ch][0], Q6, hSpatParamRendCom->num_freq_bands ); - } - - IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) ) - { - fixedToFloat_arrL32( st_ivas->cldfbAnaDec[1]->cldfb_state_fx, st_ivas->cldfbAnaDec[1]->cldfb_state, Q11, ( st_ivas->cldfbAnaDec[1]->p_filter_length - st_ivas->cldfbAnaDec[1]->no_channels ) ); - fixedToFloat_arrL32( Cldfb_RealBuffer_fx[1][0], Cldfb_RealBuffer[1][0], Q6, CLDFB_NO_CHANNELS_MAX ); - fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[1][0], Cldfb_ImagBuffer[1][0], Q6, CLDFB_NO_CHANNELS_MAX ); - } - - IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled && !( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( hDirACRend->hOutSetup.num_lfe, 0 ) ) ) - { - FOR( i = 0; i < nchan_transport; i++ ) - { - Cldfb_RealBuffer[i][0][0] = fixedToFloat_32( Cldfb_RealBuffer_fx[i][0][0], Q6 ); - Cldfb_ImagBuffer[i][0][0] = fixedToFloat_32( Cldfb_ImagBuffer_fx[i][0][0], Q6 ); - } - fixedToFloat_arrL32( Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][slot_idx], Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][slot_idx], Q6, CLDFB_NO_CHANNELS_MAX ); - fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][slot_idx], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][slot_idx], Q6, CLDFB_NO_CHANNELS_MAX ); - } - - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, 2 * nchan_transport * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( &proto_diffuse_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, 2 * s_min( nchan_transport, hDirACRend->num_outputs_diff ) * hSpatParamRendCom->num_freq_bands ); - IF( nchan_transport >= 4 ) - { - fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); - } - IF( nchan_transport == 4 && p_Rmat_fx != 0 ) - { - FOR( i = 0; i < 4; i++ ) - { - fixedToFloat_arrL32( Cldfb_RealBuffer_fx[i][0], Cldfb_RealBuffer[i][0], Q6, hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[i][0], Cldfb_ImagBuffer[i][0], Q6, hSpatParamRendCom->num_freq_bands ); - } - } - } - ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) - { - fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - proto_length = i_mult(6, hSpatParamRendCom->num_freq_bands); - fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - IF( hDirACRend->masa_stereo_type_detect ) - { - hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); - } - } - ELSE - { - SWITCH( nchan_transport ) - { - case 11: - case 8: - case 6: - case 4: - offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); - fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); - fixedToFloat_arrL32( &proto_direct_buffer_f_fx[offset], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[offset], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); - proto_length = i_mult(2, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff)); - fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - case 2: - IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) - { - fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - } - ELSE - { - fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); - IF( hDirACRend->masa_stereo_type_detect ) - { - hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); - } - } - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); - proto_length = i_mult(6, hSpatParamRendCom->num_freq_bands); - fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - case 1: - fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); - fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); - proto_length = i_mult(2, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff)); - fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); - BREAK; - } - } - IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) - { - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[0][index - 1], hDirACRend->buffer_intensity_real[0][index - 1], hDirACRend->q_buffer_intensity_real[index - 1], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[1][index - 1], hDirACRend->buffer_intensity_real[1][index - 1], hDirACRend->q_buffer_intensity_real[index - 1], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[2][index - 1], hDirACRend->buffer_intensity_real[2][index - 1], hDirACRend->q_buffer_intensity_real[index - 1], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->diffuseness_vector[md_idx], hSpatParamRendCom->q_diffuseness_vector, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - fixedToFloat_arrL32( &hDirACRend->buffer_energy_fx[( index - 1 ) * num_freq_bands], &hDirACRend->buffer_energy[( index - 1 ) * num_freq_bands], hDirACRend->q_buffer_energy[index - 1], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); - } -#else - float dirEne; - float surCohEner; - float surCohRatio[CLDFB_NO_CHANNELS_MAX]; - float Cldfb_RealBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - float Cldfb_ImagBuffer_Temp[2][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#ifdef IVAS_FLOAT_FIXED - set_zero( surCohRatio, CLDFB_NO_CHANNELS_MAX ); -#endif - hodirac_flag = ivas_get_hodirac_flag( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ); - if ( st_ivas->hQMetaData != NULL && st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) - { - coherence_flag = st_ivas->hQMetaData->coherence_flag; - } - else - { - coherence_flag = 0; - } - - - /* Subframe loop */ - slot_idx_start = hSpatParamRendCom->slots_rendered; - slot_idx_start_cldfb_synth = 0; - - subframe_idx = hSpatParamRendCom->subframes_rendered; - if ( hDirAC->hConfig->dec_param_estim == FALSE ) - { - md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; - } - else - { - md_idx = hSpatParamRendCom->render_to_md_map[slot_idx_start]; - } - - /* copy parameters into local buffers*/ - if ( hDirAC->hConfig->dec_param_estim == FALSE ) - { - mvs2s( hSpatParamRendCom->azimuth[hSpatParamRendCom->render_to_md_map[subframe_idx]], azimuth, hSpatParamRendCom->num_freq_bands ); - mvs2s( hSpatParamRendCom->elevation[hSpatParamRendCom->render_to_md_map[subframe_idx]], elevation, hSpatParamRendCom->num_freq_bands ); - mvr2r( hSpatParamRendCom->diffuseness_vector[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector, hSpatParamRendCom->num_freq_bands ); -#ifdef IVAS_FLOAT_FIXED - Copy32( hSpatParamRendCom->diffuseness_vector_fx[hSpatParamRendCom->render_to_md_map[subframe_idx]], diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); -#endif - } - else - { - set_zero( diffuseness_vector, hSpatParamRendCom->num_freq_bands ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( diffuseness_vector_fx, 0, hSpatParamRendCom->num_freq_bands ); -#endif - } - - if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { - set_zero( reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - } - else - { - set_zero( onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); - } + p_Rmat_fx = &st_ivas->hCombinedOrientationData->Rmat_fx[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] ) - { - p_Rmat = &st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx][0][0]; - if ( st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + IF( EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; - if ( hDirAC->hConfig->dec_param_estim == FALSE ) + move16(); + IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) { - rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat ); + rotateAziEle_DirAC_fx( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat_fx ); } } } - else + ELSE { - p_Rmat = 0; + p_Rmat_fx = 0; } - if ( hDirAC->hConfig->dec_param_estim == FALSE ) + IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) { /* compute response */ - if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { -#ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - diffuseness_vector_fx[i] = float_to_fix( diffuseness_vector[i], Q30 ); - } - ivas_dirac_dec_compute_power_factors_fx( hSpatParamRendCom->num_freq_bands, diffuseness_vector_fx, hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx ); - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], Q29 ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], Q29 ); - } -#else - ivas_dirac_dec_compute_power_factors( hSpatParamRendCom->num_freq_bands, - diffuseness_vector, - hDirACRend->h_output_synthesis_psd_params.max_band_decorr, - hDirACRend->h_output_synthesis_psd_state.direct_power_factor, - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor ); -#endif + hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q29; + move16(); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q = Q29; + move16(); - if ( coherence_flag ) + IF( coherence_flag ) { - for ( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - dirEne = hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i]; - surCohEner = hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] * hSpatParamRendCom->surroundingCoherence[md_idx][i]; - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] -= surCohEner; - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] += surCohEner; + dirEne_fx = hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i]; // Q29 + move32(); + surCohEner_fx = Mpy_32_16_1( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hSpatParamRendCom->surroundingCoherence_fx[md_idx][i] ); // Q29 + Q15 - Q15 = Q29 - surCohRatio[i] = surCohEner / ( 1e-12f + dirEne + surCohEner ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i] = L_sub( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], surCohEner_fx ); // Q29 + move32(); + hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i] = L_add( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], surCohEner_fx ); // Q29 + move32(); + + surCohRatio_fx[i] = BASOP_Util_Divide3232_Scale( surCohEner_fx, ( L_add( EPSILLON_FX, L_add( dirEne_fx, surCohEner_fx ) ) ), &temp_q ); + move32(); + surCohRatio_fx[i] = L_shl( surCohRatio_fx[i], temp_q ); + move32(); } } - else + ELSE { - set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands ); + set_zero_fx( surCohRatio_fx, hSpatParamRendCom->num_freq_bands ); } + surCohRatio_q_fx = Q15; + move16(); } - else + ELSE { -#ifdef IVAS_FLOAT_FIXED Word16 max_exp_direct = 0, max_exp_diffusion = 0; ivas_dirac_dec_compute_gain_factors_fx( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], @@ -4526,66 +3978,27 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, &max_exp_direct, &max_exp_diffusion ); - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], max_exp_direct ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], max_exp_diffusion ); - } - -#else - ivas_dirac_dec_compute_gain_factors( hSpatParamRendCom->num_freq_bands, - hSpatParamRendCom->diffuseness_vector[md_idx], - hDirACRend->h_output_synthesis_psd_params.max_band_decorr, - hDirACRend->h_output_synthesis_psd_state.direct_power_factor, - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor ); -#endif + hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = sub(Q31, max_exp_direct); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q = sub(Q31, max_exp_diffusion); - if ( coherence_flag ) + IF( coherence_flag ) { - for ( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - surCohRatio[i] = hSpatParamRendCom->surroundingCoherence[md_idx][i]; + surCohRatio_fx[i] = (Word32) hSpatParamRendCom->surroundingCoherence_fx[md_idx][i]; + move32(); } } - else + ELSE { - set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands ); + set_zero_fx( surCohRatio_fx, hSpatParamRendCom->num_freq_bands ); } + surCohRatio_q_fx = Q15; + move16(); } - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) + IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 1 ) ) { -#ifdef IVAS_FLOAT_FIXED - Word32 surCohRatio_fx[CLDFB_NO_CHANNELS_MAX]; - Word16 Q_surCohRatio = Q31; - IF( surCohRatio != NULL ) - { - float max_val = 0.0f; - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - max_val = max( max_val, surCohRatio[i] ); - } - Word16 a = norm_l( (Word32) max_val ); - if ( a != 0 ) - { - Q_surCohRatio = a; - } - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - surCohRatio_fx[i] = float_to_fix( surCohRatio[i], Q_surCohRatio ); - } - } - ////////////////////////////////////// to be removed ///////////////////////////////// - IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) - { - IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) - { - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - } - } - ///////////////////////////////////////////////////////////////////////////////////// ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, @@ -4595,77 +4008,13 @@ void ivas_dirac_dec_render_sf_fx( elevation, md_idx, surCohRatio_fx, - Q_surCohRatio, + surCohRatio_q_fx, st_ivas->hCombinedOrientationData->shd_rot_max_order, p_Rmat_fx, hodirac_flag ); - ///////////////////////////////////// to be removed ////////////////////////////////////////////// - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - - IF( hodirac_flag ) - { - fixedToFloat_arrL( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - ELSE - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////// -#else - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat, - hodirac_flag ); -#endif } - else + ELSE { -#ifdef IVAS_FLOAT_FIXED - Word32 surCohRatio_fx[CLDFB_NO_CHANNELS_MAX]; - Word16 Q_surCohRatio = Q31; - IF( surCohRatio != NULL ) - { - float max_val = 0.0f; - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - max_val = max( max_val, surCohRatio[i] ); - } - Word16 a = norm_l( (Word32) max_val ); - if ( a != 0 ) - { - Q_surCohRatio = a; - } - for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - surCohRatio_fx[i] = float_to_fix( surCohRatio[i], Q_surCohRatio ); - } - } - ////////////////////////////////////// to be removed ///////////////////////////////// - IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) - { - IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) - { - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - } - } - ///////////////////////////////////////////////////////////////////////////////////// ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, @@ -4675,701 +4024,786 @@ void ivas_dirac_dec_render_sf_fx( elevation, md_idx, surCohRatio_fx, - Q_surCohRatio, + surCohRatio_q_fx, 0, NULL, hodirac_flag ); - ///////////////////////////////////// to be removed ////////////////////////////////////////////// - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + } - IF( hodirac_flag ) - { - fixedToFloat_arrL( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - ELSE + IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) + { + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + { + index_slot = add( slot_idx_start, slot_idx ); + offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); + /* CLDFB Analysis*/ + FOR( ch = 0; ch < nchan_transport; ch++ ) { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////// -#else - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - st_ivas->hMasa == NULL ? NULL : st_ivas->hMasa->data.band_mapping, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio, - 0, - NULL, - hodirac_flag ); -#endif - } - } - - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 ) - { - for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - index_slot = slot_idx_start + slot_idx; - - /* CLDFB Analysis*/ - for ( ch = 0; ch < nchan_transport; ch++ ) - { - cldfbAnalysis_ts_ivas( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), - Cldfb_RealBuffer_Temp[ch][slot_idx], - Cldfb_ImagBuffer_Temp[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch] ); + q_temp_cldfb = Q11; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], + Cldfb_RealBuffer_Temp_fx[ch][slot_idx], + Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); } + q_cldfb = q_temp_cldfb; + move16(); } - if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + IF( L_and( NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ), NE_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) { - ivas_omasa_preProcessStereoTransportsForMovedObjects( st_ivas, Cldfb_RealBuffer_Temp, Cldfb_ImagBuffer_Temp, hSpatParamRendCom->num_freq_bands, subframe_idx ); + ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( st_ivas, Cldfb_RealBuffer_Temp_fx, Cldfb_ImagBuffer_Temp_fx, &cldfb_buf_q, hSpatParamRendCom->num_freq_bands, subframe_idx ); } } - for ( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - index_slot = slot_idx_start + slot_idx; - if ( hDirAC->hConfig->dec_param_estim == TRUE ) + index_slot = add( slot_idx_start, slot_idx ); + IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { md_idx = hSpatParamRendCom->render_to_md_map[index_slot]; + move16(); } - else + ELSE { md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; + move16(); } - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) { - for ( ch = 0; ch < nchan_transport; ch++ ) + FOR( ch = 0; ch < nchan_transport; ch++ ) { - mvr2r( pppQMfFrame_ts_re[ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); - mvr2r( pppQMfFrame_ts_im[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( pppQMfFrame_ts_re_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( pppQMfFrame_ts_im_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); } + q_cldfb = Q6; + move16(); } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && nchan_transport == 2 ) + ELSE IF( L_and( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ), EQ_16( nchan_transport, 2 ) ) ) { - for ( ch = 0; ch < nchan_transport; ch++ ) + FOR( ch = 0; ch < nchan_transport; ch++ ) { - mvr2r( Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_RealBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); - mvr2r( Cldfb_ImagBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_RealBuffer_Temp_fx[ch][slot_idx], Cldfb_RealBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); + Copy32( Cldfb_ImagBuffer_Temp_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands ); } } - else + ELSE { /* CLDFB Analysis*/ - for ( ch = 0; ch < nchan_transport; ch++ ) + offset = i_mult( hSpatParamRendCom->num_freq_bands, index_slot ); + FOR( ch = 0; ch < nchan_transport; ch++ ) { - cldfbAnalysis_ts_ivas( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), - Cldfb_RealBuffer[ch][0], - Cldfb_ImagBuffer[ch][0], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch] ); + q_temp_cldfb = Q11; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &st_ivas->hTcBuffer->tc_fx[hDirACRend->sba_map_tc[ch]][offset], + Cldfb_RealBuffer_fx[ch][0], + Cldfb_ImagBuffer_fx[ch][0], + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch], &q_temp_cldfb ); } + q_cldfb = q_temp_cldfb; + move16(); } /* CNG in DirAC, extra CLDFB ana for CNA*/ - if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) + IF( EQ_16( st_ivas->nchan_transport, 1 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && !( L_or( EQ_16( st_ivas->ivas_format, SBA_FORMAT ), EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - - generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, - st_ivas->cldfbAnaDec[1], - st_ivas->hTcBuffer->tc[1], - Cldfb_RealBuffer[1][0], - Cldfb_ImagBuffer[1][0], - index_slot, - st->cna_dirac_flag && st->flag_cna, - ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); + Word16 Q_input = Q11; + move16(); + q_temp_cldfb = Q11; + generate_masking_noise_dirac_ivas_fx( st->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], + st_ivas->hTcBuffer->tc_fx[1], + Cldfb_RealBuffer_fx[1][0], + Cldfb_ImagBuffer_fx[1][0], + index_slot, + st->cna_dirac_flag && st->flag_cna, + ( L_or( EQ_32( st->core_brate, FRAME_NO_DATA ), EQ_32( st->core_brate, SID_2k40 ) ) ) && EQ_16( st->cng_type, FD_CNG ) && st->cng_sba_flag, Q_input, &q_temp_cldfb ); + Scale_sig32( Cldfb_RealBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); + Scale_sig32( Cldfb_ImagBuffer_fx[1][0], CLDFB_NO_CHANNELS_MAX, sub( Q6, q_temp_cldfb ) ); } /* LFE synthesis */ - if ( st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled && !( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && hDirACRend->hOutSetup.num_lfe == 0 ) ) + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled && !( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( hDirACRend->hOutSetup.num_lfe, 0 ) ) ) { - ivas_lfe_synth_with_cldfb( st_ivas->hMasa->hMasaLfeSynth, - Cldfb_RealBuffer, Cldfb_ImagBuffer, - Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1], - slot_idx, - md_idx, - nchan_transport ); + ivas_lfe_synth_with_cldfb_fx( st_ivas->hMasa->hMasaLfeSynth, + Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1], + slot_idx, + md_idx, + nchan_transport, q_cldfb ); } /*-----------------------------------------------------------------* * protoype signal computation *-----------------------------------------------------------------*/ - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) { - protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, - reference_power, slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - p_Rmat ); + protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + proto_diffuse_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + reference_power_fx, &DirAC_mem.reference_power_q, + slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + p_Rmat_fx, q_cldfb ); } - else + ELSE { - protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, - reference_power, slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - 0 ); + protoSignalComputation_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + proto_diffuse_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + reference_power_fx, &DirAC_mem.reference_power_q, + slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + 0, q_cldfb ); } + + q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; + move16(); + q_proto_diffuse_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q; + move16(); } - else if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { - protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, - 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect ); + protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, + &hDirACRend->proto_frame_f_q, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + reference_power_fx, + &DirAC_mem.reference_power_q, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect, + q_cldfb ); + + q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; + move16(); + + proto_length = i_mult( 6, hSpatParamRendCom->num_freq_bands ); } - else + ELSE { - switch ( nchan_transport ) + SWITCH( nchan_transport ) { case 11: case 8: case 6: case 4: - protoSignalComputation4( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, - slot_idx, hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - hDirACRend->hoa_decoder, - nchan_transport, - hDirACRend->sba_map_tc ); - break; + protoSignalComputation4_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + hDirACRend->proto_frame_f_fx, + &hDirACRend->proto_frame_f_q, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + reference_power_fx, + &DirAC_mem.reference_power_q, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + slot_idx, hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + hDirACRend->hoa_decoder, + nchan_transport, + hDirACRend->sba_map_tc, q_cldfb ); + proto_length = i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + BREAK; case 2: - protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, - hDirACRend->hOutSetup.is_loudspeaker_setup, - slot_idx, - hSpatParamRendCom->num_freq_bands, - hDirACRend->masa_stereo_type_detect ); - break; + protoSignalComputation2_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hDirACRend->proto_frame_f_fx, + &hDirACRend->proto_frame_f_q, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + reference_power_fx, + &DirAC_mem.reference_power_q, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + hDirACRend->hOutSetup.is_loudspeaker_setup, + slot_idx, + hSpatParamRendCom->num_freq_bands, + hDirACRend->masa_stereo_type_detect, + q_cldfb ); + proto_length = i_mult( 6, hSpatParamRendCom->num_freq_bands ); + BREAK; case 1: - protoSignalComputation1( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, - hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, - slot_idx, - hDirACRend->num_protos_diff, - hSpatParamRendCom->num_freq_bands ); - break; + protoSignalComputation1_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + hDirACRend->proto_frame_f_fx, + &hDirACRend->proto_frame_f_q, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, + reference_power_fx, + &DirAC_mem.reference_power_q, + hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, + &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, + slot_idx, + hDirACRend->num_protos_diff, + hSpatParamRendCom->num_freq_bands, q_cldfb ); + proto_length = i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ); + BREAK; default: return; } + q_proto_direct_buffer[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; + move16(); } /*-----------------------------------------------------------------* * Compute DirAC parameters at decoder side *-----------------------------------------------------------------*/ - - if ( hDirAC->hConfig->dec_param_estim == TRUE ) + IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { - mvs2s( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], hSpatParamRendCom->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); - mvs2s( &hSpatParamRendCom->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], hSpatParamRendCom->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); - if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) + Copy( &hSpatParamRendCom->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); + Copy( &hSpatParamRendCom->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], sub( hSpatParamRendCom->num_freq_bands, hDirAC->hConfig->enc_param_start_band ) ); + IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 0 ) ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; - rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat ); + move16(); + rotateAziEle_DirAC_fx( azimuth, elevation, num_freq_bands, hSpatParamRendCom->num_freq_bands, p_Rmat_fx ); } - hDirACRend->index_buffer_intensity = ( hDirACRend->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1; /* averaging_length = 32 */ + /*hDirACRend->index_buffer_intensity = ( hDirACRend->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1 */ + IF( EQ_16( hDirACRend->index_buffer_intensity, 0 ) ) + { + hDirACRend->index_buffer_intensity = 1; + } + ELSE + { + hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( idiv1616( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ + } index = hDirACRend->index_buffer_intensity; - + move16(); num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + move16(); - computeIntensityVector_dec( Cldfb_RealBuffer, - Cldfb_ImagBuffer, - num_freq_bands, - hDirACRend->buffer_intensity_real[0][index - 1], - hDirACRend->buffer_intensity_real[1][index - 1], - hDirACRend->buffer_intensity_real[2][index - 1] ); - - computeDirectionAngles( hDirACRend->buffer_intensity_real[0][index - 1], - hDirACRend->buffer_intensity_real[1][index - 1], - hDirACRend->buffer_intensity_real[2][index - 1], - num_freq_bands, - azimuth, - elevation ); - - mvr2r( reference_power, &( hDirACRend->buffer_energy[( index - 1 ) * num_freq_bands] ), num_freq_bands ); + computeIntensityVector_dec_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, + q_cldfb, num_freq_bands, + hDirACRend->buffer_intensity_real_fx[0][sub( index, 1 )], + hDirACRend->buffer_intensity_real_fx[1][sub( index, 1 )], + hDirACRend->buffer_intensity_real_fx[2][sub( index, 1 )], + &hDirACRend->q_buffer_intensity_real[sub( index, 1 )] ); + + computeDirectionAngles_fx( hDirACRend->buffer_intensity_real_fx[0][sub( index, 1 )], + hDirACRend->buffer_intensity_real_fx[1][sub( index, 1 )], + hDirACRend->buffer_intensity_real_fx[2][sub( index, 1 )], + hDirACRend->q_buffer_intensity_real[sub( index, 1 )], + num_freq_bands, azimuth, elevation ); + + Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); + hDirACRend->q_buffer_energy[sub( index, 1 )] = DirAC_mem.reference_power_q; + move16(); - computeDiffuseness( hDirACRend->buffer_intensity_real, hDirACRend->buffer_energy, num_freq_bands, hSpatParamRendCom->diffuseness_vector[md_idx] ); + computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); } -#endif /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ - Word16 scale = 0, temp_len = 0; - if ( hDirACRend->proto_signal_decorr_on == 1 ) + IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) { /* decorrelate prototype frame */ - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_dec_decorr_process_fx(hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - nchan_transport, - &proto_diffuse_buffer_f_fx [slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff], - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - hDirACRend->num_protos_diff, - hDirACRend->proto_index_diff, - &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min(4, nchan_transport)], - &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, - onset_filter_fx, - hDirACRend->h_freq_domain_decorr_ap_params, - hDirACRend->h_freq_domain_decorr_ap_state); - - - fixedToFloat_arrL(onset_filter_fx, onset_filter, Q31, hSpatParamRendCom->num_freq_bands ); + ivas_dirac_dec_decorr_process_fx( hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + nchan_transport, + &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff], + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + hDirACRend->num_protos_diff, + hDirACRend->proto_index_diff, + &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport )], + &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, + onset_filter_fx, + hDirACRend->h_freq_domain_decorr_ap_params, + hDirACRend->h_freq_domain_decorr_ap_state ); + + q_onset_filter = Q31; + move16(); -#else - ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - nchan_transport, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->proto_index_diff, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min( 4, nchan_transport ), - onset_filter, - hDirACRend->h_freq_domain_decorr_ap_params, - hDirACRend->h_freq_domain_decorr_ap_state ); -#endif + v_multc_fixed( onset_filter_fx, 268435456, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); // 268435456 = 0.25 in Q30 + q_onset_filter = sub( add( q_onset_filter, Q30 ), Q31 ); - v_multc( onset_filter, 0.25f, onset_filter, hSpatParamRendCom->num_freq_bands ); - v_add( onset_filter, onset_filter_subframe, onset_filter_subframe, hSpatParamRendCom->num_freq_bands ); - p_onset_filter = onset_filter_subframe; -#ifdef IVAS_FLOAT_FIXED - floatToFixed_arrL( onset_filter, onset_filter_fx, Q30, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( onset_filter_subframe, onset_filter_subframe_fx, Q30, hSpatParamRendCom->num_freq_bands ); + v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); // Q30 p_onset_filter_fx = onset_filter_subframe_fx; -#endif } ELSE { -#ifdef IVAS_FLOAT_FIXED - scale = L_norm_arr(hDirACRend->proto_frame_f_fx, proto_length); - Scale_sig32(hDirACRend->proto_frame_f_fx, proto_length, scale); - hDirACRend->proto_frame_f_q = add(hDirACRend->proto_frame_f_q, scale); - ivas_dirac_dec_decorr_process_fx(hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - nchan_transport, - hDirACRend->proto_frame_f_fx, - hDirACRend->proto_frame_f_q, - hDirACRend->num_protos_diff, - hDirACRend->proto_index_diff, - DirAC_mem.frame_dec_f_fx, - &DirAC_mem.frame_dec_f_q, - onset_filter_fx, - hDirACRend->h_freq_domain_decorr_ap_params, - hDirACRend->h_freq_domain_decorr_ap_state); - - temp_len = DirAC_mem.frame_dec_f_len; - fixedToFloat_arrL(onset_filter_fx, onset_filter, Q31, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff); - me2f_buf(DirAC_mem.frame_dec_f_fx, 31- DirAC_mem.frame_dec_f_q , DirAC_mem.frame_dec_f , temp_len); -#else - ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands, - hDirACRend->num_outputs_diff, - hDirACRend->num_protos_diff, - hDirACRend->synthesisConf, - nchan_transport, - hDirACRend->proto_frame_f, - hDirACRend->num_protos_diff, - hDirACRend->proto_index_diff, - DirAC_mem.frame_dec_f, - onset_filter, - hDirACRend->h_freq_domain_decorr_ap_params, - hDirACRend->h_freq_domain_decorr_ap_state ); -#endif - - hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; - p_onset_filter = onset_filter; + scale = L_norm_arr( hDirACRend->proto_frame_f_fx, proto_length ); + Scale_sig32( hDirACRend->proto_frame_f_fx, proto_length, scale ); + hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, scale ); + ivas_dirac_dec_decorr_process_fx( hSpatParamRendCom->num_freq_bands, + hDirACRend->num_outputs_diff, + hDirACRend->num_protos_diff, + hDirACRend->synthesisConf, + nchan_transport, + hDirACRend->proto_frame_f_fx, + hDirACRend->proto_frame_f_q, + hDirACRend->num_protos_diff, + hDirACRend->proto_index_diff, + DirAC_mem.frame_dec_f_fx, + &DirAC_mem.frame_dec_f_q, + onset_filter_fx, + hDirACRend->h_freq_domain_decorr_ap_params, + hDirACRend->h_freq_domain_decorr_ap_state ); -#ifdef IVAS_FLOAT_FIXED hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx; hDirACRend->proto_frame_dec_f_q = DirAC_mem.frame_dec_f_q; + move16(); hDirACRend->proto_frame_dec_f_len = DirAC_mem.frame_dec_f_len; + move16(); p_onset_filter_fx = onset_filter_fx; - floatToFixed_arrL(onset_filter, onset_filter_fx, Q30, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff); -#endif + + scale_sig32( onset_filter_fx, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff, -1 ); + q_onset_filter = Q30; + move16(); } } - else + ELSE { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - set_f( onset_filter_subframe, 1.f, hSpatParamRendCom->num_freq_bands ); - p_onset_filter = onset_filter_subframe; -#ifdef IVAS_FLOAT_FIXED set_l( onset_filter_subframe_fx, ONE_IN_Q30, hSpatParamRendCom->num_freq_bands ); + q_onset_filter = Q30; + move16(); p_onset_filter_fx = onset_filter_subframe_fx; -#endif } - else + ELSE { /* no frequency domain decorrelation: use prototype frame */ - hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; - p_onset_filter = NULL; -#ifdef IVAS_FLOAT_FIXED hDirACRend->proto_frame_dec_f_fx = hDirACRend->proto_frame_f_fx; hDirACRend->proto_frame_dec_f_len = hDirACRend->proto_frame_f_len; + move16(); hDirACRend->proto_frame_dec_f_q = hDirACRend->proto_frame_f_q; + move16(); p_onset_filter_fx = NULL; -#endif } } /*-----------------------------------------------------------------* * output synthesis *-----------------------------------------------------------------*/ - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS || hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) + IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) { + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state ); + Word16 diffuse_start = i_mult( i_mult( slot_idx, 2 ), i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) ); + + exp = getScaleFactor32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len ); + scale_sig32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len, exp ); + hDirACRend->proto_frame_dec_f_q = add( hDirACRend->proto_frame_dec_f_q, exp ); + + exp = getScaleFactor32( state->proto_diffuse_buffer_f_fx, diffuse_start ); + scale_sig32( state->proto_diffuse_buffer_f_fx, diffuse_start, exp ); + state->proto_diffuse_buffer_f_q = add( state->proto_diffuse_buffer_f_q, exp ); + /*Compute diffuse prototypes*/ -#ifdef IVAS_FLOAT_FIXED - /* Float to fixed */ - if (hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0) - { - f2me_buf(hDirACRend->proto_frame_dec_f, hDirACRend->proto_frame_dec_f_fx, &hDirACRend->proto_frame_dec_f_q, hDirACRend->proto_frame_dec_f_len); - hDirACRend->proto_frame_dec_f_q = 31 - hDirACRend->proto_frame_dec_f_q; - DIRAC_OUTPUT_SYNTHESIS_STATE *state = &(hDirACRend->h_output_synthesis_psd_state); - f2me_buf(state->proto_power_diff_smooth, state->proto_power_diff_smooth_fx, &state->proto_power_diff_smooth_q, state->proto_power_diff_smooth_len); - state->proto_power_diff_smooth_q = 31 - state->proto_power_diff_smooth_q; - Word16 diffuse_start = slot_idx * 2 * hDirACRend->h_output_synthesis_psd_params.max_band_decorr * hDirACRend->hOutSetup.nchan_out_woLFE; - state->proto_diffuse_buffer_f_q = 31; - f2me_buf(state->proto_diffuse_buffer_f, state->proto_diffuse_buffer_f_fx, &state->proto_diffuse_buffer_f_q, diffuse_start); - state->proto_diffuse_buffer_f_q = 31 - state->proto_diffuse_buffer_f_q; - } ivas_dirac_dec_compute_diffuse_proto_fx( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); - /* Fixed to float */ - if (hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0) - { - DIRAC_OUTPUT_SYNTHESIS_STATE *state = &(hDirACRend->h_output_synthesis_psd_state); - me2f_buf(state->proto_power_diff_smooth_fx, - 31 - state->proto_power_diff_smooth_q, - state->proto_power_diff_smooth, - state->proto_power_diff_smooth_len); - me2f_buf(state->proto_diffuse_buffer_f_fx, - 31 - state->proto_diffuse_buffer_f_q, - state->proto_diffuse_buffer_f, - state->proto_diffuse_buffer_f_len); - } -#else - ivas_dirac_dec_compute_diffuse_proto( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx ); -#endif } /*Compute PSDs*/ -#ifdef IVAS_FLOAT_FIXED -#if 1 // TO BE REMOVED - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; - DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; + h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); + h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); + num_channels_dir = hDirACRend->num_outputs_dir; + move16(); - h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params ); - h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) ) + { + num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; + move16(); + } - Word16 num_channels_dir = hDirACRend->num_outputs_dir; + IF( L_and( h_dirac_output_synthesis_params->use_onset_filters, L_and( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) ) + { + Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_params->max_band_decorr, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; + move16(); - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) - { - num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE; + scale_sig32( h_dirac_output_synthesis_state->diffuse_responses_square_fx, num_channels_dir, sub( Q31, h_dirac_output_synthesis_state->diffuse_responses_square_q ) ); + h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; + move16(); + + exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); + } + + IF( L_and( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) + { + scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) ); + h_dirac_output_synthesis_state->direct_power_factor_q = Q31; + move16(); + + scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) ); + h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; + move16(); + + scale_sig32( h_dirac_output_synthesis_state->direct_responses_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, h_dirac_output_synthesis_state->direct_responses_q ) ); + h_dirac_output_synthesis_state->direct_responses_q = Q31; + move16(); + + scale_sig32( h_dirac_output_synthesis_state->direct_responses_square_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, h_dirac_output_synthesis_state->direct_responses_square_q ) ); + h_dirac_output_synthesis_state->direct_responses_square_q = Q31; + move16(); + + scale_sig32( h_dirac_output_synthesis_state->diffuse_responses_square_fx, num_channels_dir, sub( Q31, h_dirac_output_synthesis_state->diffuse_responses_square_q ) ); + h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; + move16(); + + exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, exp ); + + exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, exp ); + + exp = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); + scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ), exp ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); + } + + IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) + { + ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, + DirAC_mem.reference_power_q, + p_onset_filter_fx, + azimuth, + elevation, + hSpatParamRendCom->diffuseness_vector_fx[md_idx], + hSpatParamRendCom->q_diffuseness_vector, + hSpatParamRendCom, + hDirACRend, + st_ivas->hCombinedOrientationData->shd_rot_max_order, + p_Rmat_fx, + st_ivas->hVBAPdata, + hDirACRend->hOutSetup, + nchan_transport, + md_idx, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); + } + ELSE + { + ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, + DirAC_mem.reference_power_q, + p_onset_filter_fx, + azimuth, + elevation, + hSpatParamRendCom->diffuseness_vector_fx[md_idx], + hSpatParamRendCom->q_diffuseness_vector, + hSpatParamRendCom, + hDirACRend, + 0, + 0, + st_ivas->hVBAPdata, + hDirACRend->hOutSetup, + nchan_transport, + md_idx, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); + } + + IF( hDirAC->hConfig->dec_param_estim ) + { + Word16 fac = BASOP_Util_Divide3232_Scale( 1, hSpatParamRendCom->subframe_nbslots[subframe_idx], &exp ); + Word32 flag = 0; + move32(); + fac = shl_o( fac, exp, &flag ); + + IF( LT_16( q_diffuseness_vector, hSpatParamRendCom->q_diffuseness_vector ) ) + { + scale_sig32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->num_freq_bands, sub( q_diffuseness_vector, hSpatParamRendCom->q_diffuseness_vector ) ); + hSpatParamRendCom->q_diffuseness_vector = q_diffuseness_vector; + move16(); + } + ELSE + { + scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( hSpatParamRendCom->q_diffuseness_vector, q_diffuseness_vector ) ); + q_diffuseness_vector = hSpatParamRendCom->q_diffuseness_vector; + move16(); + } + v_multc_acc_32_16( hSpatParamRendCom->diffuseness_vector_fx[md_idx], fac, diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands ); + } + + IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) ) + { + scale_sig32( reference_power_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, DirAC_mem.reference_power_q ) ); + DirAC_mem.reference_power_q = q_reference_power_smooth; + move16(); + } + ELSE + { + scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_q, q_reference_power_smooth ) ); + q_reference_power_smooth = DirAC_mem.reference_power_q; + move16(); + } + v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 ); + q_reference_power_smooth = sub( q_reference_power_smooth, 1 ); + } } - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD && hodirac_flag ) + +#ifdef IVAS_FLOAT_FIXED + ////////////////////////////////// to be removed ///////////////////////////////////// + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, nchan_transport ) ), q_proto_direct_buffer[slot_idx], 2 * nchan_transport * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL32( &proto_diffuse_buffer_f_fx[i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) )], hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f + i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ), q_proto_diffuse_buffer[slot_idx], 2 * s_min( nchan_transport, hDirACRend->num_outputs_diff ) * hSpatParamRendCom->num_freq_bands ); + } + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) + { + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), q_proto_direct_buffer[slot_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); + } + ELSE { - IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) + SWITCH( nchan_transport ) { - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); + case 11: + case 8: + case 6: + case 4: + offset = i_mult( i_mult( slot_idx, 2 ), i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[offset], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[offset], q_proto_direct_buffer[slot_idx], i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + BREAK; + case 2: + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) + { + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 3 ), q_proto_direct_buffer[slot_idx], i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + } + ELSE + { + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), q_proto_direct_buffer[slot_idx], i_mult( 4, hSpatParamRendCom->num_freq_bands ) ); + } + BREAK; + case 1: + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx[i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ), q_proto_direct_buffer[slot_idx], i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + BREAK; } } } + IF( EQ_16( hDirAC->hConfig->dec_param_estim, FALSE ) ) + { + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); + } + ELSE + { + me2f_buf( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor, hSpatParamRendCom->num_freq_bands ); + me2f_buf( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hSpatParamRendCom->num_freq_bands ); + } + } + IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + + IF( hodirac_flag ) + { + fixedToFloat_arrL32( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + } + ELSE + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + } + } + IF( !( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) ) + { + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + fixedToFloat_arrL32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, st_ivas->cldfbAnaDec[ch]->cldfb_state, Q11, ( st_ivas->cldfbAnaDec[ch]->p_filter_length - st_ivas->cldfbAnaDec[ch]->no_channels ) ); + } + } + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + IF( nchan_transport >= 4 ) + { + fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, 5 * hSpatParamRendCom->num_freq_bands ); + } + } + ELSE IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + IF( hDirACRend->masa_stereo_type_detect ) + { + hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + } + } + ELSE + { + SWITCH( nchan_transport ) + { + case 11: + case 8: + case 6: + case 4: + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); + me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) ); + fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + case 2: + IF( hDirACRend->hOutSetup.is_loudspeaker_setup ) + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 3, hSpatParamRendCom->num_freq_bands ) ); + } + ELSE + { + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ); + IF( hDirACRend->masa_stereo_type_detect ) + { + hDirACRend->masa_stereo_type_detect->subtract_power_y = fixedToFloat_32( hDirACRend->masa_stereo_type_detect->subtract_power_y_fx, hDirACRend->masa_stereo_type_detect->q_subtract_power_y ); + } + } + me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 6, hSpatParamRendCom->num_freq_bands ) ); + fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + case 1: + fixedToFloat_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands ); + me2f_buf( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_q, hDirACRend->proto_frame_f, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) ); + fixedToFloat_arrL32( reference_power_fx, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands ); + BREAK; + } + } - if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) + IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) ) { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; i++ ) { - floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[0][i], hDirACRend->buffer_intensity_real[0][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[1][i], hDirACRend->buffer_intensity_real[1][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + fixedToFloat_arrL32( hDirACRend->buffer_intensity_real_fx[2][i], hDirACRend->buffer_intensity_real[2][i], hDirACRend->q_buffer_intensity_real[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); + fixedToFloat_arrL32( &hDirACRend->buffer_energy_fx[i * num_freq_bands], &hDirACRend->buffer_energy[i * num_freq_bands], hDirACRend->q_buffer_energy[i], hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); } - } - else if ( hDirAC->hConfig->dec_param_estim == TRUE ) - { - IF( EQ_16( hDirACRend->panningConf, DIRAC_PANNING_VBAP ) ) + FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - IF( EQ_16( hSpatParamRendCom->numParametricDirections, 2 ) ) - { - floatToFixed_arr( hDirACRend->diffuse_response_function, hDirACRend->diffuse_response_function_fx, Q15, hDirACRend->num_outputs_dir ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio1[md_idx], hSpatParamRendCom->energy_ratio1_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( hSpatParamRendCom->energy_ratio2[md_idx], hSpatParamRendCom->energy_ratio2_fx[md_idx], Q30, hSpatParamRendCom->num_freq_bands ); - } + md_idx = hSpatParamRendCom->render_to_md_map[add( hSpatParamRendCom->slots_rendered, slot_idx )]; + fixedToFloat_arrL32( hSpatParamRendCom->diffuseness_vector_fx[md_idx], hSpatParamRendCom->diffuseness_vector[md_idx], Q30, hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band] ); } - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + } + + IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) + { + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - floatToFixed_arrL32( reference_power, reference_power_fix, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands * (min( 4, nchan_transport ) + 1)); + fixedToFloat_arrL( onset_filter_fx, onset_filter, q_onset_filter, hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( onset_filter_subframe_fx, onset_filter_subframe, q_onset_filter, hSpatParamRendCom->num_freq_bands ); + p_onset_filter = onset_filter_subframe; } - else + ELSE { + fixedToFloat_arrL( onset_filter_fx, onset_filter, q_onset_filter, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff ); + me2f_buf( DirAC_mem.frame_dec_f_fx, 31 - DirAC_mem.frame_dec_f_q, DirAC_mem.frame_dec_f, DirAC_mem.frame_dec_f_len ); + hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f; + p_onset_filter = onset_filter; } } - - if ( h_dirac_output_synthesis_params->use_onset_filters && (hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD)) - { - h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_q, h_dirac_output_synthesis_params->max_band_decorr ); - - h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->diffuse_responses_square_q, num_channels_dir ); - - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - - floatToFixed_arrL(hDirACRend->stack_mem.onset_filter, p_onset_filter_fx, Q30, ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ? hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands : 2 * hSpatParamRendCom->num_freq_bands ); - } - - if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD) + ELSE { - h_dirac_output_synthesis_state->direct_power_factor_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->direct_responses_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->direct_responses, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_q, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->direct_responses_square_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->direct_responses_square, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->direct_responses_square_q, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor_q, hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = L_get_q_buf( h_dirac_output_synthesis_state->cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - - h_dirac_output_synthesis_state->diffuse_responses_square_q = Q31; - floatToFixed_arrL( h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->diffuse_responses_square_q, num_channels_dir ); - } -#endif - IF ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) + IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fix, - DirAC_mem.reference_power_q, - p_onset_filter_fx, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector_fx[md_idx], - hSpatParamRendCom->q_diffuseness_vector, - hSpatParamRendCom, - hDirACRend, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat_fx, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); + fixedToFloat_arrL( onset_filter_fx, onset_filter, q_onset_filter, hSpatParamRendCom->num_freq_bands ); + p_onset_filter = onset_filter_subframe; } ELSE { - ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fix, - DirAC_mem.reference_power_q, - p_onset_filter_fx, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector_fx[md_idx], - hSpatParamRendCom->q_diffuseness_vector, - hSpatParamRendCom, - hDirACRend, - 0, - 0, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); + hDirACRend->proto_frame_dec_f = hDirACRend->proto_frame_f; + p_onset_filter = NULL; } - -#if 1 - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD && hodirac_flag ) + } + IF( L_or( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ), EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) + { + if ( hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0 ) { - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); + DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state ); + me2f_buf( state->proto_power_diff_smooth_fx, + 31 - state->proto_power_diff_smooth_q, + state->proto_power_diff_smooth, + state->proto_power_diff_smooth_len ); + me2f_buf( state->proto_diffuse_buffer_f_fx, + 31 - state->proto_diffuse_buffer_f_q, + state->proto_diffuse_buffer_f, + state->proto_diffuse_buffer_f_len ); + } + } - IF( hodirac_flag ) - { - fixedToFloat_arrL( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - ELSE - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } + if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) + { + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_q, 2 * hSpatParamRendCom->num_freq_bands ); } - if ( hDirAC->hConfig->dec_param_estim == FALSE && hodirac_flag ) + else { - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL(h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->direct_power_factor, h_dirac_output_synthesis_state->direct_power_factor_q, 2*hSpatParamRendCom->num_freq_bands); - fixedToFloat_arrL(h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diffuse_power_factor, h_dirac_output_synthesis_state->diffuse_power_factor_q, 2*hSpatParamRendCom->num_freq_bands); - } - else + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 -hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); } } - else if ( hDirAC->hConfig->dec_param_estim == TRUE ) + } + else if ( hDirAC->hConfig->dec_param_estim == TRUE ) + { + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - IF( st_ivas->hMasa == NULL && EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - - IF( hodirac_flag ) - { - fixedToFloat_arrL( &hDirACRend->h_output_synthesis_psd_state.direct_responses_fx[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], &hDirACRend->h_output_synthesis_psd_state.direct_responses[i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir )], hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - ELSE - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses, hDirACRend->h_output_synthesis_psd_state.direct_responses_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - IF( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - fixedToFloat_arrL( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->h_output_synthesis_psd_state.direct_responses_square, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); - } - } - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->direct_power_factor_q ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->diffuse_power_factor_q ); - } - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, (num_channels_dir) * hSpatParamRendCom->num_freq_bands ); - } - else + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) { - - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); - hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); - } - + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->direct_power_factor_q ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = me2f( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], 31 - h_dirac_output_synthesis_state->diffuse_power_factor_q ); } - } - - if ( h_dirac_output_synthesis_params->use_onset_filters && (hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD)) - { - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); - } - - if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD) - { - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); - } -#endif -#else - if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) - { - ivas_dirac_dec_output_synthesis_process_slot( reference_power, - p_onset_filter, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector[md_idx], - hSpatParamRendCom, - hDirACRend, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, (num_channels_dir) *hSpatParamRendCom->num_freq_bands ); } else { - ivas_dirac_dec_output_synthesis_process_slot( reference_power, - p_onset_filter, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector[md_idx], - hSpatParamRendCom, - hDirACRend, - 0, - 0, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); - } -#endif - if ( hDirAC->hConfig->dec_param_estim ) - { - float fac = 1.0f / (float) hSpatParamRendCom->subframe_nbslots[subframe_idx]; - v_multc_acc( hSpatParamRendCom->diffuseness_vector[md_idx], fac, diffuseness_vector, hSpatParamRendCom->num_freq_bands ); + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + hDirACRend->h_output_synthesis_psd_state.direct_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ); + hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor[i] = fix_to_float( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx[i], hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ); + } } + } - if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) - { - v_add( reference_power, reference_power_smooth, reference_power_smooth, hSpatParamRendCom->num_freq_bands ); - } + if ( h_dirac_output_synthesis_params->use_onset_filters && ( hDirAC->hConfig->dec_param_estim != TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands ); + } + + if ( hDirAC->hConfig->dec_param_estim == TRUE && hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + fixedToFloat_arrL( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, num_channels_dir * hSpatParamRendCom->num_freq_bands ); + } + + if ( hDirAC->hConfig->dec_param_estim ) + { + fixedToFloat_arrL32( diffuseness_vector_fx, diffuseness_vector, q_diffuseness_vector, hSpatParamRendCom->num_freq_bands ); + } + + if ( hDirACRend->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) + { + fixedToFloat_arrL32( reference_power_smooth_fx, reference_power_smooth, q_reference_power_smooth, hSpatParamRendCom->num_freq_bands ); } + ////////////////////////////////////////////////////////////////////////////////////// +#endif #ifdef IVAS_FLOAT_FIXED ivas_dirac_dec_output_synthesis_get_interpolator_fx( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); @@ -5386,61 +4820,6 @@ void ivas_dirac_dec_render_sf_fx( size = hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; size_ho = ( hodirac_flag ) ? size * DIRAC_HO_NUMSECTORS : size; -#ifdef MSAN_FIX - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - floatToFixed_arrL( Cldfb_RealBuffer[ch][0], Cldfb_RealBuffer_fx[ch][0], - Q6, - hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( Cldfb_ImagBuffer[ch][0], Cldfb_ImagBuffer_fx[ch][0], - Q6, - hSpatParamRendCom->num_freq_bands ); - } -#else - IF( hDirACRend->hOutSetup.is_loudspeaker_setup && hDirACRend->hoa_decoder != NULL ) - { - FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) - { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - floatToFixed_arrL( Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], - Q6, - hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], - Q6, - hSpatParamRendCom->num_freq_bands ); - } - } - } - ELSE - { -#ifdef MSAN_FIX - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - floatToFixed_arrL( Cldfb_RealBuffer[ch][0], Cldfb_RealBuffer_fx[ch][0], - Q6, - hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( Cldfb_ImagBuffer[ch][0], Cldfb_ImagBuffer_fx[ch][0], - Q6, - hSpatParamRendCom->num_freq_bands ); - } -#else - FOR( ch = 0; ch < hDirACRend->num_outputs_dir; ch++ ) - { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - floatToFixed_arrL( Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], - Q6, - hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], - Q6, - hSpatParamRendCom->num_freq_bands ); - } - } -#endif - } -#endif - hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = Q26; floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, size_ho ); @@ -5535,12 +4914,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - fixedToFloat_arrL( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer[ch][slot_idx], - add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ), - hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], - add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ), - hSpatParamRendCom->num_freq_bands ); + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); } } } @@ -5550,12 +4925,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - fixedToFloat_arrL( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer[ch][slot_idx], - add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ), - hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], - add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ), - hSpatParamRendCom->num_freq_bands ); + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, add( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, sub( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, 33 ) ) ) ); } } } @@ -5564,7 +4935,6 @@ void ivas_dirac_dec_render_sf_fx( else { #ifdef IVAS_FLOAT_FIXED - Word16 q_reference_power_smooth; Word16 size, size_ho, q_Cldfb; size = hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; size_ho = ( hodirac_flag ) ? size * DIRAC_HO_NUMSECTORS : size; @@ -5595,31 +4965,6 @@ void ivas_dirac_dec_render_sf_fx( #endif #ifdef IVAS_FLOAT_FIXED -#ifdef MSAN_FIX - FOR( ch = 0; ch < nchan_transport; ch++ ) - { - floatToFixed_arrL( Cldfb_RealBuffer[ch][0], Cldfb_RealBuffer_fx[ch][0], - Q6, - hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( Cldfb_ImagBuffer[ch][0], Cldfb_ImagBuffer_fx[ch][0], - Q6, - hSpatParamRendCom->num_freq_bands ); - } -#else - FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ ) - { - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) - { - floatToFixed_arrL( Cldfb_RealBuffer[ch][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], - Q6, - hSpatParamRendCom->num_freq_bands ); - floatToFixed_arrL( Cldfb_ImagBuffer[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], - Q6, - hSpatParamRendCom->num_freq_bands ); - } - } -#endif - hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31; floatToFixed_arrL( hDirACRend->h_output_synthesis_psd_state.direct_power_factor, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, hSpatParamRendCom->num_freq_bands ); @@ -5776,12 +5121,8 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { - fixedToFloat_arrL( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer[ch][slot_idx], - q_Cldfb, - hSpatParamRendCom->num_freq_bands ); - fixedToFloat_arrL( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer[ch][slot_idx], - q_Cldfb, - hSpatParamRendCom->num_freq_bands ); + scale_sig32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); + scale_sig32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands, sub( Q6, q_Cldfb ) ); } } #endif @@ -5795,34 +5136,6 @@ void ivas_dirac_dec_render_sf_fx( #ifdef IVAS_FLOAT_FIXED //////////////////////////////////////////////// FLOAT TO FIXED ///////////////////////////////////////////// -#ifdef MSAN_FIX - Word16 idx1, idx2, idx3; - for ( idx1 = 0; idx1 < hDirACRend->hOutSetup.nchan_out_woLFE; idx1++ ) - { - for ( idx2 = 0; idx2 < hSpatParamRendCom->subframe_nbslots[subframe_idx]; idx2++ ) - { - for ( idx3 = 0; idx3 < hSpatParamRendCom->num_freq_bands; idx3++ ) - { - Cldfb_RealBuffer_fx[idx1][idx2][idx3] = floatToFixed( Cldfb_RealBuffer[idx1][idx2][idx3], Q6 ); - Cldfb_ImagBuffer_fx[idx1][idx2][idx3] = floatToFixed( Cldfb_ImagBuffer[idx1][idx2][idx3], Q6 ); - } - } - } -#else - for (int idx1 = 0; idx1 < MAX_OUTPUT_CHANNELS; idx1++) - { - for (int idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++) - { - for (int idx3 = 0; idx3 < CLDFB_NO_CHANNELS_MAX; idx3++) - { - Cldfb_RealBuffer_fx[idx1][idx2][idx3] = floatToFixed(Cldfb_RealBuffer[idx1][idx2][idx3], Q6); - Cldfb_ImagBuffer_fx[idx1][idx2][idx3] = floatToFixed(Cldfb_ImagBuffer[idx1][idx2][idx3], Q6); - - } - } - } -#endif - Word32 output_buf_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; if (st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM) { @@ -5967,9 +5280,9 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); - FOR ( idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + FOR ( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { - FOR ( idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) + FOR ( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) { Scale_sig32(Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, Q6 - input_q ); Scale_sig32(Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, Q6 - input_q ); @@ -6012,11 +5325,6 @@ void ivas_dirac_dec_render_sf_fx( #if 1 // TODOD: remove Fixed to float fixedToFloat_arrL( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_state, st_ivas->cldfbSynDec[ch]->Q_cldfb_state, st_ivas->cldfbSynDec[ch]->p_filter_length ); - for ( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) - { - fixedToFloat_arrL( Cldfb_RealBuffer_Binaural_fx[ch][i], Cldfb_RealBuffer_Binaural[ch][i], CLDFB_NO_CHANNELS_MAX, Q6 ); - fixedToFloat_arrL( Cldfb_ImagBuffer_Binaural_fx[ch][i], Cldfb_ImagBuffer_Binaural[ch][i], CLDFB_NO_CHANNELS_MAX, Q6 ); - } #endif } } @@ -7352,4 +6660,4 @@ void ivas_dirac_dec_render_sf( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 25f5b5c26..36bc0fef2 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -461,6 +461,8 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( tmp_fx = hDirACRend->diffuse_response_function_fx[ch_idx]; dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx] = L_deposit_h( mult( tmp_fx, tmp_fx ) ); + dirac_output_synthesis_state->diffuse_responses_square_q = Q31; + move16(); /*TODO : remove floating code*/ dirac_output_synthesis_state->diffuse_responses_square[ch_idx] = fixedToFloat( dirac_output_synthesis_state->diffuse_responses_square_fx[ch_idx], Q31 ); } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 6ae3e7f7d..f52a9f0b8 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1729,7 +1729,7 @@ ivas_error ivas_dirac_alloc_mem( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx = hDirAC_mem->proto_direct_buffer_f_fx; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx = hDirAC_mem->proto_diffuse_buffer_f_fx; hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len = hDirAC_mem->proto_diffuse_buffer_f_len; - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = hDirAC_mem->proto_diffuse_buffer_f_q; + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = Q31; #endif /* Gains/power factors*/ hDirAC_mem->direct_power_factor = NULL; -- GitLab