From 21caa42f7e97b30bcc51709147f17942f1073299 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 11 Nov 2024 16:17:12 +0100 Subject: [PATCH 01/36] implement bandwise Q for reference power --- lib_com/options.h | 2 + lib_dec/ivas_dirac_dec.c | 346 +++++++++ lib_rend/ivas_dirac_output_synthesis_dec.c | 863 ++++++++++++++++++++- lib_rend/ivas_dirac_rend.c | 291 +++++++ lib_rend/ivas_prot_rend.h | 4 + lib_rend/ivas_stat_rend.h | 43 +- lib_rend/lib_rend.c | 99 +++ 7 files changed, 1609 insertions(+), 39 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 21e924688..213d152d1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,6 +200,8 @@ #define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* FhG: fixes for decoder-side noise level estimation in MDCT-Stereo to prevent noise bursts in stereo switching */ /* ################## End DEVELOPMENT switches ######################### */ +#define FIX_867 + /* clang-format on */ #define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 787379e9f..3a7da7cdb 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3739,7 +3739,12 @@ void ivas_dirac_dec_render_sf_fx( DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; Word16 num_channels_dir, exp; +#ifdef FIX_867 + Word16 q_diffuseness_vector = Q31; + Word16 q_reference_power_smooth[CLDFB_SLOTS_PER_SUBFRAME * MAX_OUTPUT_CHANNELS]; +#else Word16 q_diffuseness_vector = Q31, q_reference_power_smooth = Q31; +#endif move16(); move16(); Word16 proto_power_smooth_len = 0; @@ -3747,6 +3752,9 @@ void ivas_dirac_dec_render_sf_fx( Word16 tmp1; push_wmops( "ivas_dirac_dec_render" ); +#ifdef FIX_876 + set16_fx( q_reference_power_smooth, Q31, CLDFB_SLOTS_PER_SUBFRAME * MAX_OUTPUT_CHANNELS ); +#endif /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; @@ -3819,15 +3827,46 @@ void ivas_dirac_dec_render_sf_fx( test(); IF( h_dirac_output_synthesis_params->use_onset_filters && ( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ) && NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ); kk++ ) + { + tmp1 = norm_l( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] ); + L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] ) ); // tmp1 + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = tmp1; + move16(); + } +#else tmp1 = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); // tmp1 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = tmp1; move16(); +#endif } test(); IF( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ) && NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ); kk++ ) + { + Word16 shift; + shift = L_norm_arr( &h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx[kk], 1 ); + + h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx[kk], shift ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + shift + h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[kk] = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[kk], shift ); + move16(); + + shift = norm_l( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] ); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], 1 ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + shift + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = add( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk], shift ); + move16(); + + tmp1 = norm_l( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] ); + h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], tmp1 ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + tmp1 + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk], tmp1 ); + move16(); + } +#else Word16 shift; shift = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), shift ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + shift @@ -3841,6 +3880,7 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth + tmp1 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp1 ); move16(); +#endif } @@ -3936,13 +3976,45 @@ void ivas_dirac_dec_render_sf_fx( size_ho = size; move16(); } +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < size; kk++ ) + { + hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk] ) ); // Q26 + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26, size ); +#else scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; move16(); +#endif IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { Word16 shift; +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < size_ho; kk++ ) + { + shift = norm_l( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk] ); + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk], shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth + shift) + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[kk], shift ); + move16(); + + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk] = Q26; + move16(); + } + + FOR( Word16 kk = 0; kk < imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); kk++ ) + { + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth[kk] ) ); // Q26 + set16_fx( &hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth[kk], Q26, 1 ); + move16(); + + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk] ) ); // Q26 + set16_fx( &hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk], Q26, 1 ); + move16(); + } +#else shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth + shift) hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, shift ); @@ -3959,10 +4031,42 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26; move16(); +#endif } ELSE { Word16 shift; +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ); kk++ ) + { + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk] = Q26; + move16(); + } + + FOR( Word16 kk = 0; kk < size_ho; kk++ ) + { + shift = norm_l( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx[kk] ); + hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx[kk], shift ); // Q( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev+ shift) + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev[kk], shift ); + move16(); + + + shift = norm_l( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[kk] ); + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[kk], shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev + shift) + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk] = + add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk], shift ); + move16(); + } + + FOR( Word16 kk = 0; kk < imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ); kk++ ) + { + tmp1 = norm_l( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk] ); + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk], tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev+ tmp1) + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk], tmp1 ); + move16(); + } +#else scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; move16(); @@ -3979,6 +4083,8 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev+ tmp1) hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp1 ); move16(); +#endif + tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1) hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, tmp1 ); @@ -4327,7 +4433,11 @@ void ivas_dirac_dec_render_sf_fx( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, +#ifdef FIX_867 + reference_power_fx, DirAC_mem.reference_power_q, +#else reference_power_fx, &DirAC_mem.reference_power_q, +#endif slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, @@ -4340,7 +4450,11 @@ void ivas_dirac_dec_render_sf_fx( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, +#ifdef FIX_867 + reference_power_fx, DirAC_mem.reference_power_q, +#else reference_power_fx, &DirAC_mem.reference_power_q, +#endif slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, @@ -4359,7 +4473,11 @@ void ivas_dirac_dec_render_sf_fx( 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, +#ifdef FIX_867 + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif 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, @@ -4385,7 +4503,11 @@ void ivas_dirac_dec_render_sf_fx( 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, +#ifdef FIX_867 + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif 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, @@ -4402,7 +4524,11 @@ void ivas_dirac_dec_render_sf_fx( 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, +#ifdef FIX_867 + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif 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, @@ -4427,7 +4553,11 @@ void ivas_dirac_dec_render_sf_fx( 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, +#ifdef FIX_867 + DirAC_mem.reference_power_q, +#else &DirAC_mem.reference_power_q, +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, slot_idx, @@ -4492,7 +4622,11 @@ void ivas_dirac_dec_render_sf_fx( num_freq_bands, azimuth, elevation ); Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); +#ifdef FIX_867 + hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0]; +#else hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q; +#endif 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 ); @@ -4617,10 +4751,20 @@ void ivas_dirac_dec_render_sf_fx( h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31; move16(); +#ifdef FIX_867 + FOR( Word16 l = 0; l < i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ); l++ ) + { + exp = norm_l( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[l] ); + h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[l] = L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[l], exp ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + exp + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[l] = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[l], exp ); + move16(); + } +#else 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 + exp h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); move16(); +#endif } test(); @@ -4641,7 +4785,25 @@ void ivas_dirac_dec_render_sf_fx( 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 ) ); // Q31 h_dirac_output_synthesis_state->direct_responses_square_q = Q31; move16(); +#ifdef FIX_867 + FOR( Word16 l = 0; l < i_mult( num_channels_dir, hSpatParamRendCom->num_freq_bands ); l++ ) + { + exp = getScaleFactor32( &h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx[l], 1 ); + scale_sig32( &h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx[l], 1, exp ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, exp + h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[l] = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[l], exp ); + move16(); + exp = getScaleFactor32( &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[l], 1 ); + scale_sig32( &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[l], 1, exp ); // h_dirac_output_synthesis_state->q_cy_auto_dir_smooth+ exp + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[l] = add( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[l], exp ); + move16(); + + exp = getScaleFactor32( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[l], 1 ); + scale_sig32( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[l], 1, exp ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth+ exp + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[l] = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[l], exp ); + move16(); + } +#else 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, exp h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, exp ); @@ -4654,6 +4816,7 @@ void ivas_dirac_dec_render_sf_fx( 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+ exp h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, exp ); move16(); +#endif } test(); @@ -4724,6 +4887,49 @@ void ivas_dirac_dec_render_sf_fx( IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867 + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + IF( LT_16( q_reference_power_smooth[i], DirAC_mem.reference_power_q[i] ) ) + { + Word32 temp; + + temp = L_shl( reference_power_fx[i], sub( q_reference_power_smooth[i], DirAC_mem.reference_power_q[i] ) ); + test(); + IF( temp == 0 && ( reference_power_fx[i] != 0 ) ) + { + reference_power_fx[i] = 1; + } + ELSE + { + reference_power_fx[i] = temp; + } + move32(); + + DirAC_mem.reference_power_q[i] = q_reference_power_smooth[i]; + move16(); + } + ELSE + { + Word32 temp; + temp = L_shl( reference_power_smooth_fx[i], sub( DirAC_mem.reference_power_q[i], q_reference_power_smooth[i] ) ); + test(); + IF( temp == 0 && ( reference_power_smooth_fx[i] != 0 ) ) + { + reference_power_smooth_fx[i] = 1; + } + ELSE + { + reference_power_smooth_fx[i] = temp; + } + move32(); + q_reference_power_smooth[i] = DirAC_mem.reference_power_q[i]; + move16(); + } + q_reference_power_smooth[i] = sub( q_reference_power_smooth[i], 1 ); + } + v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 ); +#else IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) ) { Word32 temp; @@ -4766,6 +4972,7 @@ void ivas_dirac_dec_render_sf_fx( } 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 ); +#endif } } @@ -4843,6 +5050,21 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867 + FOR( Word16 l = 0; l < size_ho; l++ ) + { + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l], Q26 ) ) + { + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] = Q26; + } + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l], Q26 ) ) + { + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] = Q26; + } + } +#else IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, Q26 ) ) { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth ) ); // Q26 @@ -4853,6 +5075,7 @@ void ivas_dirac_dec_render_sf_fx( { scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size_ho, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); // Q26 } +#endif IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) ) { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) ); // Q31 @@ -4865,6 +5088,20 @@ void ivas_dirac_dec_render_sf_fx( { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) ); // Q31 } +#ifdef FIX_867 + FOR( Word16 l = 0; l < i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); l++ ) + { + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth[l], Q26 ) ) + { + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx[l] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth[l] ) ); // Q26 + } + + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[l], Q26 ) ) + { + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[l] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[l] ) ); // Q26 + } + } +#else IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26 ) ) { scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); // Q26 @@ -4873,10 +5110,28 @@ void ivas_dirac_dec_render_sf_fx( { scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); // Q26 } +#endif IF( NE_16( q_diffuseness_vector, Q30 ) ) { scale_sig32( diffuseness_vector_fx, hSpatParamRendCom->num_freq_bands, sub( Q30, q_diffuseness_vector ) ); // Q30 } +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < size; kk++ ) + { + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk], Q26 ) ) + { + hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk] ) ); // Q26 + } + } + + FOR( Word16 kk = 0; kk < i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ); kk++ ) + { + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk], Q26 ) ) + { + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx[kk] = L_shl( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx[kk], sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk] ) ); // Q26 + } + } +#else IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) ) { scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26 @@ -4885,6 +5140,7 @@ void ivas_dirac_dec_render_sf_fx( { scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26 } +#endif ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, @@ -4896,8 +5152,13 @@ void ivas_dirac_dec_render_sf_fx( diffuseness_vector_fx, hodirac_flag, hDirAC->hConfig->dec_param_estim, +#ifdef FIX_867 + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ); +#else &hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, &hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ); +#endif test(); IF( hDirACRend->hOutSetup.is_loudspeaker_setup && hDirACRend->hoa_decoder != NULL ) @@ -4906,8 +5167,16 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { +#ifdef FIX_867 + FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 + } +#else 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 ) ) ) ); // Q6 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 ) ) ) ); // Q6 +#endif } } } @@ -4917,8 +5186,16 @@ void ivas_dirac_dec_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { +#ifdef FIX_867 + FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 + } +#else 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 ) ) ) ); // Q6 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 ) ) ) ); // Q6 +#endif } } } @@ -4957,6 +5234,41 @@ void ivas_dirac_dec_render_sf_fx( Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); // Q31 } +#ifdef FIX_867 + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + exp = norm_l( reference_power_smooth_fx[i] ); + reference_power_smooth_fx[i] = L_shl( reference_power_smooth_fx[i], exp ); // q_reference_power_smooth + exp + q_reference_power_smooth[i] = add( q_reference_power_smooth[i], exp ); + + IF( LT_16( q_reference_power_smooth[i], hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[i] ) ) + { + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx[i] = L_shl( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx[i], + sub( q_reference_power_smooth[i], hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[i] ) ); // q_reference_power_smooth + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[i] = q_reference_power_smooth[i]; + move16(); + } + ELSE + { + Word32 temp; + temp = L_shl( reference_power_smooth_fx[i], + sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[i], + q_reference_power_smooth[i] ) ); + test(); + IF( temp == 0 && ( reference_power_smooth_fx[i] != 0 ) ) + { + reference_power_smooth_fx[i] = 1; + } + ELSE + { + reference_power_smooth_fx[i] = temp; + } + move32(); + q_reference_power_smooth[i] = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[i]; + move16(); + } + } +#else exp = L_norm_arr( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); // q_reference_power_smooth + exp q_reference_power_smooth = add( q_reference_power_smooth, exp ); @@ -4987,6 +5299,7 @@ void ivas_dirac_dec_render_sf_fx( q_reference_power_smooth = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q; move16(); } +#endif IF( hDirACRend->masa_stereo_type_detect != NULL ) { @@ -5042,7 +5355,25 @@ void ivas_dirac_dec_render_sf_fx( move16(); } } +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < size; kk++ ) + { + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk], Q26 ) ) + { + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx[kk], 1, + sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk] ) ); // Q26 + } + } + FOR( Word16 kk = 0; kk < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ); kk++ ) + { + IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk], Q26 ) ) + { + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx[kk], 1, + sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk] ) ); // Q26 + } + } +#else IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) ) { scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26 @@ -5051,6 +5382,7 @@ void ivas_dirac_dec_render_sf_fx( { scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26 } +#endif IF( hDirACRend->proto_signal_decorr_on ) { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) ); // proto_direct_buffer_f_q @@ -5065,7 +5397,11 @@ void ivas_dirac_dec_render_sf_fx( hSpatParamRendCom->subframe_nbslots[subframe_idx], diffuseness_vector_fx, reference_power_smooth_fx, +#ifdef FIX_867 + q_reference_power_smooth, +#else &q_reference_power_smooth, +#endif qualityBasedSmFactor_fx, hDirAC->hConfig->enc_param_start_band, &q_Cldfb ); @@ -5486,10 +5822,20 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867 + FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[l] = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l]; + move16(); + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[l] = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[l]; + move16(); + } +#else hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; move16(); hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; move16(); +#endif } test(); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 72c32b57a..0e98f3986 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -236,6 +236,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev = (Word16 *) malloc( size * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->cy_cross_dir_smooth_prev_len = size; move16(); IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) @@ -254,6 +260,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ); move16(); @@ -263,6 +275,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->cy_auto_diff_smooth_prev_len = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ); move16(); } @@ -272,6 +290,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->cy_auto_diff_smooth_prev_len = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ); move16(); } @@ -282,6 +306,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->gains_dir_prev_q = (Word16 *) malloc( size * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->gains_dir_prev_len = size; move16(); test(); @@ -291,6 +321,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->gains_diff_prev_q = (Word16 *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->gains_diff_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); move16(); } @@ -309,6 +345,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->gains_diff_prev_q = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif dirac_output_synthesis_state->gains_diff_prev_len = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ); move16(); } @@ -342,8 +384,18 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF( ( dirac_output_synthesis_state->reference_power_smooth_prev_q = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } +#endif set32_fx( dirac_output_synthesis_state->reference_power_smooth_prev_fx, 0, hSpatParamRendCom->num_freq_bands ); +#ifdef FIX_867 + set16_fx( dirac_output_synthesis_state->reference_power_smooth_prev_q, Q31, hSpatParamRendCom->num_freq_bands ); +#else dirac_output_synthesis_state->reference_power_smooth_prev_q = Q31; +#endif move16(); IF( ( dirac_output_synthesis_state->direction_smoothness_prev_fx = (Word32 *) malloc( hSpatParamRendCom->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) @@ -825,8 +877,13 @@ void ivas_dirac_dec_output_synthesis_init_fx( IF( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx != NULL ) { set32_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); +#ifdef FIX_867 + set16_fx( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev = 0; +#endif move16(); IF( hodirac_flag ) @@ -838,22 +895,37 @@ void ivas_dirac_dec_output_synthesis_init_fx( size = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ); } set32_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx, 0, size ); +#ifdef FIX_867 + set16_zero_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev, size ); +#else h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev = 0; +#endif move16(); IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { set32_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, imult1616( h_dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ) ); +#ifdef FIX_867 + set16_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev, 0, imult1616( h_dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ) ); +#endif } ELSE IF( NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) { set32_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); +#ifdef FIX_867 + set16_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ); +#endif } ELSE { set32_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); +#ifdef FIX_867 + set16_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = 0; +#endif move16(); IF( h_dirac_output_synthesis_state->proto_power_smooth_prev_fx != NULL ) @@ -863,8 +935,12 @@ void ivas_dirac_dec_output_synthesis_init_fx( move16(); } set32_fx( h_dirac_output_synthesis_state->gains_dir_prev_fx, 0, size ); +#ifdef FIX_867 + set16_zero_fx( h_dirac_output_synthesis_state->gains_dir_prev_q, h_dirac_output_synthesis_state->gains_dir_prev_len ); +#else h_dirac_output_synthesis_state->gains_dir_prev_q = 0; move16(); +#endif IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { @@ -873,6 +949,9 @@ void ivas_dirac_dec_output_synthesis_init_fx( ELSE { set32_fx( h_dirac_output_synthesis_state->gains_diff_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); +#ifdef FIX_867 + set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); +#endif } h_dirac_output_synthesis_state->gains_diff_prev_q = 0; move16(); @@ -1326,9 +1405,13 @@ void ivas_dirac_dec_output_synthesis_process_slot( } #else void ivas_dirac_dec_output_synthesis_process_slot_fx( - const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ + const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ +#ifdef FIX_867 + const Word16 *q_reference_power, /* i : Estimated power Q */ +#else const Word16 q_reference_power, /* i : Estimated power Q */ - const Word32 *onset, /* i : onset filter Q31*/ +#endif + const Word32 *onset, /* i : onset filter Q31*/ const Word16 *azimuth, const Word16 *elevation, const Word32 *diffuseness, /* Q(q_diffuseness)*/ @@ -1509,8 +1592,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { +#ifdef FIX_867 + Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk]; + move16(); +#else Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); +#endif } FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) @@ -1540,7 +1628,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) { b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], 232831 /* EPSILON in exp 63 */, &b_exp ); +#ifdef FIX_867 + b_exp = add( b_exp, sub( sub( 31, q_reference_power[k + num_freq_bands] ), 63 ) ); +#else b_exp = add( b_exp, sub( sub( 31, q_reference_power ), 63 ) ); +#endif } ELSE { @@ -1580,6 +1672,23 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { +#ifdef FIX_867 + IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], + sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; + move16(); + } +#else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ @@ -1593,6 +1702,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } +#endif h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx*/ move32(); } @@ -1620,7 +1730,11 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) { b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], 232831 /* EPSILON in exp 63 */, &b_exp ); +#ifdef FIX_867 + b_exp = add( b_exp, sub( sub( 31, q_reference_power[k + num_freq_bands] ), 63 ) ); +#else b_exp = add( b_exp, sub( sub( 31, q_reference_power ), 63 ) ); +#endif } ELSE { @@ -1660,6 +1774,24 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { +#ifdef FIX_867 + IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; + move16(); + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); +#else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ @@ -1675,6 +1807,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); +#endif } ELSE { @@ -1700,6 +1833,23 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { +#ifdef FIX_867 + IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; + move16(); + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); +#else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ @@ -1715,6 +1865,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); +#endif } ELSE { @@ -1733,6 +1884,21 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) { +#ifdef FIX_867 + IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; + move16(); + } +#else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ @@ -1746,6 +1912,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } +#endif h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } @@ -1766,16 +1933,37 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { temp = s_min( Q_temp_cy_cross_dir_smooth_fx[kk], temp ); } +#ifndef FIX_867 h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp; +#endif move16(); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ move32(); +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = temp; +#endif } free( Q_temp_cy_cross_dir_smooth_fx ); /*Directional gain (panning)*/ Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < tmp16; kk++ ) + { + IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] ) ) + { + + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = + L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], + sub( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ + move32(); + + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = temp_q; + move16(); + } + } +#else IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { FOR( Word16 kk = 0; kk < tmp16; kk++ ) @@ -1786,6 +1974,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); } +#endif FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { v_mult_fixed( h_dirac_output_synthesis_state->direct_power_factor_fx, @@ -1793,10 +1982,21 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( aux_buf, num_freq_bands ); /*temp_q*/ +#ifdef FIX_867 + FOR( Word16 k = 0; k < num_freq_bands; k++ ) + { + IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) + { + Scale_sig32( &aux_buf[ch_idx * num_freq_bands + k], 1, sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], temp_q ) ); + /*temp_q->(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ + } + } +#else IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) { Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } +#endif v_add_fixed( aux_buf, &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], @@ -1812,10 +2012,20 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( aux_buf, num_freq_bands_diff ); /* h_dirac_output_synthesis_state->diffuse_power_factor_q+15-15*/ temp_q = h_dirac_output_synthesis_state->diffuse_power_factor_q; +#ifdef FIX_867 + FOR( Word16 k = 0; k < num_freq_bands; k++ ) + { + IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[ch_idx * num_freq_bands + k] ) ) + { + Scale_sig32( &aux_buf[ch_idx * num_freq_bands + k], 1, sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[ch_idx * num_freq_bands + k], temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth)*/ + } + } +#else IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ) { Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth)*/ } +#endif v_add_fixed( aux_buf, &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], @@ -1851,11 +2061,19 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( hDirACRend->proto_index_diff, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power, +#ifdef FIX_867 + q_reference_power, +#else &q_reference_power, +#endif h_dirac_output_synthesis_state->diffuse_responses_square_fx, onset, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#else &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#endif diff_start_band = h_dirac_output_synthesis_params->max_band_decorr; move16(); @@ -1864,9 +2082,14 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( /* process other PSDs only slot wise for 4 transport channels */ IF( EQ_16( dec_param_estim, TRUE ) ) { +#ifdef FIX_867 + computeTargetPSDs_direct_fx( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_state->direct_power_factor_fx, reference_power, q_reference_power, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); + computeTargetPSDs_diffuse_fx( num_channels_dir, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power, q_reference_power, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#else computeTargetPSDs_direct_fx( num_channels_dir, num_freq_bands, h_dirac_output_synthesis_state->direct_power_factor_fx, reference_power, &q_reference_power, h_dirac_output_synthesis_state->direct_responses_fx, h_dirac_output_synthesis_state->direct_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, &h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); computeTargetPSDs_diffuse_fx( num_channels_dir, num_freq_bands, diff_start_band, h_dirac_output_synthesis_state->diffuse_power_factor_fx, reference_power, &q_reference_power, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#endif } return; @@ -1962,8 +2185,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Sqrt32( L_add( ONE_IN_Q26 /*1 in Q26*/, h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] ), &exp ); // (Q31 - exp) move32(); +#ifdef FIX_867 + // Scale to bring in common Q-factor + q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], sub( Q31, exp ) ); + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] = L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l], sub( q_com, sub( Q31, exp ) ) ); /*Q( Q31- exp)->q_com*/ + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l] = L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l], sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ +#endif } +#ifndef FIX_867 // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, sub( Q31, exp ) ); Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], @@ -1972,6 +2204,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ +#endif } /*Directional gain*/ @@ -1999,6 +2232,36 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], //(Q30, Q31) -> Q30 num_freq_bands ); +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands; l++ ) + { + q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[l], Q30 ); + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] = + L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l], sub( q_com, Q30 ) ); /*Q30->q_com*/ + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l] = + L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l], sub( q_com, Q30 ) ); + /*Q30->q_com*/ + + h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l] = q_com; + move16(); + + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l] = + L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l], sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ); + /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ + h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] = q_com; + move16(); + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l] = + L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l], + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l] ) ); + + /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ + h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir + l] = q_com; + move16(); + } +#else // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q30 ); Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], @@ -2013,12 +2276,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + num_freq_bands * num_channels_dir], num_freq_bands, sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state.q_cy_cross_dir_smooth = q_com; move16(); h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev = q_com; move16(); +#endif /*Diffuse gain*/ FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) @@ -2029,6 +2295,24 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( num_freq_bands_diff ); // Scale to bring in common Q-factor +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands_diff; l++ ) + { + q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l], Q31 ); + + h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l] = + L_shl( h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l], sub( q_com, Q31 ) ); /*q31->q_com*/ + + h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff + l] = + L_shl( h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff + l], sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l] ) ); + /* h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ + + h_dirac_output_synthesis_state.q_cy_auto_diff_smooth[ch_idx * num_freq_bands_diff + l] = q_com; + move16(); + h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l] = q_com; + move16(); + } +#else q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, Q31 ); Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, @@ -2036,12 +2320,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /* h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state.q_cy_auto_diff_smooth = q_com; move16(); h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev = q_com; move16(); +#endif } ELSE IF( EQ_16( dec_param_estim, FALSE ) ) { @@ -2068,8 +2355,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Sqrt32( L_add( ONE_IN_Q26, h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] ), &exp ); // (Q31 - exp) move32(); +#ifdef FIX_867 + // Scale to bring in common Q-factor + q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], sub( Q31, exp ) ); + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] = L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l], + sub( q_com, sub( Q31, exp ) ) ); /*( Q31- exp )->q_com*/ + h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l] = L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l], + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ +#endif } +#ifndef FIX_867 // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, sub( Q31, exp ) ); Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], @@ -2078,6 +2374,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ +#endif } /*Directional gain*/ @@ -2088,6 +2385,26 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 num_freq_bands ); +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands; l++ ) + { + // Scale to bring in common Q-factor + q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], Q31 ); + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l] = + L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + l], + sub( q_com, Q31 ) ); /*q31->q_com*/ + + h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l] = + L_shl( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands + l], + sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ + + h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx * num_freq_bands + l] = q_com; + move16(); + h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] = q_com; + move16(); + } +#else // Scale to bring in common Q-factor q_com = s_min( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, Q31 ); Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], @@ -2096,12 +2413,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Scale_sig32( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx[ch_idx * num_freq_bands], num_freq_bands, sub( q_com, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev->q_com*/ +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state.q_cy_cross_dir_smooth = q_com; move16(); h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev = q_com; move16(); +#endif /*Diffuse gain*/ FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) @@ -2112,19 +2432,41 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( num_freq_bands_diff ); // Scale to bring in common Q-factor +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands_diff; l++ ) + { + q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l], Q31 ); + + h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l] = L_shl( h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l], + sub( q_com, Q31 ) ); /*q31->q_com*/ + + h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff + l] = + L_shl( h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff + l], + sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l] ) ); /*h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ + + h_dirac_output_synthesis_state.q_cy_auto_diff_smooth[ch_idx * num_freq_bands_diff + l] = q_com; + move16(); + + h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l] = q_com; + move16(); + } +#else q_com = s_min( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, Q31 ); Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, sub( q_com, Q31 ) ); /*q31->q_com*/ Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ + sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state.q_cy_auto_diff_smooth = q_com; move16(); h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev = q_com; move16(); +#endif } /*-----------------------------------------------------------------* @@ -2141,12 +2483,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q - g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q +#ifdef FIX_867 // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ) ); // p_gains_dir_q + g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 1 ) ) ) ); // p_gains_dir_q +#else + g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q +#endif + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2157,12 +2504,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q - g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q +#ifdef FIX_867 // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ) ); // p_gains_dir_q + g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 1 ) ) ) ); // p_gains_dir_q +#else + g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q +#endif + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2173,12 +2525,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q +#ifdef FIX_867 + g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_dir_q + g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_dir_q +#else + g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q + g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q +#endif + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2203,12 +2560,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q +#ifdef FIX_867 // (p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_dir_q + g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_dir_q +#else g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q - *( p_gains_dir++ ) = g2; // p_gains_dir_q +#endif + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -2223,11 +2585,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { g1 = POINT_1175_Q31; // Q31 move32(); - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, 0 ); // p_gains_diff_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ), Q5 ) ) ); // p_gains_diff_q - *( p_gains_diff++ ) = g2; // p_gains_diff_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, 0 ); // p_gains_diff_q +#ifdef FIX_867 // p_gains_diff_q + g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_diff_q +#else + g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ), Q5 ) ) ); // p_gains_diff_q +#endif + *( p_gains_diff++ ) = g2; // p_gains_diff_q move32(); } } @@ -2246,9 +2612,23 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir_prev = h_dirac_output_synthesis_state.gains_dir_prev_fx; FOR( ch_idx = 0; ch_idx < num_channels_dir; ch_idx++ ) { +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands; l++ ) + { + h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands + l] = + L_shl( h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands + l], + sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], + h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + 1] ) ); + /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ + + h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + l] = + h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l]; + } +#else Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], num_freq_bands, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#endif } h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); @@ -2320,10 +2700,18 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir++; p_gains_dir_prev++; +#ifdef FIX_867 + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + move32(); + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + move32(); +#else + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); +#endif } } } @@ -2351,10 +2739,17 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_dir++; p_gains_dir_prev++; +#ifdef FIX_867 + output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + move32(); + output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) + move32(); +#else output_real[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); output_imag[l * num_channels_dir + ch_idx] = L_shl( *( p_proto++ ), sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 31 ) ); // p_proto_dir_q -> (p_gains_dir_q + p_proto_dir_q - 31) move32(); +#endif } } } @@ -2365,12 +2760,28 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( p_gains_diff_prev = h_dirac_output_synthesis_state.gains_diff_prev_fx + i_mult( nchan_transport_foa, num_freq_bands_diff ); FOR( ch_idx = nchan_transport_foa; ch_idx < num_channels_diff; ch_idx++ ) { +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands; l++ ) + { + h_dirac_output_synthesis_state.gains_diff_prev_fx[ch_idx * num_freq_bands_diff + l] = + L_shl( h_dirac_output_synthesis_state.gains_diff_prev_fx[ch_idx * num_freq_bands_diff + l], + sub( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l], + h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx * num_freq_bands_diff + l] ) ); + /*h_dirac_output_synthesis_state.gains_diff_prev_q->h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev*/ + + h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx * num_freq_bands_diff + l] = + h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands_diff + l]; + } +#else Scale_sig32( &h_dirac_output_synthesis_state.gains_diff_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, sub( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev, h_dirac_output_synthesis_state.gains_diff_prev_q ) ); /*h_dirac_output_synthesis_state.gains_diff_prev_q->h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev*/ +#endif } +#ifndef FIX_867 h_dirac_output_synthesis_state.gains_diff_prev_q = h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev; move16(); +#endif ch_idx_diff = nchan_transport_foa; move16(); @@ -2469,17 +2880,39 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( IF( hodirac_flag ) { Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) * DIRAC_HO_NUMSECTORS ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#ifdef FIX_867 + FOR( l = 0; l < imult1616( num_freq_bands, num_channels_dir ) * DIRAC_HO_NUMSECTORS; l++ ) + { + q_cy_cross_dir_smooth_prev[l] = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[l]; + } +#endif } ELSE { Copy32( h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx, h_dirac_output_synthesis_state.gains_dir_prev_fx, imult1616( num_freq_bands, num_channels_dir ) ); /*h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#ifdef FIX_867 + FOR( l = 0; l < imult1616( num_freq_bands, num_channels_dir ); l++ ) + { + q_cy_cross_dir_smooth_prev[l] = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[l]; + } +#endif } +#ifndef FIX_867 *q_cy_cross_dir_smooth_prev = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; +#endif move16(); Copy32( h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx, h_dirac_output_synthesis_state.gains_diff_prev_fx, imult1616( num_freq_bands_diff, num_channels_diff ) ); /* h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev*/ +#ifdef FIX_867 + FOR( l = 0; l < imult1616( num_freq_bands_diff, num_channels_diff ); l++ ) + { + q_cy_auto_diff_smooth_prev[l] = h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[l]; + move16(); + } +#else *q_cy_auto_diff_smooth_prev = h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev; move16(); +#endif /* reset values */ IF( hodirac_flag ) @@ -2966,7 +3399,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word32 *p_gains_dir, *p_gains_diff; Word32 g, g1, g2; Word32 *p_cy_auto_dir_smooth, *p_cy_auto_dir_smooth_prev; +#ifdef FIX_867 + Word16 q_cy_auto_dir_smooth_local[CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; + Word16 q_cy_auto_dir_smooth_prev_local[CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; +#else Word16 q_cy_auto_dir_smooth_local[MAX_OUTPUT_CHANNELS], q_cy_auto_dir_smooth_prev_local[MAX_OUTPUT_CHANNELS]; +#endif Word32 *p_cy_cross_dir_smooth, *p_cy_cross_dir_smooth_prev; Word32 *p_cy_auto_diff_smooth, *p_cy_auto_diff_smooth_prev; Word32 gains_dir[CLDFB_NO_CHANNELS_MAX * MAX_OUTPUT_CHANNELS]; @@ -3010,7 +3448,24 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); num_freq_bands = hSpatParamRendCom->num_freq_bands; move16(); +#ifdef FIX_867 + IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) + { + nchan_target_psds = 2; + move16(); + } + ELSE + { + nchan_target_psds = nchan_out_woLFE; + move16(); + } + FOR( l = 0; l < nchan_target_psds * num_freq_bands; l++ ) + { + q_cy_auto_dir_smooth_local[l] = h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[l]; + } +#else set16_fx( q_cy_auto_dir_smooth_local, h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, nchan_out_woLFE ); +#endif /*-----------------------------------------------------------------* * compute target PSDs @@ -3048,11 +3503,42 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, q_cy_auto_dir_smooth_local, h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); +#else &h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); +#endif // Scale cy_auto_diff_smooth_fx if required IF( diff_start_band != 0 ) { +#ifdef FIX_867 + FOR( l = 0; l < num_freq_bands; l++ ) + { + q_com = s_min( q_reference_power_smooth[l], h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[l] ); + + reference_power_smooth[l] = L_shl( reference_power_smooth[l], sub( q_com, q_reference_power_smooth[l] ) ); /**q_reference_power_smooth->q_com*/ + h_dirac_output_synthesis_state->reference_power_smooth_prev_fx[l] = + L_shl( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx[l], sub( q_com, q_reference_power_smooth[l] ) ); + /**q_reference_power_smooth->q_com*/ + + FOR( Word16 i_ch = 0; i_ch < nchan_target_psds; i_ch++ ) + { + h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[num_freq_bands * i_ch + l] = + L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[num_freq_bands * i_ch + l], + sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[num_freq_bands * i_ch + l] ) ); + /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/ + + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[num_freq_bands * i_ch + l] = q_com; + move16(); + } + + q_reference_power_smooth[l] = q_com; + move16(); + h_dirac_output_synthesis_state->reference_power_smooth_prev_q[l] = q_com; + move16(); + } +#else q_com = s_min( *q_reference_power_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); scale_sig32( reference_power_smooth, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); /**q_reference_power_smooth->q_com*/ scale_sig32( h_dirac_output_synthesis_state->reference_power_smooth_prev_fx, num_freq_bands, sub( q_com, *q_reference_power_smooth ) ); /**q_reference_power_smooth->q_com*/ @@ -3066,6 +3552,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = q_com; move16(); +#endif } computeTargetPSDs_diffuse_subframe_fx( nchan_target_psds, num_freq_bands, diff_start_band, @@ -3074,7 +3561,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( q_reference_power_smooth, h_dirac_output_synthesis_state->diffuse_responses_square_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#else &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#endif } /*-----------------------------------------------------------------* @@ -3087,7 +3578,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( p_cy_auto_dir_smooth = h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx; // q_cy_auto_dir_smooth p_cy_auto_diff_smooth = h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx; // q_cy_auto_diff_smooth +#ifdef FIX_867 + q_com = s_min( q_cy_auto_dir_smooth_local[num_freq_bands], h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[num_freq_bands] ); +#else q_com = s_min( q_cy_auto_dir_smooth_local[1], h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ); +#endif IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) ) { @@ -3095,9 +3590,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); exp1 = 0; move16(); +#ifdef FIX_867 + tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[num_freq_bands] ) ), + ( L_add( Sqrt32( h_dirac_output_synthesis_state->direct_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp) + &exp1 ); +#else tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[1] ) ), ( L_add( Sqrt32( h_dirac_output_synthesis_state->direct_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp) &exp1 ); +#endif target_power_y = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp)) q_target_power_y = add( sub( Q31, exp1 ), sub( q_com, sub( Q31, exp ) ) ); q_target_power_y = sub( q_target_power_y, 1 ); @@ -3106,9 +3607,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); exp1 = 0; move16(); +#ifdef FIX_867 + tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[num_freq_bands] ) ), + ( L_add( Sqrt32( h_dirac_output_synthesis_state->diffuse_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp) + &exp1 ); +#else tmp32 = BASOP_Util_Divide3232_Scale_cadence( L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ), ( L_add( Sqrt32( h_dirac_output_synthesis_state->diffuse_power_factor_fx[0], &exp ), EPSILON_FX ) ), // (Q31 - exp) &exp1 ); +#endif target_power_y1 = L_shr( tmp32, 1 ); // Q31 + (q_com - (31 - exp)) q_target_power_y1 = add( sub( Q31, exp1 ), sub( q_com, sub( Q31, exp ) ) ); q_target_power_y1 = sub( q_target_power_y1, 1 ); @@ -3118,9 +3625,15 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } ELSE { +#ifdef FIX_867 + target_power_y = L_add( + L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[num_freq_bands] ) ), + L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[num_freq_bands] ) ) ); // q_com +#else target_power_y = L_add( L_shl( p_cy_auto_dir_smooth[num_freq_bands], sub( q_com, q_cy_auto_dir_smooth_local[1] ) ), L_shl( p_cy_auto_diff_smooth[num_freq_bands], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ) ); // q_com +#endif exp = q_com; move16(); } @@ -3319,6 +3832,28 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( p_cy_auto_dir_smooth = h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx; p_cy_auto_dir_smooth_prev = h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx; +#ifdef FIX_867 + FOR( k = 0; k < nchan_target_psds; k++ ) + { + FOR( l = 0; l < num_freq_bands; l++ ) + { + q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] = norm_l( p_cy_auto_dir_smooth_prev[k * num_freq_bands + l] ); + move16(); + + p_cy_auto_dir_smooth_prev[k * num_freq_bands + l] = L_shl( p_cy_auto_dir_smooth_prev[k * num_freq_bands + l], q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] ); /*q_cy_auto_dir_smooth_prev_local[k]+h_dirac_output_synthesis_state -> q_cy_auto_dir_smooth_prev*/ + q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] = add( q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l], h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev[k * num_freq_bands + l] ); + move16(); + + q_com = s_min( q_cy_auto_dir_smooth_local[k * num_freq_bands + l], q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] ); + p_cy_auto_dir_smooth[k * num_freq_bands + l] = L_shl( p_cy_auto_dir_smooth[k * num_freq_bands + l], sub( q_com, q_cy_auto_dir_smooth_local[k * num_freq_bands + l] ) ); /*q_cy_auto_dir_smooth_local -> q_com*/ + p_cy_auto_dir_smooth_prev[k * num_freq_bands + l] = L_shl( p_cy_auto_dir_smooth_prev[k * num_freq_bands + l], sub( q_com, q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] ) ); /*q_cy_auto_dir_smooth_prev_local -> q_com*/ + + q_cy_auto_dir_smooth_local[k * num_freq_bands + l] = q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] = q_com; + move16(); + move16(); + } + } +#else FOR( k = 0; k < nchan_out_woLFE; k++ ) { q_cy_auto_dir_smooth_prev_local[k] = getScaleFactor32( p_cy_auto_dir_smooth_prev + imult1616( k, num_freq_bands ), num_freq_bands ); @@ -3333,25 +3868,55 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); move16(); } +#endif p_cy_cross_dir_smooth = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx; p_cy_cross_dir_smooth_prev = h_dirac_output_synthesis_state->cy_cross_dir_smooth_prev_fx; +#ifdef FIX_867 + for ( Word16 kk = 0; kk < imult1616( nchan_target_psds, num_freq_bands ); kk++ ) + { + q_com = s_min( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk], h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev[kk] ); + + p_cy_cross_dir_smooth[kk] = L_shl( p_cy_cross_dir_smooth[kk], sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth -> q_com*/ + p_cy_cross_dir_smooth_prev[kk] = L_shl( p_cy_cross_dir_smooth_prev[kk], sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev[kk] ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev -> q_com*/ + + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev[kk] = q_com; + move16(); + move16(); + } +#else q_com = s_min( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev ); scale_sig32( p_cy_cross_dir_smooth, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth -> q_com*/ scale_sig32( p_cy_cross_dir_smooth_prev, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev -> q_com*/ h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth_prev = q_com; move16(); move16(); +#endif p_cy_auto_diff_smooth = h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx; p_cy_auto_diff_smooth_prev = h_dirac_output_synthesis_state->cy_auto_diff_smooth_prev_fx; +#ifdef FIX_867 + for ( Word16 kk = 0; kk < imult1616( nchan_out_woLFE, num_freq_bands ); kk++ ) + { + q_com = s_min( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk], h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev[kk] ); + + p_cy_auto_diff_smooth[kk] = L_shl( p_cy_auto_diff_smooth[kk], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/ + p_cy_auto_diff_smooth_prev[kk] = L_shl( p_cy_auto_diff_smooth_prev[kk], sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev[kk] ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev -> q_com*/ + + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev[kk] = q_com; + + move16(); + move16(); + } +#else q_com = s_min( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ); scale_sig32( p_cy_auto_diff_smooth, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/ scale_sig32( p_cy_auto_diff_smooth_prev, imult1616( nchan_out_woLFE, num_freq_bands ), sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev -> q_com*/ h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = q_com; move16(); move16(); +#endif FOR( k = 0; k < nchan_out_woLFE; k++ ) { @@ -3372,14 +3937,24 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) L_tmp = Mpy_32_32( power_smooth_temp, ( *( p_cy_auto_dir_smooth_prev++ ) ) ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 +#ifdef FIX_867 + exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), + q_cy_auto_dir_smooth_prev_local[num_freq_bands * k + l] ), + Q31 ) ); +#else exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), q_cy_auto_dir_smooth_prev_local[k] ), Q31 ) ); +#endif p_power_smooth++; *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) move32(); +#ifdef FIX_867 + *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_dir_prev_q +#else *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q, sub( Q31, exp ) ) ); // gains_dir_prev_q +#endif move32(); IF( *( p_gains_dir ) < 0 ) @@ -3387,11 +3962,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_dir ) = 0; move32(); } +#ifdef FIX_867 + ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l] ) ), Q5 ) ) ) ) + { + *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l] ) ), Q5 ) ); /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/ + move32(); + } +#else + ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) { *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/ move32(); } +#endif IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 ) { @@ -3412,11 +3996,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( exp = 0; move16(); L_tmp = BASOP_Util_Divide3232_Scale_cadence( *( p_cy_auto_diff_smooth_prev++ ), ( *( p_power_diff_smooth_prev++ ) ), &exp ); // (Q31 - exp) + (q_a - q_b) +#ifdef FIX_867 + exp = sub( Q31, add( sub( Q31, exp ), sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev[k * num_freq_bands + l], h_dirac_output_synthesis_state->proto_power_diff_smooth_q ) ) ); +#else exp = sub( Q31, add( sub( Q31, exp ), sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev, h_dirac_output_synthesis_state->proto_power_diff_smooth_q ) ) ); +#endif *( p_gains_diff ) = Sqrt32( L_tmp, &exp ); // (31 - exp) move32(); - *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q +#ifdef FIX_867 + *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_diff_prev_q +#else + *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q +#endif move32(); IF( *( p_gains_diff ) < 0 ) @@ -3424,11 +4016,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_diff ) = 0; move32(); } +#ifdef FIX_867 + ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l] ) ), Q5 ) ) ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ + { + *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l] ) ), Q5 ) ); /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ + move32(); + } + +#else ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ { *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ move32(); } +#endif p_gains_diff++; } @@ -3464,7 +4065,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) move32(); - *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q, sub( Q31, exp ) ) ); // gains_dir_prev_q +#ifdef FIX_867 + *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_dir_prev_q +#else + *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q, sub( Q31, exp ) ) ); // gains_dir_prev_q +#endif move32(); IF( *( p_gains_dir ) < 0 ) @@ -3472,17 +4077,27 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_dir ) = 0; move32(); } +#ifdef FIX_867 + ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l] ) ), Q5 ) ) ) ) /*gains_dir_prev_q*/ + { + *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l] ) ), Q5 ) ); /*gains_dir_prev_q*/ + move32(); + } + +#else ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) /*gains_dir_prev_q*/ { *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*gains_dir_prev_q*/ move32(); } +#endif IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 ) { *( p_gains_dir ) = L_negate( *( p_gains_dir ) ); /*gains_dir_prev_q*/ move32(); } + p_gains_dir++; /*diffuse*/ @@ -3509,14 +4124,26 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); } ( p_cy_auto_diff_smooth_prev++ ); +#ifdef FIX_867 + exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev[k * num_freq_bands + l] ), + Q31 ) ); + + +#else exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), h_dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev ), Q31 ) ); +#endif p_power_smooth++; *( p_gains_diff ) = Sqrt32( L_tmp, &exp ); /*31-exp*/ move32(); - *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q +#ifdef FIX_867 + *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_diff_prev_q +#else + *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q +#endif move32(); IF( *( p_gains_diff ) < 0 ) @@ -3524,11 +4151,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_diff ) = 0; move32(); } +#ifdef FIX_867 + ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l] ) ), Q5 ) ) ) ) // gains_diff_prev_q + { + *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l] ) ), Q5 ) ); // gains_diff_prev_q + move32(); + } + +#else ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) // gains_diff_prev_q { *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); // gains_diff_prev_q move32(); } +#endif p_gains_diff++; } } @@ -3628,6 +4264,24 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } } q_align = W_norm( W_temp ); +#ifdef FIX_867 + Word16 tmp_min; + minimum_s( h_dirac_output_synthesis_state->gains_dir_prev_q, nchan_out_woLFE * num_freq_bands, &tmp_min ); + FOR( buf_idx = 0; buf_idx < nbslots; ++buf_idx ) + { + FOR( k = 0; k < nchan_out_woLFE; k++ ) + { + FOR( l = 0; l < num_freq_bands; l++ ) + { + RealBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_RealBuffer64_fx[k][buf_idx][l], q_align - h_dirac_output_synthesis_state->gains_dir_prev_q[l] + tmp_min ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ + move32(); + ImagBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_ImagBuffer64_fx[k][buf_idx][l], q_align - h_dirac_output_synthesis_state->gains_dir_prev_q[l] + tmp_min ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ + move32(); + } + } + } + *q_Cldfb = sub( add( add( h_dirac_output_synthesis_state->proto_direct_buffer_f_q, tmp_min ), q_align ), 32 ); +#else FOR( buf_idx = 0; buf_idx < nbslots; ++buf_idx ) { FOR( k = 0; k < nchan_out_woLFE; k++ ) @@ -3643,6 +4297,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } *q_Cldfb = sub( add( add( h_dirac_output_synthesis_state->proto_direct_buffer_f_q, h_dirac_output_synthesis_state->gains_dir_prev_q ), q_align ), 32 ); +#endif move16(); /*-----------------------------------------------------------------* @@ -3659,13 +4314,41 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { set_zero_fx( h_dirac_output_synthesis_state->proto_power_diff_smooth_fx, h_dirac_output_synthesis_params->max_band_decorr * nchan_out_woLFE ); } +#ifdef FIX_867 + FOR( k = 0; k < nchan_out_woLFE; k++ ) + { + Word16 min_tmp; + minimum_fx( &q_cy_auto_dir_smooth_prev_local[k * num_freq_bands], num_freq_bands, &min_tmp ); + FOR( l = 0; l < num_freq_bands; l++ ) + { + h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx[k * num_freq_bands + l] = + L_shl( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx[k * num_freq_bands + l], sub( min_tmp, q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l] ) ); + + h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev[l] = min_tmp; + } + } + +#else minimum_fx( q_cy_auto_dir_smooth_prev_local, nchan_out_woLFE, &h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev ); FOR( k = 0; k < nchan_out_woLFE; k++ ) { scale_sig32( h_dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx + ( k * num_freq_bands ), num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev, q_cy_auto_dir_smooth_prev_local[k] ) ); /*q_cy_auto_dir_smooth_prev_local[k] -> h_dirac_output_synthesis_state->q_cy_auto_dir_smooth_prev*/ } +#endif + +#ifdef FIX_867 + set_zero_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); + set16_zero_fx( h_dirac_output_synthesis_state->q_cy_auto_dir_smooth, imult1616( num_freq_bands, nchan_out_woLFE ) ); + move16(); + set_zero_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); + set16_zero_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, imult1616( num_freq_bands, nchan_out_woLFE ) ); + move16(); + set_zero_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); + set16_zero_fx( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, imult1616( num_freq_bands, nchan_out_woLFE ) ); + move16(); +#else set_zero_fx( h_dirac_output_synthesis_state->cy_auto_dir_smooth_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); h_dirac_output_synthesis_state->q_cy_auto_dir_smooth = 0; move16(); @@ -3675,6 +4358,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( set_zero_fx( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_freq_bands, nchan_out_woLFE ) ); h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = 0; move16(); +#endif pop_wmops(); @@ -5977,14 +6661,38 @@ static void computeTargetPSDs_direct_fx( /* estimate direct and diffuse power */ v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifndef FIX_867 Word16 common1_q = s_min( *q_cy_auto_dir_smooth, *q_reference_power ); Word16 common2_q = s_min( *q_cy_cross_dir_smooth, *q_reference_power ); +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); +#ifdef FIX_867 + FOR( Word16 l = 0; l < num_freq_bands; l++ ) + { + Word16 common1_q = s_min( q_cy_auto_dir_smooth[cur_idx + l], q_reference_power[l] ); + Word16 common2_q = s_min( q_cy_cross_dir_smooth[cur_idx + l], q_reference_power[l] ); + v_mult_fixed( direct_power, &direct_responses_square[cur_idx + l], aux_buffer_res, 1 ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + scale_sig32( &aux_buffer_res[l], 1, sub( common1_q, q_reference_power[l] ) ); /* Q(common1_q) */ + scale_sig32( &cy_auto_dir_smooth[cur_idx + l], 1, sub( common1_q, q_cy_auto_dir_smooth[cur_idx + l] ) ); /* Q(common1_q) */ + v_add_fixed( &cy_auto_dir_smooth[cur_idx + l], &aux_buffer_res[l], &cy_auto_dir_smooth[cur_idx + l], 1, Q1 ); /* Q(common1_q) - Q1 */ + + v_mult_fixed( direct_power, &direct_responses[cur_idx + l], &aux_buffer_res[l], 1 ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + scale_sig32( &aux_buffer_res[l], 1, sub( common2_q, q_reference_power[l] ) ); /* Q(common2_q) */ + scale_sig32( &cy_cross_dir_smooth[cur_idx + l], 1, sub( common2_q, q_cy_cross_dir_smooth[cur_idx + l] ) ); /* Q(common2_q) */ + v_add_fixed( &cy_cross_dir_smooth[cur_idx + l], &aux_buffer_res[l], &cy_cross_dir_smooth[cur_idx + l], 1, Q1 ); /* Q(common2_q) - Q1 */ + + /* Q adjustment */ + q_cy_auto_dir_smooth[cur_idx + l] = sub( common1_q, Q1 ); + move16(); + q_cy_cross_dir_smooth[cur_idx + l] = sub( common2_q, Q1 ); + move16(); + } +#else v_mult_fixed( direct_power, &direct_responses_square[cur_idx], aux_buffer_res, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ scale_sig32( aux_buffer_res, num_freq_bands, sub( common1_q, *q_reference_power ) ); /* Q(common1_q) */ scale_sig32( &cy_auto_dir_smooth[cur_idx], num_freq_bands, sub( common1_q, *q_cy_auto_dir_smooth ) ); /* Q(common1_q) */ @@ -5994,13 +6702,16 @@ static void computeTargetPSDs_direct_fx( scale_sig32( aux_buffer_res, num_freq_bands, sub( common2_q, *q_reference_power ) ); /* Q(common2_q) */ scale_sig32( &cy_cross_dir_smooth[cur_idx], num_freq_bands, sub( common2_q, *q_cy_cross_dir_smooth ) ); /* Q(common2_q) */ v_add_fixed( &cy_cross_dir_smooth[cur_idx], aux_buffer_res, &cy_cross_dir_smooth[cur_idx], num_freq_bands, Q1 ); /* Q(common2_q) - Q1 */ +#endif } +#ifndef FIX_867 /* Q adjustment */ *q_cy_auto_dir_smooth = sub( common1_q, Q1 ); move16(); *q_cy_cross_dir_smooth = sub( common2_q, Q1 ); move16(); +#endif return; } @@ -6095,13 +6806,24 @@ static void computeTargetPSDs_direct_subframe_fx( { cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power+q_tmp*/ move32(); +#ifdef FIX_867 + q_cy_auto_dir_smooth[cur_idx + i] = add( q_reference_power[i], q_tmp ); + move16(); + + q_cy_cross_dir_smooth[cur_idx + i] = q_reference_power[i]; + move16(); +#endif } +#ifndef FIX_867 q_cy_auto_dir_smooth[ch_idx] = add( *q_reference_power, q_tmp ); move16(); +#endif v_mult_fixed( direct_power, &direct_responses[cur_idx], &cy_cross_dir_smooth[cur_idx], num_freq_bands ); // (q_reference_power, Q31) -> q_reference_power } +#ifndef FIX_867 *q_cy_cross_dir_smooth = *q_reference_power; +#endif move16(); return; @@ -6160,22 +6882,42 @@ static void computeTargetPSDs_diffuse_fx( /* estimate direct and diffuse power */ v_mult_fixed( diffuse_power_factor, reference_power, diffuse_power, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ +#ifndef FIX_867 Word16 common_q = s_min( *q_cy_auto_diff_smooth, *q_reference_power ); +#endif /* compute target auto and cross PSDs of current frame (smoothed) */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); +#ifdef FIX_867 + v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + FOR( Word16 l = 0; l < sub( num_freq_bands, start_band ); ++l ) + { + Word16 common_q = s_min( q_cy_auto_diff_smooth[add( cur_idx, start_band ) + l], q_reference_power[start_band + l] ); + aux_buffer_res[l] = L_shl( aux_buffer_res[l], sub( common_q, q_reference_power[start_band + l] ) ); /* Q(common_q) */ + cy_auto_diff_smooth[add( cur_idx, start_band ) + l] = L_shl( cy_auto_diff_smooth[add( cur_idx, start_band ) + l], + sub( common_q, q_cy_auto_diff_smooth[add( cur_idx, start_band ) + l] ) ); /* Q(common_q) */ + /* Q adjustment */ + q_cy_auto_diff_smooth[add( cur_idx, start_band ) + l] = sub( common_q, Q1 ); + } + v_add_fixed( &cy_auto_diff_smooth[add( cur_idx, start_band )], + aux_buffer_res, + &cy_auto_diff_smooth[add( cur_idx, start_band )], sub( num_freq_bands, start_band ), Q1 ); /* Q(common_q) - Q1 */ +#else v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ scale_sig32( aux_buffer_res, sub( num_freq_bands, start_band ), sub( common_q, *q_reference_power ) ); /* Q(common_q) */ scale_sig32( &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), sub( common_q, *q_cy_auto_diff_smooth ) ); /* Q(common_q) */ v_add_fixed( &cy_auto_diff_smooth[cur_idx + start_band], aux_buffer_res, &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), Q1 ); /* Q(common_q) - Q1 */ +#endif } +#ifndef FIX_867 /* Q adjustment */ *q_cy_auto_diff_smooth = sub( common_q, Q1 ); move16(); +#endif return; } @@ -6286,6 +7028,9 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( Word16 *q_cy_auto_diff_smooth ) { Word16 ch_idx, cur_idx, diff_idx; +#ifdef FIX_867 + Word16 l; +#endif Word32 diffuse_response_p4, aux_buffer_res1[CLDFB_NO_CHANNELS_MAX]; /* segment auxiliary buffer */ Word32 diffuse_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ @@ -6324,6 +7069,55 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, Q1 ); // Q30 v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 +#ifdef FIX_867 + FOR( l = 0; l < num_decorr_freq_bands; l++ ) + { + q_reference_power_min_one = sub( q_reference_power[l], Q1 ); + + IF( GT_16( q_cy_auto_diff_smooth[cur_idx + l], q_reference_power_min_one ) ) + { + q_common = q_reference_power_min_one; + move16(); + } + ELSE + { + q_common = q_cy_auto_diff_smooth[cur_idx + l]; + move16(); + } + + IF( NE_16( q_common, q_reference_power_min_one ) ) + { + scale_sig32( &aux_buffer_res[l], 1, sub( q_common, q_reference_power_min_one ) ); // q_common + } + IF( NE_16( q_common, q_cy_auto_diff_smooth[cur_idx + l] ) ) + { + scale_sig32( &cy_auto_diff_smooth[cur_idx + l], 1, sub( q_common, q_cy_auto_diff_smooth[cur_idx + l] ) ); // q_common + } + /* Q adjustment */ + q_cy_auto_diff_smooth[cur_idx + l] = sub( q_common, Q1 ); + } + + v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_common - Q1) + + FOR( ; l < num_freq_bands; l++ ) + { + q_reference_power_min_one = sub( q_reference_power[l], Q1 ); + + IF( GT_16( q_cy_auto_diff_smooth[cur_idx + l], q_reference_power_min_one ) ) + { + q_common = q_reference_power_min_one; + move16(); + } + ELSE + { + q_common = q_cy_auto_diff_smooth[cur_idx + l]; + move16(); + } + scale_sig32( &cy_auto_diff_smooth[cur_idx + l], 1, sub( sub( q_common, Q1 ), q_cy_auto_diff_smooth[cur_idx + l] ) ); // (q_common - Q1) + q_cy_auto_diff_smooth[cur_idx + l] = sub( q_common, Q1 ); + } + +#else IF( NE_16( q_common, q_reference_power_min_one ) ) { scale_sig32( aux_buffer_res, num_decorr_freq_bands, sub( q_common, q_reference_power_min_one ) ); // q_common @@ -6334,11 +7128,14 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( } v_add_fixed( &cy_auto_diff_smooth[cur_idx], aux_buffer_res, &cy_auto_diff_smooth[cur_idx], num_decorr_freq_bands, Q1 ); // (q_common - Q1) scale_sig32( &cy_auto_diff_smooth[cur_idx + num_decorr_freq_bands], sub( num_freq_bands, num_decorr_freq_bands ), sub( sub( q_common, Q1 ), *q_cy_auto_diff_smooth ) ); // (q_common - Q1) +#endif } +#ifndef FIX_867 /* Q adjustment */ *q_cy_auto_diff_smooth = sub( q_common, Q1 ); move16(); +#endif return; } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 5bb0dfe1f..77673ff63 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1302,6 +1302,14 @@ ivas_error ivas_dirac_alloc_mem_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero_fx( hDirAC_mem->cy_auto_dir_smooth_fx, size ); +#ifdef FIX_867 + IF( ( hDirAC_mem->q_cy_auto_dir_smooth = (Word16 *) malloc( sizeof( Word16 ) * size ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set16_zero_fx( hDirAC_mem->q_cy_auto_dir_smooth, size ); +#endif + hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len = size; move16(); @@ -1358,7 +1366,12 @@ ivas_error ivas_dirac_alloc_mem_fx( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = Q31; move16(); hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx = hDirAC_mem->cy_auto_dir_smooth_fx; +#ifdef FIX_867 + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = hDirAC_mem->q_cy_auto_dir_smooth; + set16_zero_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); +#else hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = 0; +#endif move16(); hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx = hDirAC_mem->direct_responses_square_fx; hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q = Q31; @@ -1370,6 +1383,12 @@ ivas_error ivas_dirac_alloc_mem_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } +#ifdef FIX_867 + IF( ( hDirAC_mem->q_cy_cross_dir_smooth = (Word16 *) malloc( sizeof( Word16 ) * size_ho ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len = size_ho; move16(); #ifdef MSAN_FIX @@ -1386,6 +1405,12 @@ ivas_error ivas_dirac_alloc_mem_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero_fx( hDirAC_mem->cy_auto_diff_smooth_fx, size ); +#ifdef FIX_867 + IF( ( hDirAC_mem->q_cy_auto_diff_smooth = (Word16 *) malloc( sizeof( Word16 ) * size ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len = size; move16(); } @@ -1396,14 +1421,30 @@ ivas_error ivas_dirac_alloc_mem_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); } set_zero_fx( hDirAC_mem->cy_auto_diff_smooth_fx, imult1616( num_outputs_diff, num_freq_bands_diff ) ); +#ifdef FIX_867 + IF( ( hDirAC_mem->q_cy_auto_diff_smooth = (Word16 *) malloc( sizeof( Word16 ) * num_outputs_diff * num_freq_bands_diff ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } +#endif hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len = imult1616( num_outputs_diff, num_freq_bands_diff ); } +#ifdef FIX_867 + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx = hDirAC_mem->cy_cross_dir_smooth_fx; + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = hDirAC_mem->q_cy_cross_dir_smooth; + set16_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, Q31, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); + + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx = hDirAC_mem->cy_auto_diff_smooth_fx; + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = hDirAC_mem->q_cy_auto_diff_smooth; + set16_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, 0, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); +#else hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx = hDirAC_mem->cy_cross_dir_smooth_fx; hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = 31; move16(); hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx = hDirAC_mem->cy_auto_diff_smooth_fx; hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = 0; move16(); +#endif /*Responses (gains/factors)*/ IF( ( hDirAC_mem->direct_responses_fx = (Word32 *) malloc( sizeof( Word32 ) * size_ho ) ) == NULL ) @@ -1505,10 +1546,24 @@ ivas_error ivas_dirac_alloc_mem_fx( hDirAC_mem->reference_power_len = imult1616( 2, num_freq_bands ); move16(); +#ifdef FIX_867 + IF( ( hDirAC_mem->reference_power_q = (Word16 *) malloc( sizeof( Word32 ) * 2 * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + + IF( ( hDirAC_mem->reference_power_smooth_q = (Word16 *) malloc( sizeof( Word32 ) * 2 * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set16_fx( hDirAC_mem->reference_power_q, Q31, hDirAC_mem->reference_power_len ); + set16_fx( hDirAC_mem->reference_power_smooth_q, Q31, hDirAC_mem->reference_power_len ); +#else hDirAC_mem->reference_power_q = Q31; move16(); hDirAC_mem->reference_power_smooth_q = Q31; move16(); +#endif IF( hDirACRend->proto_signal_decorr_on ) { IF( ( hDirAC_mem->onset_filter_fx = (Word32 *) malloc( sizeof( Word32 ) * num_outputs_diff * num_freq_bands ) ) == NULL ) @@ -1531,6 +1586,13 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirAC_mem->reference_power_len = imult1616( 5, num_freq_bands ); +#ifdef FIX_867 + IF( ( hDirAC_mem->reference_power_q = (Word16 *) malloc( sizeof( Word16 ) * 5 * num_freq_bands ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } + set16_fx( hDirAC_mem->reference_power_q, Q31, hDirAC_mem->reference_power_len ); +#endif } IF( hDirACRend->proto_signal_decorr_on ) @@ -2741,7 +2803,11 @@ void protoSignalComputation1_fx( reference_power_fx[l] = Madd_32_32( Mpy_32_32( re, re ), im, im ); // 2*(q_cldfb+min_q_shift)-31 move32(); +#ifdef FIX_867 + reference_power_q[l] = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); +#else *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); +#endif move16(); IF( LT_16( *reference_power_q, *proto_power_smooth_q ) ) @@ -3598,6 +3664,17 @@ void protoSignalComputation2_fx( q_reference_power_64fx = shl( add( q_cldfb, min_q_shift ), 1 ); Word16 norm_shift = 63; move16(); +#ifdef FIX_867 + + FOR( l = 0; l < num_freq_bands; l++ ) + + { + norm_shift = W_norm( reference_power_64fx[l] ); + reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); // q_reference_power_64fx+norm_shift-32 + q_reference_power[l] = sub( add( q_reference_power_64fx, norm_shift ), 32 ); + } + +#else FOR( l = 0; l < num_freq_bands; l++ ) { IF( reference_power_64fx[l] ) @@ -3612,6 +3689,7 @@ void protoSignalComputation2_fx( } *q_reference_power = sub( add( q_reference_power_64fx, norm_shift ), 32 ); move16(); +#endif *q_proto_frame_f = add( q_cldfb, min_q_shift ); move16(); @@ -4010,11 +4088,18 @@ void protoSignalComputation4_fx( reference_power_fx[l] = Madd_32_16( reference_power_fx[l], sq_tmp_fx, 16384 /*0.5 in Q15*/ ); // 2*(q_cldfb+min_q_shift)-31 move32(); +#ifdef FIX_867 + sq_tmp_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); + reference_power_q[l] = sub( add( sq_tmp_q, Q15 ), 15 ); + move16(); +#endif } } +#ifndef FIX_867 sq_tmp_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); *reference_power_q = sub( add( sq_tmp_q, Q15 ), 15 ); move16(); +#endif min_q_shift = sub( q_shift, find_guarded_bits_fx( 2 ) ); @@ -5994,7 +6079,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q, +#ifdef FIX_867 + reference_power_fix, DirAC_mem.reference_power_q, slot_idx, nchan_transport, +#else reference_power_fix, &DirAC_mem.reference_power_q, slot_idx, nchan_transport, +#endif hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, 0, q_cldfb ); @@ -6007,12 +6096,34 @@ static void ivas_masa_ext_dirac_render_sf_fx( 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, +#ifdef FIX_867 + reference_power_fix, DirAC_mem.reference_power_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, +#else reference_power_fix, &DirAC_mem.reference_power_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, +#endif &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect, q_cldfb ); proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); +#ifdef FIX_867 + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + IF( LT_16( DirAC_mem.reference_power_q[i], DirAC_mem.reference_power_smooth_q[i] ) ) + { + reference_power_fix[hSpatParamRendCom->num_freq_bands + i] = + L_shl( reference_power_fix[hSpatParamRendCom->num_freq_bands + i], sub( DirAC_mem.reference_power_q[i], DirAC_mem.reference_power_smooth_q[i] ) ); + DirAC_mem.reference_power_smooth_q[i] = DirAC_mem.reference_power_q[i]; + move16(); + } + ELSE + { + reference_power_fix[i] = L_shl( reference_power_fix[i], sub( DirAC_mem.reference_power_smooth_q[i], DirAC_mem.reference_power_q[i] ) ); + DirAC_mem.reference_power_q[i] = DirAC_mem.reference_power_smooth_q[i]; + move16(); + } + } +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -6025,6 +6136,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); @@ -6040,7 +6152,11 @@ static void ivas_masa_ext_dirac_render_sf_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, +#ifdef FIX_867 + reference_power_fix, DirAC_mem.reference_power_q, +#else reference_power_fix, &DirAC_mem.reference_power_q, +#endif 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, @@ -6050,6 +6166,24 @@ static void ivas_masa_ext_dirac_render_sf_fx( proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); +#ifdef FIX_867 + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + IF( LT_16( DirAC_mem.reference_power_q[i], DirAC_mem.reference_power_smooth_q[i] ) ) + { + reference_power_fix[hSpatParamRendCom->num_freq_bands + i] = + L_shl( reference_power_fix[hSpatParamRendCom->num_freq_bands + i], sub( DirAC_mem.reference_power_q[i], DirAC_mem.reference_power_smooth_q[i] ) ); + DirAC_mem.reference_power_smooth_q[i] = DirAC_mem.reference_power_q[i]; + move16(); + } + ELSE + { + reference_power_fix[i] = L_shl( reference_power_fix[i], sub( DirAC_mem.reference_power_smooth_q[i], DirAC_mem.reference_power_q[i] ) ); + DirAC_mem.reference_power_q[i] = DirAC_mem.reference_power_smooth_q[i]; + move16(); + } + } +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -6062,6 +6196,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q hDirACRend->proto_frame_f_q = add( hDirACRend->proto_frame_f_q, temp_proto_frame_q ); @@ -6074,7 +6209,11 @@ static void ivas_masa_ext_dirac_render_sf_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, +#ifdef FIX_867 + reference_power_fix, DirAC_mem.reference_power_q, +#else reference_power_fix, &DirAC_mem.reference_power_q, +#endif hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, &hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, slot_idx, @@ -6084,6 +6223,24 @@ static void ivas_masa_ext_dirac_render_sf_fx( proto_direct_buffer_f_temp_q[slot_idx] = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q; move16(); +#ifdef FIX_867 + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + IF( LT_16( DirAC_mem.reference_power_q[i], DirAC_mem.reference_power_smooth_q[i] ) ) + { + reference_power_fix[hSpatParamRendCom->num_freq_bands + i] = + L_shl( reference_power_fix[hSpatParamRendCom->num_freq_bands + i], sub( DirAC_mem.reference_power_q[i], DirAC_mem.reference_power_smooth_q[i] ) ); // DirAC_mem.reference_power_q + DirAC_mem.reference_power_smooth_q[i] = DirAC_mem.reference_power_q[i]; + move16(); + } + ELSE + { + reference_power_fix[i] = L_shl( reference_power_fix[i], sub( DirAC_mem.reference_power_smooth_q[i], DirAC_mem.reference_power_q[i] ) ); // DirAC_mem.reference_power_smooth_q + DirAC_mem.reference_power_q[i] = DirAC_mem.reference_power_smooth_q[i]; + move16(); + } + } +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -6096,6 +6253,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif temp_proto_frame_q = sub( getScaleFactor32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len ), 2 ); Scale_sig32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f_len, temp_proto_frame_q ); // hDirACRend->proto_frame_f_q+temp_proto_frame_q @@ -6214,11 +6372,23 @@ static void ivas_masa_ext_dirac_render_sf_fx( IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867 + for ( i = 0; i < DirAC_mem.reference_power_len; i++ ) + { + // check this: 1 is subtracted from Q but headroom is 0 + DirAC_mem.reference_power_fx[i] = L_shl( DirAC_mem.reference_power_fx[i], -1 ); + DirAC_mem.reference_power_q[i] = sub( DirAC_mem.reference_power_q[i], 1 ); + move16(); + DirAC_mem.reference_power_smooth_q[i] = DirAC_mem.reference_power_q[i]; + move16(); + } +#else Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, -1 ); // DirAC_mem.reference_power_q-1 DirAC_mem.reference_power_q = sub( DirAC_mem.reference_power_q, 1 ); move16(); DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); +#endif v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); // DirAC_mem.reference_power_smooth_q } } @@ -6276,7 +6446,36 @@ static void ivas_masa_ext_dirac_render_sf_fx( } q_cldfb = 6; move16(); +#ifdef FIX_867 + FOR( i = 0; i < hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len; i++ ) + { + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx[i] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx[i], sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth[i] ) ); + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len ); + FOR( i = 0; i < hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len; i++ ) + { + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[i] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[i], sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[i] ) ); + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, Q26, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); + + FOR( i = 0; i < hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len; i++ ) + { + hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[i] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[i], sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[i] ) ); + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, Q26, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); + + FOR( i = 0; i < hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len; i++ ) + { + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[i] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[i], sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[i] ) ); + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, Q26, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); + +#else Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); // q26 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26; move16(); @@ -6292,6 +6491,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( Scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len, sub( 26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); // q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26; move16(); +#endif ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, @@ -6303,14 +6503,31 @@ static void ivas_masa_ext_dirac_render_sf_fx( diffuseness_vector_fx, 0, 0, +#ifdef FIX_867 + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ); +#else &hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, &hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ); +#endif q_cldfb = -1; move16(); +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; kk++ ) + { + hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk] = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk]; + } + + FOR( Word16 kk = 0; kk < hDirACRend->num_outputs_diff * hSpatParamRendCom->num_freq_bands; kk++ ) + { + hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk] = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk]; + } +#else hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; move16(); hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev; move16(); +#endif } ELSE { @@ -6341,6 +6558,25 @@ static void ivas_masa_ext_dirac_render_sf_fx( q_cldfb = 11; move16(); +#ifdef FIX_867 + FOR( i = 0; i < DirAC_mem.reference_power_len; i++ ) + { + Word16 reference_power_temp_q = getScaleFactor32( &DirAC_mem.reference_power_fx[i], 1 ); + L_shl( DirAC_mem.reference_power_fx[i], reference_power_temp_q ); + DirAC_mem.reference_power_q[i] = add( DirAC_mem.reference_power_q[i], reference_power_temp_q ); + move16(); + DirAC_mem.reference_power_smooth_q[i] = add( DirAC_mem.reference_power_q[i], reference_power_temp_q ); + move16(); + } + + FOR( Word16 kk = 0; kk < h_dirac_output_synthesis_state->cy_auto_diff_smooth_len; kk++ ) + { + Word16 q_cy_auto_diff_smooth = getScaleFactor32( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], 1 ); + Scale_sig32( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], 1, q_cy_auto_diff_smooth ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk], q_cy_auto_diff_smooth ); + move16(); + } +#else Word16 reference_power_temp_q = getScaleFactor32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len ); scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, reference_power_temp_q ); /*DirAC_mem.reference_power_q + reference_power_temp_q*/ DirAC_mem.reference_power_q = add( DirAC_mem.reference_power_q, reference_power_temp_q ); @@ -6352,6 +6588,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( Scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len, q_cy_auto_diff_smooth ); // h_dirac_output_synthesis_state->q_cy_auto_diff_smooth+ q_cy_auto_diff_smooth h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, q_cy_auto_diff_smooth ); move16(); +#endif Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands, sub( 31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); // q31 hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q = Q31; @@ -6405,6 +6642,29 @@ static void ivas_masa_ext_dirac_render_sf_fx( /*Buffer rescaling*/ +#ifdef FIX_867 + FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx[l] = + L_shl( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx[l], + sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l], DirAC_mem.reference_power_q[l] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l] ) ); + } + + FOR( Word16 l = 0; l < DirAC_mem.reference_power_len; l++ ) + { + DirAC_mem.reference_power_fx[l] = L_shl( DirAC_mem.reference_power_fx[l], + sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l], DirAC_mem.reference_power_q[l] ), + DirAC_mem.reference_power_q[l] ) ); + + + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l], DirAC_mem.reference_power_q[l] ); + move16(); + DirAC_mem.reference_power_q[l] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l], DirAC_mem.reference_power_q[l] ); + move16(); + DirAC_mem.reference_power_smooth_q[l] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l], DirAC_mem.reference_power_q[l] ); + move16(); + } +#else Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) Scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ), DirAC_mem.reference_power_q ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) @@ -6414,6 +6674,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); DirAC_mem.reference_power_smooth_q = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ); move16(); +#endif ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, @@ -6422,7 +6683,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( hSpatParamRendCom->subframe_nbslots[subframe_idx], diffuseness_vector_fx, reference_power_smooth_fx, +#ifdef FIX_867 + DirAC_mem.reference_power_smooth_q, +#else &DirAC_mem.reference_power_smooth_q, +#endif ONE_IN_Q31, 0, &q_cldfb ); @@ -6430,6 +6695,31 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = DirAC_mem.reference_power_smooth_q; move16(); +#ifdef FIX_867 + FOR( Word16 l = 0; l < DirAC_mem.reference_power_len; l++ ) + { + hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[l] = DirAC_mem.reference_power_smooth_q[l]; + move16(); + } + + FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) + { + IF( LT_16( DirAC_mem.reference_power_q[l], DirAC_mem.reference_power_smooth_q[l] ) ) + { + reference_power_fix[hSpatParamRendCom->num_freq_bands + l] = + L_shl( reference_power_fix[hSpatParamRendCom->num_freq_bands + l], sub( DirAC_mem.reference_power_q[l], DirAC_mem.reference_power_smooth_q[l] ) ); + DirAC_mem.reference_power_smooth_q[l] = DirAC_mem.reference_power_q[l]; + move16(); + } + ELSE + { + reference_power_fix[l] = + L_shl( reference_power_fix[l], sub( DirAC_mem.reference_power_smooth_q[l], DirAC_mem.reference_power_q[l] ) ); + DirAC_mem.reference_power_q[l] = DirAC_mem.reference_power_smooth_q[l]; + move16(); + } + } +#else IF( LT_16( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ) { Scale_sig32( reference_power_fix + hSpatParamRendCom->num_freq_bands, sub( DirAC_mem.reference_power_len, hSpatParamRendCom->num_freq_bands ), sub( DirAC_mem.reference_power_q, DirAC_mem.reference_power_smooth_q ) ); // DirAC_mem.reference_power_q @@ -6442,6 +6732,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_q = DirAC_mem.reference_power_smooth_q; move16(); } +#endif } /*-----------------------------------------------------------------* diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 8752094ce..ac5d6dfac 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -851,7 +851,11 @@ void ivas_dirac_dec_output_synthesis_close( #ifdef IVAS_FLOAT_FIXED void ivas_dirac_dec_output_synthesis_process_slot_fx( const Word32 *reference_power, /* i : Estimated power */ +#ifdef FIX_867 + const Word16 *q_reference_power, /* i : Estimated power */ +#else const Word16 q_reference_power, /* i : Estimated power */ +#endif const Word32 *onset, /* i : onset filter */ const Word16 *azimuth, const Word16 *elevation, diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 49808bdd1..4170a44cc 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -313,6 +313,11 @@ typedef struct dirac_dec_stack_mem Word32 *cy_auto_dir_smooth_fx; Word32 *cy_cross_dir_smooth_fx; Word32 *cy_auto_diff_smooth_fx; +#ifdef FIX_867 + Word16 *q_cy_auto_dir_smooth; + Word16 *q_cy_cross_dir_smooth; + Word16 *q_cy_auto_diff_smooth; +#endif #else float *cy_cross_dir_smooth; float *cy_auto_dir_smooth; @@ -324,8 +329,13 @@ typedef struct dirac_dec_stack_mem float *onset_filter; #else Word32 *reference_power_fx; +#ifdef FIX_867 + Word16 *reference_power_q; + Word16 *reference_power_smooth_q; +#else Word16 reference_power_q; Word16 reference_power_smooth_q; +#endif Word16 reference_power_len; Word32 *onset_filter_fx; /* Q31 */ #endif @@ -434,7 +444,11 @@ typedef struct dirac_output_synthesis_state_structure float *direction_smoothness_prev; #else Word32 *reference_power_smooth_prev_fx; /* Q(reference_power_smooth_prev_q) */ +#ifdef FIX_867 + Word16 *reference_power_smooth_prev_q; +#else Word16 reference_power_smooth_prev_q; +#endif Word32 *direction_smoothness_prev_fx; /* Q31 */ #endif @@ -479,8 +493,13 @@ typedef struct dirac_output_synthesis_state_structure Word32 *gains_dir_prev_fx; /* Direct sound gains of current synthesis block. Size: num_freq_bands*num_channel. */ Word32 *gains_diff_prev_fx; /* Diffuse sound gains of previous synthesis block. Size: num_freq_bands*num_channel. */ +#ifdef FIX_867 + Word16 *gains_dir_prev_q; + Word16 *gains_diff_prev_q; +#else Word16 gains_dir_prev_q; Word16 gains_diff_prev_q; +#endif Word16 gains_dir_prev_len; Word16 gains_diff_prev_len; @@ -490,9 +509,15 @@ typedef struct dirac_output_synthesis_state_structure Word32 *cy_cross_dir_smooth_fx; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word32 *cy_auto_diff_smooth_fx; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#ifdef FIX_867 + Word16 *q_cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 *q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 *q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#else + Word16 q_cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#endif Word16 cy_auto_dir_smooth_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 cy_cross_dir_smooth_len; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ @@ -503,9 +528,15 @@ typedef struct dirac_output_synthesis_state_structure Word32 *cy_cross_dir_smooth_prev_fx; /* Target cross PSD of direct sound of previous synthesis block. Size: num_freq_bands*num_channels. */ Word32 *cy_auto_diff_smooth_prev_fx; /* Target auto PSD of diffuse sound of previous synthesis block. Size: num_freq_bands*num_channels. */ - Word16 q_cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#ifdef FIX_867 + Word16 *q_cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 *q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 *q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#else + Word16 q_cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ +#endif Word16 cy_auto_dir_smooth_prev_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 cy_cross_dir_smooth_prev_len; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8abafc8f8..ea6e981c1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -15202,37 +15202,85 @@ static void intermidiate_ext_dirac_render( IF( to_fix ) { +#ifdef FIX_867 + set16_fx( DirAC_mem.reference_power_smooth_q, Q31, DirAC_mem.reference_power_len ); + set16_fx( DirAC_mem.reference_power_q, Q31, DirAC_mem.reference_power_len ); +#else DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31; move16(); move16(); +#endif FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len; kk++ ) + { + Word16 shift = norm_l( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk] ); + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk], shift ); + + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[kk] = + add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[kk], shift ); + move16(); + } +#else Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_fx, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ), sub( Q30, hDirACRend->h_output_synthesis_psd_state.direct_responses_q ) ); /* Q30 */ hDirACRend->h_output_synthesis_psd_state.direct_responses_q = Q30; move16(); +#endif } IF( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len; kk++ ) + { + Word16 shift = L_norm_arr( &hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk], 1 ); + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[kk], 1, shift ); + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[kk], shift ); + move16(); + } +#else Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, shift ); move16(); +#endif } IF( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len; kk++ ) + { + Word16 shift = L_norm_arr( &hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[kk], 1 ); + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[kk], 1, shift ); + hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[kk], shift ); + move16(); + } +#else Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, shift ); move16(); +#endif } IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->num_outputs_dir * hSpatParamRendCom->num_freq_bands; kk++ ) + { + Word16 shift = L_norm_arr( &hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx[kk], 1 ); + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx[kk], 1, shift ); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth[kk], shift ); + move16(); + } +#else Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, shift ); move16(); +#endif } Word16 num_channels_dir = hDirACRend->num_outputs_dir; @@ -15246,32 +15294,83 @@ static void intermidiate_ext_dirac_render( IF( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < num_channels_dir * hSpatParamRendCom->num_freq_bands; kk++ ) + { + tmp = L_norm_arr( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], 1 ); + scale_sig32( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], 1, tmp ); + h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk], tmp ); + move16(); + } +#else tmp = L_norm_arr( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ) ); scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_len, tmp ); /* Q(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth + tmp) */ h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = add( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, tmp ); move16(); +#endif } IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx ) { +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len; kk++ ) + { + tmp = L_norm_arr( &hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk], 1 ); + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx[kk], 1, tmp ); + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[kk], tmp ); + move16(); + } +#else tmp = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_len, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev + tmp) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp ); move16(); +#endif } +#ifdef FIX_867 + FOR( Word16 kk = 0; kk < hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len; kk++ ) + { + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx[kk], + 1, + Q26 - hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[kk] ); + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len ); + + FOR( Word16 kk = 0; kk < hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len; kk++ ) + { + scale_sig32( &hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx[kk], + 1, + Q26 - hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[kk] ); + } + set16_fx( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len ); +#else scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); /* Q26 */ hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26; move16(); scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); /* Q26 */ hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26; move16(); +#endif IF( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx ) { +#ifdef FIX_867 + FOR( Word16 l = 0; l < hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len; l++ ) + { + Word16 shift = norm_l( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx[l] ); + hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx[l] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx[l], shift ); + /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev + shift) */ + + hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev[l] = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev[l], shift ); + move16(); + } +#else Word16 shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_len, shift ); /* Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev + shift) */ hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift ); move16(); +#endif } IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) -- GitLab From 72a164e588f6e1f5187b1849dec75b7a58bdb30a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Nov 2024 10:20:14 +0100 Subject: [PATCH 02/36] fix memory bug --- lib_rend/ivas_dirac_output_synthesis_dec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 0e98f3986..c1717e5a8 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -251,6 +251,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF((dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = (Word16 *)malloc(dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_dir * sizeof(Word16))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + } +#endif dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); move16(); } @@ -336,6 +342,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } +#ifdef FIX_867 + IF((dirac_output_synthesis_state->gains_diff_prev_q = (Word16 *)malloc(hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof(Word16))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); + } +#endif dirac_output_synthesis_state->gains_diff_prev_len = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ); move16(); } @@ -953,8 +965,10 @@ void ivas_dirac_dec_output_synthesis_init_fx( set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); #endif } +#ifndef FIX_867 h_dirac_output_synthesis_state->gains_diff_prev_q = 0; move16(); +#endif IF( h_dirac_output_synthesis_state->proto_power_diff_smooth_prev_fx != NULL ) { -- GitLab From 6c0f3d8eea27817f2b2e8a525b69a9e819837ca0 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Nov 2024 11:12:04 +0100 Subject: [PATCH 03/36] add debug code and fix bugs --- lib_com/options.h | 1 + lib_dec/ivas_dirac_dec.c | 35 ++++++++++++++++++---- lib_rend/ivas_dirac_output_synthesis_dec.c | 19 +++++++++++- lib_rend/ivas_dirac_rend.c | 18 ++++++++++- 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 213d152d1..c1d0f40dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -201,6 +201,7 @@ /* ################## End DEVELOPMENT switches ######################### */ #define FIX_867 +#define FIX_867_DBG /* clang-format on */ #define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 3a7da7cdb..dc0407362 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3752,7 +3752,7 @@ void ivas_dirac_dec_render_sf_fx( Word16 tmp1; push_wmops( "ivas_dirac_dec_render" ); -#ifdef FIX_876 +#ifdef FIX_867 set16_fx( q_reference_power_smooth, Q31, CLDFB_SLOTS_PER_SUBFRAME * MAX_OUTPUT_CHANNELS ); #endif @@ -3831,7 +3831,8 @@ void ivas_dirac_dec_render_sf_fx( FOR( Word16 kk = 0; kk < imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ); kk++ ) { tmp1 = norm_l( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] ); - L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] ) ); // tmp1 + h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] = + L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] ) ); // tmp1 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = tmp1; move16(); } @@ -4892,8 +4893,7 @@ void ivas_dirac_dec_render_sf_fx( { IF( LT_16( q_reference_power_smooth[i], DirAC_mem.reference_power_q[i] ) ) { - Word32 temp; - + Word32 temp; temp = L_shl( reference_power_fx[i], sub( q_reference_power_smooth[i], DirAC_mem.reference_power_q[i] ) ); test(); IF( temp == 0 && ( reference_power_fx[i] != 0 ) ) @@ -4911,7 +4911,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - Word32 temp; + Word32 temp; temp = L_shl( reference_power_smooth_fx[i], sub( DirAC_mem.reference_power_q[i], q_reference_power_smooth[i] ) ); test(); IF( temp == 0 && ( reference_power_smooth_fx[i] != 0 ) ) @@ -4927,8 +4927,14 @@ void ivas_dirac_dec_render_sf_fx( move16(); } q_reference_power_smooth[i] = sub( q_reference_power_smooth[i], 1 ); + + reference_power_smooth_fx[i] = L_add(L_shr(reference_power_smooth_fx[i],1), + L_shr(reference_power_fx[i],1) ); + Word16 shift; + shift = norm_l(reference_power_smooth_fx[i]); + reference_power_smooth_fx[i] = L_shl(reference_power_smooth_fx[i], shift); + q_reference_power_smooth[i] = add(q_reference_power_smooth[i], shift); } - v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 ); #else IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) ) { @@ -4973,6 +4979,23 @@ void ivas_dirac_dec_render_sf_fx( 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 ); #endif + + +#ifdef FIX_867_DBG + FOR(i = 0; i < hSpatParamRendCom->num_freq_bands; i++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("reference_power_smooth_fx", "w"); + + Word32 m = reference_power_smooth_fx[i]; + Word16 e = q_reference_power_smooth[i]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", i, m, e, f1); + } +#endif } } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index c1717e5a8..75d633d86 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4112,7 +4112,24 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); } - p_gains_dir++; + +#ifdef FIX_867_DBG + { + static FILE *f = 0; + if (f == 0) + f = fopen("gains", "w"); + + Word32 m = *p_gains_dir; + Word16 e = h_dirac_output_synthesis_state->gains_dir_prev_q[k*num_freq_bands + l]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif + p_gains_dir++; + + /*diffuse*/ *( p_cy_auto_diff_smooth_prev ) = L_add( Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth ) ) ), diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 77673ff63..736cd10ba 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -3667,7 +3667,6 @@ void protoSignalComputation2_fx( #ifdef FIX_867 FOR( l = 0; l < num_freq_bands; l++ ) - { norm_shift = W_norm( reference_power_64fx[l] ); reference_power_fx[l] = W_extract_h( W_shl( reference_power_64fx[l], norm_shift ) ); // q_reference_power_64fx+norm_shift-32 @@ -3691,6 +3690,23 @@ void protoSignalComputation2_fx( move16(); #endif +#ifdef FIX_867_DBG + FOR(l = 0; l < num_freq_bands; l++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("reference_power_fx", "w"); + + Word32 m = reference_power_fx[l]; + Word16 e = q_reference_power[l]; + float f1_m = (float)m; + float f1_e = powf(2,e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif + + *q_proto_frame_f = add( q_cldfb, min_q_shift ); move16(); *q_proto_direct_buffer_f = add( q_cldfb, min_q_shift ); -- GitLab From bfdca295e94680bfc284700a64bd35cfef58c8f8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Nov 2024 12:08:15 +0100 Subject: [PATCH 04/36] optimize calculation of q_cy_auto_dir_smooth and cy_cross_dir_smooth --- lib_rend/ivas_dirac_output_synthesis_dec.c | 54 +++++++++++++++++----- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 75d633d86..2011cee51 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4050,6 +4050,33 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( /*Only direct prototype*/ FOR( ; l < num_freq_bands; l++ ) { +#ifdef FIX_867_DBG + { + static FILE *f = 0; + if (f == 0) + f = fopen("cy_auto_dir_smooth_prev", "w"); + + Word32 m = *p_cy_auto_dir_smooth; + Word16 e = h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[k*num_freq_bands + l]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } + { + static FILE *f = 0; + if (f == 0) + f = fopen("p_power_smooth", "w"); + + Word32 m = *p_power_smooth; + Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif + /*Direct*/ g1 = alpha[l]; // Q31 move32(); @@ -4070,6 +4097,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_cy_cross_dir_smooth_prev ) = 1; move32(); } + ( p_cy_cross_dir_smooth++ ); power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); L_tmp = Mpy_32_32( power_smooth_temp, L_tmp ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 @@ -6820,7 +6848,19 @@ static void computeTargetPSDs_direct_subframe_fx( FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { cur_idx = imult1616( ch_idx, num_freq_bands ); - +#ifdef FIX_867 + FOR(i = 0; i < num_freq_bands; i++) + { + W_tmp[i] = W_mult_32_32(direct_power[i], direct_responses_square[cur_idx + i]); // q_reference_power + Q31 + 1 + q_tmp = W_norm(W_tmp[i]); + cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl(W_tmp[i], q_tmp) ); + q_cy_auto_dir_smooth[ch_idx + i] = add(q_reference_power[i], q_tmp); + move16(); + + cy_cross_dir_smooth[cur_idx + i] = Mpy_32_32(direct_power[i], direct_responses[cur_idx+i]); + q_cy_cross_dir_smooth[cur_idx + i] = q_reference_power[i]; + } +#else W_max = 0; move64(); FOR( i = 0; i < num_freq_bands; i++ ) @@ -6837,25 +6877,17 @@ static void computeTargetPSDs_direct_subframe_fx( { cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); /*q_reference_power+q_tmp*/ move32(); -#ifdef FIX_867 - q_cy_auto_dir_smooth[cur_idx + i] = add( q_reference_power[i], q_tmp ); - move16(); - - q_cy_cross_dir_smooth[cur_idx + i] = q_reference_power[i]; - move16(); -#endif } -#ifndef FIX_867 q_cy_auto_dir_smooth[ch_idx] = add( *q_reference_power, q_tmp ); move16(); -#endif v_mult_fixed( direct_power, &direct_responses[cur_idx], &cy_cross_dir_smooth[cur_idx], num_freq_bands ); // (q_reference_power, Q31) -> q_reference_power +#endif } #ifndef FIX_867 *q_cy_cross_dir_smooth = *q_reference_power; + move16(); #endif - move16(); return; } -- GitLab From 2685f3ae3225084d5a52516d9759388261069bdd Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Nov 2024 12:27:43 +0100 Subject: [PATCH 05/36] fix calculation of q_cy_auto_diff_smooth --- lib_rend/ivas_dirac_output_synthesis_dec.c | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 2011cee51..5ca7d2cbd 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4051,18 +4051,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( FOR( ; l < num_freq_bands; l++ ) { #ifdef FIX_867_DBG - { - static FILE *f = 0; - if (f == 0) - f = fopen("cy_auto_dir_smooth_prev", "w"); - - Word32 m = *p_cy_auto_dir_smooth; - Word16 e = h_dirac_output_synthesis_state->q_cy_auto_dir_smooth[k*num_freq_bands + l]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } { static FILE *f = 0; if (f == 0) @@ -6889,6 +6877,27 @@ static void computeTargetPSDs_direct_subframe_fx( move16(); #endif + +#ifdef FIX_867_DBG + FOR(ch_idx = 0; ch_idx < num_channels; ++ch_idx) + { + cur_idx = imult1616(ch_idx, num_freq_bands); + FOR(i = 0; i < num_freq_bands; i++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("cy_auto_dir_smooth1", "w"); + + Word32 m = cy_auto_dir_smooth[cur_idx + i]; + Word16 e = q_cy_auto_dir_smooth[cur_idx + i]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", i, m, e, f1); + } + } +#endif + return; } #else @@ -7040,9 +7049,18 @@ static void computeTargetPSDs_diffuse_subframe_fx( cur_idx = imult1616( ch_idx, num_freq_bands ); v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power - } +#ifdef FIX_867 + FOR(Word16 i=0;i Date: Tue, 19 Nov 2024 13:09:57 +0100 Subject: [PATCH 06/36] fix calculation of cy_auto_dir_smooth and cy_cross_dir_smooth --- lib_dec/ivas_dirac_dec.c | 46 +++++++++++----------- lib_rend/ivas_dirac_output_synthesis_dec.c | 40 ++++++++++++------- lib_rend/ivas_dirac_rend.c | 26 ++++++------ 3 files changed, 62 insertions(+), 50 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index dc0407362..2d1b07520 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3831,8 +3831,8 @@ void ivas_dirac_dec_render_sf_fx( FOR( Word16 kk = 0; kk < imult1616( num_channels_dir, hSpatParamRendCom->num_freq_bands ); kk++ ) { tmp1 = norm_l( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] ); - h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] = - L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] ) ); // tmp1 + h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk] = + L_shl( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[kk], sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] ) ); // tmp1 h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[kk] = tmp1; move16(); } @@ -4893,7 +4893,7 @@ void ivas_dirac_dec_render_sf_fx( { IF( LT_16( q_reference_power_smooth[i], DirAC_mem.reference_power_q[i] ) ) { - Word32 temp; + Word32 temp; temp = L_shl( reference_power_fx[i], sub( q_reference_power_smooth[i], DirAC_mem.reference_power_q[i] ) ); test(); IF( temp == 0 && ( reference_power_fx[i] != 0 ) ) @@ -4911,7 +4911,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - Word32 temp; + Word32 temp; temp = L_shl( reference_power_smooth_fx[i], sub( DirAC_mem.reference_power_q[i], q_reference_power_smooth[i] ) ); test(); IF( temp == 0 && ( reference_power_smooth_fx[i] != 0 ) ) @@ -4928,12 +4928,12 @@ void ivas_dirac_dec_render_sf_fx( } q_reference_power_smooth[i] = sub( q_reference_power_smooth[i], 1 ); - reference_power_smooth_fx[i] = L_add(L_shr(reference_power_smooth_fx[i],1), - L_shr(reference_power_fx[i],1) ); - Word16 shift; - shift = norm_l(reference_power_smooth_fx[i]); - reference_power_smooth_fx[i] = L_shl(reference_power_smooth_fx[i], shift); - q_reference_power_smooth[i] = add(q_reference_power_smooth[i], shift); + reference_power_smooth_fx[i] = L_add( L_shr( reference_power_smooth_fx[i], 1 ), + L_shr( reference_power_fx[i], 1 ) ); + Word16 shift; + shift = norm_l( reference_power_smooth_fx[i] ); + reference_power_smooth_fx[i] = L_shl( reference_power_smooth_fx[i], shift ); + q_reference_power_smooth[i] = add( q_reference_power_smooth[i], shift ); } #else IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) ) @@ -4982,19 +4982,19 @@ void ivas_dirac_dec_render_sf_fx( #ifdef FIX_867_DBG - FOR(i = 0; i < hSpatParamRendCom->num_freq_bands; i++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("reference_power_smooth_fx", "w"); - - Word32 m = reference_power_smooth_fx[i]; - Word16 e = q_reference_power_smooth[i]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", i, m, e, f1); - } + FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "reference_power_smooth_fx", "w" ); + + Word32 m = reference_power_smooth_fx[i]; + Word16 e = q_reference_power_smooth[i]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", i, m, e, f1 ); + } #endif } } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 5ca7d2cbd..d8974d64d 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -6703,7 +6703,11 @@ static void computeTargetPSDs_direct_fx( /* segment auxiliary buffer */ Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ - Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ +#ifdef FIX_867 + Word32 aux_buffer_res; /* size: num_freq_bands. */ +#else + Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ +#endif /* estimate direct and diffuse power */ v_mult_fixed( direct_power_factor, reference_power, direct_power, num_freq_bands ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ @@ -6722,20 +6726,28 @@ static void computeTargetPSDs_direct_fx( { Word16 common1_q = s_min( q_cy_auto_dir_smooth[cur_idx + l], q_reference_power[l] ); Word16 common2_q = s_min( q_cy_cross_dir_smooth[cur_idx + l], q_reference_power[l] ); - v_mult_fixed( direct_power, &direct_responses_square[cur_idx + l], aux_buffer_res, 1 ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - scale_sig32( &aux_buffer_res[l], 1, sub( common1_q, q_reference_power[l] ) ); /* Q(common1_q) */ - scale_sig32( &cy_auto_dir_smooth[cur_idx + l], 1, sub( common1_q, q_cy_auto_dir_smooth[cur_idx + l] ) ); /* Q(common1_q) */ - v_add_fixed( &cy_auto_dir_smooth[cur_idx + l], &aux_buffer_res[l], &cy_auto_dir_smooth[cur_idx + l], 1, Q1 ); /* Q(common1_q) - Q1 */ - - v_mult_fixed( direct_power, &direct_responses[cur_idx + l], &aux_buffer_res[l], 1 ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - scale_sig32( &aux_buffer_res[l], 1, sub( common2_q, q_reference_power[l] ) ); /* Q(common2_q) */ - scale_sig32( &cy_cross_dir_smooth[cur_idx + l], 1, sub( common2_q, q_cy_cross_dir_smooth[cur_idx + l] ) ); /* Q(common2_q) */ - v_add_fixed( &cy_cross_dir_smooth[cur_idx + l], &aux_buffer_res[l], &cy_cross_dir_smooth[cur_idx + l], 1, Q1 ); /* Q(common2_q) - Q1 */ - - /* Q adjustment */ - q_cy_auto_dir_smooth[cur_idx + l] = sub( common1_q, Q1 ); + + aux_buffer_res = Mpy_32_32( direct_power[l], direct_responses_square[cur_idx + l] ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + + aux_buffer_res = L_shl( aux_buffer_res, sub( common1_q, q_reference_power[l] ) ); /* Q(common1_q) */ + cy_auto_dir_smooth[cur_idx + l] = L_shl( cy_auto_dir_smooth[cur_idx + l], sub( common1_q, q_cy_auto_dir_smooth[cur_idx + l] ) ); /* Q(common1_q) */ + + cy_auto_dir_smooth[cur_idx + l] = L_add( L_shr(cy_auto_dir_smooth[cur_idx + l],1), L_shr(aux_buffer_res,1) ); /* Q(common1_q) - Q1 */ + + aux_buffer_res = Mpy_32_32(direct_power[l], direct_responses[cur_idx + l]); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + aux_buffer_res = L_shl( aux_buffer_res, sub( common2_q, q_reference_power[l] ) ); /* Q(common2_q) */ + cy_cross_dir_smooth[cur_idx + l] = L_shl( cy_cross_dir_smooth[cur_idx + l], sub( common2_q, q_cy_cross_dir_smooth[cur_idx + l] ) ); /* Q(common2_q) */ + + cy_cross_dir_smooth[cur_idx + l] = L_add( L_shr(cy_cross_dir_smooth[cur_idx + l],1), L_shr(aux_buffer_res,1) ); /* Q(common2_q) - Q1 */ + + Word16 q_tmp = norm_l(cy_auto_dir_smooth[cur_idx + l]); + cy_auto_dir_smooth[cur_idx + l] = L_shl(cy_auto_dir_smooth[cur_idx + l], q_tmp); + q_cy_auto_dir_smooth[cur_idx + l] = add(sub(common1_q, Q1), q_tmp); move16(); - q_cy_cross_dir_smooth[cur_idx + l] = sub( common2_q, Q1 ); + + q_tmp = norm_l(cy_cross_dir_smooth[cur_idx + l]); + cy_cross_dir_smooth[cur_idx + l] = L_shl(cy_cross_dir_smooth[cur_idx + l], q_tmp); + q_cy_cross_dir_smooth[cur_idx + l] = add(sub( common2_q, Q1 ), q_tmp); move16(); } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 736cd10ba..de975656d 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -3691,19 +3691,19 @@ void protoSignalComputation2_fx( #endif #ifdef FIX_867_DBG - FOR(l = 0; l < num_freq_bands; l++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("reference_power_fx", "w"); - - Word32 m = reference_power_fx[l]; - Word16 e = q_reference_power[l]; - float f1_m = (float)m; - float f1_e = powf(2,e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + FOR( l = 0; l < num_freq_bands; l++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "reference_power_fx", "w" ); + + Word32 m = reference_power_fx[l]; + Word16 e = q_reference_power[l]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif -- GitLab From 52a9e786f9f72f124da513679d09e0511a366549 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Nov 2024 13:38:43 +0100 Subject: [PATCH 07/36] fix Q of Cldfb_RealBuffer_fx --- lib_dec/ivas_dirac_dec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2d1b07520..ba0d2f44b 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5193,8 +5193,8 @@ void ivas_dirac_dec_render_sf_fx( #ifdef FIX_867 FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { - scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 - scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 } #else 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 ) ) ) ); // Q6 @@ -5212,8 +5212,8 @@ void ivas_dirac_dec_render_sf_fx( #ifdef FIX_867 FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { - scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 - scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 } #else 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 ) ) ) ); // Q6 -- GitLab From 60a006226370c2daf9082b1f8e2cc76b2bbb1893 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Nov 2024 13:39:16 +0100 Subject: [PATCH 08/36] disable the defines --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c1d0f40dc..1badae941 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,8 +200,8 @@ #define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* FhG: fixes for decoder-side noise level estimation in MDCT-Stereo to prevent noise bursts in stereo switching */ /* ################## End DEVELOPMENT switches ######################### */ -#define FIX_867 -#define FIX_867_DBG +//#define FIX_867 +//#define FIX_867_DBG /* clang-format on */ #define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO -- GitLab From d7d0913c4dd173d3df426d0b62335dd33c0a0337 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 11:21:21 +0100 Subject: [PATCH 09/36] fix indexing problems --- lib_dec/ivas_dirac_dec.c | 16 ----- lib_rend/ivas_dirac_output_synthesis_dec.c | 71 ++++++++++++++++++++-- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ba0d2f44b..0691df555 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4980,22 +4980,6 @@ void ivas_dirac_dec_render_sf_fx( q_reference_power_smooth = sub( q_reference_power_smooth, 1 ); #endif - -#ifdef FIX_867_DBG - FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ ) - { - static FILE *f = 0; - if ( f == 0 ) - f = fopen( "reference_power_smooth_fx", "w" ); - - Word32 m = reference_power_smooth_fx[i]; - Word16 e = q_reference_power_smooth[i]; - float f1_m = (float) m; - float f1_e = powf( 2, e ); - float f1 = f1_m / f1_e; - fprintf( f, "%d %d %d %f\n", i, m, e, f1 ); - } -#endif } } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index d8974d64d..324f72b84 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4058,7 +4058,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Word32 m = *p_power_smooth; Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; - float f1_m = (float)m; + float f1_m = (float) m; float f1_e = powf(2, e); float f1 = f1_m / f1_e; fprintf(f, "%d %d %d %f\n", l, m, e, f1); @@ -4071,6 +4071,21 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 W_temp = W_add( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ), W_mult_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/ +#ifdef FIX_867_DBG + { + static FILE *f = 0; + if (f == 0) + f = fopen("p_cy_auto_dir_smooth_prev", "w"); + + Word32 m = *p_cy_auto_dir_smooth_prev; + Word16 e = q_cy_auto_dir_smooth_prev_local[k*num_freq_bands + l]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif + q_tmp = W_norm( W_temp ); L_tmp = W_extract_h( W_shl( W_temp, q_tmp ) ); // q_cy_auto_dir_smooth_prev_local + q_tmp *( p_cy_auto_dir_smooth_prev++ ) = L_shr_r( L_tmp, q_tmp ); // q_cy_auto_dir_smooth_prev_local @@ -4088,9 +4103,23 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( ( p_cy_cross_dir_smooth++ ); power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); +#ifdef FIX_867_DBG + { + static FILE *f = 0; + if (f == 0) + f = fopen("p_power_smooth1", "w"); + + Word32 m = *p_power_smooth; + Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif L_tmp = Mpy_32_32( power_smooth_temp, L_tmp ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), - add( q_cy_auto_dir_smooth_prev_local[k], q_tmp ) ), + add( q_cy_auto_dir_smooth_prev_local[k*num_freq_bands + l], q_tmp ) ), Q31 ) ); *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) @@ -6832,6 +6861,22 @@ static void computeTargetPSDs_direct_subframe_fx( /* segment auxiliary buffer */ Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ +#ifdef FIX_867_DBG + FOR(i = 0; i < num_freq_bands; i++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("reference_power_smooth_fx", "w"); + + Word32 m = reference_power[i]; + Word16 e = q_reference_power[i]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", i, m, e, f1); + } +#endif + /* estimate direct and diffuse power */ FOR( i = 0; i < num_freq_bands; i++ ) { @@ -6854,7 +6899,7 @@ static void computeTargetPSDs_direct_subframe_fx( W_tmp[i] = W_mult_32_32(direct_power[i], direct_responses_square[cur_idx + i]); // q_reference_power + Q31 + 1 q_tmp = W_norm(W_tmp[i]); cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl(W_tmp[i], q_tmp) ); - q_cy_auto_dir_smooth[ch_idx + i] = add(q_reference_power[i], q_tmp); + q_cy_auto_dir_smooth[cur_idx + i] = add(q_reference_power[i], q_tmp); move16(); cy_cross_dir_smooth[cur_idx + i] = Mpy_32_32(direct_power[i], direct_responses[cur_idx+i]); @@ -6905,7 +6950,25 @@ static void computeTargetPSDs_direct_subframe_fx( float f1_m = (float)m; float f1_e = powf(2, e); float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", i, m, e, f1); + fprintf(f, "%d %d %d %d %f\n", ch_idx, i, m, e, f1); + } + } + + FOR(ch_idx = 0; ch_idx < num_channels; ++ch_idx) + { + cur_idx = imult1616(ch_idx, num_freq_bands); + FOR(i = 0; i < num_freq_bands; i++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("cy_cross_dir_smooth1", "w"); + + Word32 m = cy_cross_dir_smooth[cur_idx + i]; + Word16 e = q_cy_cross_dir_smooth[cur_idx + i]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %d %f\n", ch_idx, i, m, e, f1); } } #endif -- GitLab From 3248ca7043da67574523a142a139e485bce2b56b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 11:43:58 +0100 Subject: [PATCH 10/36] fix formatting --- lib_dec/ivas_dirac_dec.c | 9 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 295 ++++++++++----------- 2 files changed, 151 insertions(+), 153 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 0691df555..ee2dc0ce5 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4979,7 +4979,6 @@ void ivas_dirac_dec_render_sf_fx( 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 ); #endif - } } @@ -5177,8 +5176,8 @@ void ivas_dirac_dec_render_sf_fx( #ifdef FIX_867 FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { - scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 - scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[ch * hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[ch * hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 } #else 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 ) ) ) ); // Q6 @@ -5196,8 +5195,8 @@ void ivas_dirac_dec_render_sf_fx( #ifdef FIX_867 FOR( Word16 l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { - scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 - scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[ch*hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_RealBuffer_fx[ch][slot_idx][l], 1, 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[ch * hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 + scale_sig32( &Cldfb_ImagBuffer_fx[ch][slot_idx][l], 1, 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[ch * hSpatParamRendCom->num_freq_bands + l], 33 ) ) ) ); // Q6 } #else 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 ) ) ) ); // Q6 diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 324f72b84..86fed2da1 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -252,10 +252,10 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } #ifdef FIX_867 - IF((dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = (Word16 *)malloc(dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_dir * sizeof(Word16))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); - } + IF( ( dirac_output_synthesis_state->q_cy_auto_diff_smooth_prev = (Word16 *) malloc( dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_dir * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } #endif dirac_output_synthesis_state->cy_auto_dir_smooth_prev_len = imult1616( dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ); move16(); @@ -343,10 +343,10 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); } #ifdef FIX_867 - IF((dirac_output_synthesis_state->gains_diff_prev_q = (Word16 *)malloc(hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof(Word16))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n")); - } + IF( ( dirac_output_synthesis_state->gains_diff_prev_q = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } #endif dirac_output_synthesis_state->gains_diff_prev_len = imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ); move16(); @@ -4051,18 +4051,18 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( FOR( ; l < num_freq_bands; l++ ) { #ifdef FIX_867_DBG - { - static FILE *f = 0; - if (f == 0) - f = fopen("p_power_smooth", "w"); - - Word32 m = *p_power_smooth; - Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; - float f1_m = (float) m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "p_power_smooth", "w" ); + + Word32 m = *p_power_smooth; + Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif /*Direct*/ @@ -4072,18 +4072,18 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( W_temp = W_add( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ), W_mult_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/ #ifdef FIX_867_DBG - { - static FILE *f = 0; - if (f == 0) - f = fopen("p_cy_auto_dir_smooth_prev", "w"); - - Word32 m = *p_cy_auto_dir_smooth_prev; - Word16 e = q_cy_auto_dir_smooth_prev_local[k*num_freq_bands + l]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "p_cy_auto_dir_smooth_prev", "w" ); + + Word32 m = *p_cy_auto_dir_smooth_prev; + Word16 e = q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif q_tmp = W_norm( W_temp ); @@ -4104,22 +4104,22 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( ( p_cy_cross_dir_smooth++ ); power_smooth_temp = L_shl( *p_power_smooth, norm_l( *p_power_smooth ) ); #ifdef FIX_867_DBG - { - static FILE *f = 0; - if (f == 0) - f = fopen("p_power_smooth1", "w"); - - Word32 m = *p_power_smooth; - Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "p_power_smooth1", "w" ); + + Word32 m = *p_power_smooth; + Word16 e = h_dirac_output_synthesis_state->proto_power_smooth_q; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif L_tmp = Mpy_32_32( power_smooth_temp, L_tmp ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), - add( q_cy_auto_dir_smooth_prev_local[k*num_freq_bands + l], q_tmp ) ), + add( q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l], q_tmp ) ), Q31 ) ); *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) @@ -4159,21 +4159,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( #ifdef FIX_867_DBG - { - static FILE *f = 0; - if (f == 0) - f = fopen("gains", "w"); - - Word32 m = *p_gains_dir; - Word16 e = h_dirac_output_synthesis_state->gains_dir_prev_q[k*num_freq_bands + l]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "gains", "w" ); + + Word32 m = *p_gains_dir; + Word16 e = h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif - p_gains_dir++; - + p_gains_dir++; /*diffuse*/ @@ -6731,11 +6730,11 @@ static void computeTargetPSDs_direct_fx( Word16 ch_idx, cur_idx; /* segment auxiliary buffer */ - Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ #ifdef FIX_867 Word32 aux_buffer_res; /* size: num_freq_bands. */ #else - Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ #endif /* estimate direct and diffuse power */ @@ -6755,28 +6754,28 @@ static void computeTargetPSDs_direct_fx( { Word16 common1_q = s_min( q_cy_auto_dir_smooth[cur_idx + l], q_reference_power[l] ); Word16 common2_q = s_min( q_cy_cross_dir_smooth[cur_idx + l], q_reference_power[l] ); - - aux_buffer_res = Mpy_32_32( direct_power[l], direct_responses_square[cur_idx + l] ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - - aux_buffer_res = L_shl( aux_buffer_res, sub( common1_q, q_reference_power[l] ) ); /* Q(common1_q) */ - cy_auto_dir_smooth[cur_idx + l] = L_shl( cy_auto_dir_smooth[cur_idx + l], sub( common1_q, q_cy_auto_dir_smooth[cur_idx + l] ) ); /* Q(common1_q) */ - - cy_auto_dir_smooth[cur_idx + l] = L_add( L_shr(cy_auto_dir_smooth[cur_idx + l],1), L_shr(aux_buffer_res,1) ); /* Q(common1_q) - Q1 */ - - aux_buffer_res = Mpy_32_32(direct_power[l], direct_responses[cur_idx + l]); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ - aux_buffer_res = L_shl( aux_buffer_res, sub( common2_q, q_reference_power[l] ) ); /* Q(common2_q) */ - cy_cross_dir_smooth[cur_idx + l] = L_shl( cy_cross_dir_smooth[cur_idx + l], sub( common2_q, q_cy_cross_dir_smooth[cur_idx + l] ) ); /* Q(common2_q) */ - - cy_cross_dir_smooth[cur_idx + l] = L_add( L_shr(cy_cross_dir_smooth[cur_idx + l],1), L_shr(aux_buffer_res,1) ); /* Q(common2_q) - Q1 */ - - Word16 q_tmp = norm_l(cy_auto_dir_smooth[cur_idx + l]); - cy_auto_dir_smooth[cur_idx + l] = L_shl(cy_auto_dir_smooth[cur_idx + l], q_tmp); - q_cy_auto_dir_smooth[cur_idx + l] = add(sub(common1_q, Q1), q_tmp); + + aux_buffer_res = Mpy_32_32( direct_power[l], direct_responses_square[cur_idx + l] ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + + aux_buffer_res = L_shl( aux_buffer_res, sub( common1_q, q_reference_power[l] ) ); /* Q(common1_q) */ + cy_auto_dir_smooth[cur_idx + l] = L_shl( cy_auto_dir_smooth[cur_idx + l], sub( common1_q, q_cy_auto_dir_smooth[cur_idx + l] ) ); /* Q(common1_q) */ + + cy_auto_dir_smooth[cur_idx + l] = L_add( L_shr( cy_auto_dir_smooth[cur_idx + l], 1 ), L_shr( aux_buffer_res, 1 ) ); /* Q(common1_q) - Q1 */ + + aux_buffer_res = Mpy_32_32( direct_power[l], direct_responses[cur_idx + l] ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + aux_buffer_res = L_shl( aux_buffer_res, sub( common2_q, q_reference_power[l] ) ); /* Q(common2_q) */ + cy_cross_dir_smooth[cur_idx + l] = L_shl( cy_cross_dir_smooth[cur_idx + l], sub( common2_q, q_cy_cross_dir_smooth[cur_idx + l] ) ); /* Q(common2_q) */ + + cy_cross_dir_smooth[cur_idx + l] = L_add( L_shr( cy_cross_dir_smooth[cur_idx + l], 1 ), L_shr( aux_buffer_res, 1 ) ); /* Q(common2_q) - Q1 */ + + Word16 q_tmp = norm_l( cy_auto_dir_smooth[cur_idx + l] ); + cy_auto_dir_smooth[cur_idx + l] = L_shl( cy_auto_dir_smooth[cur_idx + l], q_tmp ); + q_cy_auto_dir_smooth[cur_idx + l] = add( sub( common1_q, Q1 ), q_tmp ); move16(); - q_tmp = norm_l(cy_cross_dir_smooth[cur_idx + l]); - cy_cross_dir_smooth[cur_idx + l] = L_shl(cy_cross_dir_smooth[cur_idx + l], q_tmp); - q_cy_cross_dir_smooth[cur_idx + l] = add(sub( common2_q, Q1 ), q_tmp); + q_tmp = norm_l( cy_cross_dir_smooth[cur_idx + l] ); + cy_cross_dir_smooth[cur_idx + l] = L_shl( cy_cross_dir_smooth[cur_idx + l], q_tmp ); + q_cy_cross_dir_smooth[cur_idx + l] = add( sub( common2_q, Q1 ), q_tmp ); move16(); } @@ -6862,19 +6861,19 @@ static void computeTargetPSDs_direct_subframe_fx( Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ #ifdef FIX_867_DBG - FOR(i = 0; i < num_freq_bands; i++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("reference_power_smooth_fx", "w"); + FOR( i = 0; i < num_freq_bands; i++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "reference_power_smooth_fx", "w" ); - Word32 m = reference_power[i]; - Word16 e = q_reference_power[i]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", i, m, e, f1); - } + Word32 m = reference_power[i]; + Word16 e = q_reference_power[i]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", i, m, e, f1 ); + } #endif /* estimate direct and diffuse power */ @@ -6894,17 +6893,17 @@ static void computeTargetPSDs_direct_subframe_fx( { cur_idx = imult1616( ch_idx, num_freq_bands ); #ifdef FIX_867 - FOR(i = 0; i < num_freq_bands; i++) - { - W_tmp[i] = W_mult_32_32(direct_power[i], direct_responses_square[cur_idx + i]); // q_reference_power + Q31 + 1 - q_tmp = W_norm(W_tmp[i]); - cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl(W_tmp[i], q_tmp) ); - q_cy_auto_dir_smooth[cur_idx + i] = add(q_reference_power[i], q_tmp); - move16(); - - cy_cross_dir_smooth[cur_idx + i] = Mpy_32_32(direct_power[i], direct_responses[cur_idx+i]); - q_cy_cross_dir_smooth[cur_idx + i] = q_reference_power[i]; - } + FOR( i = 0; i < num_freq_bands; i++ ) + { + W_tmp[i] = W_mult_32_32( direct_power[i], direct_responses_square[cur_idx + i] ); // q_reference_power + Q31 + 1 + q_tmp = W_norm( W_tmp[i] ); + cy_auto_dir_smooth[cur_idx + i] = W_extract_h( W_shl( W_tmp[i], q_tmp ) ); + q_cy_auto_dir_smooth[cur_idx + i] = add( q_reference_power[i], q_tmp ); + move16(); + + cy_cross_dir_smooth[cur_idx + i] = Mpy_32_32( direct_power[i], direct_responses[cur_idx + i] ); + q_cy_cross_dir_smooth[cur_idx + i] = q_reference_power[i]; + } #else W_max = 0; move64(); @@ -6931,46 +6930,46 @@ static void computeTargetPSDs_direct_subframe_fx( #ifndef FIX_867 *q_cy_cross_dir_smooth = *q_reference_power; - move16(); + move16(); #endif #ifdef FIX_867_DBG - FOR(ch_idx = 0; ch_idx < num_channels; ++ch_idx) - { - cur_idx = imult1616(ch_idx, num_freq_bands); - FOR(i = 0; i < num_freq_bands; i++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("cy_auto_dir_smooth1", "w"); - - Word32 m = cy_auto_dir_smooth[cur_idx + i]; - Word16 e = q_cy_auto_dir_smooth[cur_idx + i]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %d %f\n", ch_idx, i, m, e, f1); - } - } - - FOR(ch_idx = 0; ch_idx < num_channels; ++ch_idx) - { - cur_idx = imult1616(ch_idx, num_freq_bands); - FOR(i = 0; i < num_freq_bands; i++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("cy_cross_dir_smooth1", "w"); - - Word32 m = cy_cross_dir_smooth[cur_idx + i]; - Word16 e = q_cy_cross_dir_smooth[cur_idx + i]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %d %f\n", ch_idx, i, m, e, f1); - } - } + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + cur_idx = imult1616( ch_idx, num_freq_bands ); + FOR( i = 0; i < num_freq_bands; i++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "cy_auto_dir_smooth1", "w" ); + + Word32 m = cy_auto_dir_smooth[cur_idx + i]; + Word16 e = q_cy_auto_dir_smooth[cur_idx + i]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %d %f\n", ch_idx, i, m, e, f1 ); + } + } + + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + cur_idx = imult1616( ch_idx, num_freq_bands ); + FOR( i = 0; i < num_freq_bands; i++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "cy_cross_dir_smooth1", "w" ); + + Word32 m = cy_cross_dir_smooth[cur_idx + i]; + Word16 e = q_cy_cross_dir_smooth[cur_idx + i]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %d %f\n", ch_idx, i, m, e, f1 ); + } + } #endif return; @@ -7124,14 +7123,14 @@ static void computeTargetPSDs_diffuse_subframe_fx( cur_idx = imult1616( ch_idx, num_freq_bands ); v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power -#ifdef FIX_867 - FOR(Word16 i=0;i Date: Wed, 20 Nov 2024 11:56:56 +0100 Subject: [PATCH 11/36] fix encapsulation --- lib_rend/ivas_dirac_output_synthesis_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 86fed2da1..137ccc724 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -4119,7 +4119,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( #endif L_tmp = Mpy_32_32( power_smooth_temp, L_tmp ); // proto_power_smooth_q + norm_l( *p_power_smooth ) ) + q_cy_auto_dir_smooth_prev_local - 31 exp = sub( Q31, sub( add( add( h_dirac_output_synthesis_state->proto_power_smooth_q, norm_l( *p_power_smooth ) ), +#ifdef FIX_867 add( q_cy_auto_dir_smooth_prev_local[k * num_freq_bands + l], q_tmp ) ), +#else + add( q_cy_auto_dir_smooth_prev_local[k], q_tmp ) ), +#endif Q31 ) ); *( p_gains_dir ) = Sqrt32( L_tmp, &exp ); // (Q31 - exp) -- GitLab From 3ebcda9b1a922295d5fd759e3b0941788314c05a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 14:16:06 +0100 Subject: [PATCH 12/36] fix diffuseness calculation --- lib_com/ivas_dirac_com.c | 28 ++++++++++++++++++++-- lib_dec/ivas_dirac_dec.c | 11 +++++++-- lib_rend/ivas_dirac_output_synthesis_dec.c | 2 ++ lib_rend/ivas_stat_rend.h | 6 ++++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index aea7d7664..fddad1cf7 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1372,8 +1372,13 @@ void computeDiffuseness_fixed( /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ min_q_shift1 = Q31; move16(); +#ifndef FIX_867 min_q_shift1 = s_min( min_q_shift1, getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ); - min_q_shift1 = sub( min_q_shift1, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); + min_q_shift1 = sub(min_q_shift1, find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF)); +#else + min_q_shift1 = find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF); +#endif + min_q_shift2 = Q31; move16(); @@ -1386,20 +1391,33 @@ void computeDiffuseness_fixed( } min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); +#ifdef FIX_867 + q_ene = min_q_shift1; +#else q_ene = add( q_factor_energy[0], min_q_shift1 ); +#endif move16(); q_intensity = add( q_factor_intensity[0], min_q_shift2 ); move16(); + FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; +#ifndef FIX_867 q_tmp = add( q_factor_energy[i], min_q_shift1 ); +#endif FOR( k = 0; k < num_freq_bands; k++ ) { +#ifdef FIX_867 + q_tmp = add(q_factor_energy[i*num_freq_bands + k], min_q_shift1); + tmp = L_shr(p_tmp_c[k], min_q_shift1); +#else tmp = L_shl( p_tmp_c[k], min_q_shift1 ); +#endif + IF( LT_16( q_tmp, q_ene ) ) { energy_slow[k] = L_add( L_shr( energy_slow[k], sub( q_ene, q_tmp ) ), tmp ); @@ -1410,11 +1428,18 @@ void computeDiffuseness_fixed( energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, sub( q_tmp, q_ene ) ) ); move32(); } +#ifdef FIX_867 + q_ene = s_min(q_ene, q_tmp); +#endif } +#ifndef FIX_867 q_ene = s_min( q_ene, q_tmp ); +#endif /* Intensity slow */ +#ifndef FIX_867 q_tmp = add( q_factor_intensity[i], min_q_shift2 ); +#endif FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; @@ -1433,7 +1458,6 @@ void computeDiffuseness_fixed( } } } - q_intensity = s_min( q_intensity, q_tmp ); } min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ee2dc0ce5..a61ecbe2c 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -978,7 +978,11 @@ static ivas_error ivas_dirac_rend_config_fx( } } set32_fx( hDirACRend->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); - set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF ); +#ifdef FIX_867 + set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX); +#else + set16_fx(hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF); +#endif } ELSE IF( ( EQ_16( flag_config, DIRAC_OPEN ) && hDirAC->hConfig->dec_param_estim == FALSE ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( ( hDirAC->hConfig->dec_param_estim == FALSE ) && EQ_16( dec_param_estim_old, TRUE ) ) ) ) { @@ -4624,7 +4628,10 @@ void ivas_dirac_dec_render_sf_fx( Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); #ifdef FIX_867 - hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0]; + FOR(Word16 kk=0;kkq_buffer_energy[(index - 1)*num_freq_bands + kk] = DirAC_mem.reference_power_q[kk]; + } #else hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q; #endif diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 137ccc724..d19a46e32 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2644,8 +2644,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ #endif } +#ifndef FIX_867 h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); +#endif FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 4170a44cc..5d21ae139 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -712,7 +712,11 @@ typedef struct ivas_dirac_rend_data_structure Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; /* Q(q_buffer_intensity_real[]) */ Word16 q_buffer_intensity_real[DIRAC_NO_COL_AVG_DIFF]; Word32 *buffer_energy_fx; /* Q(q_buffer_energy[]) */ - Word16 q_buffer_energy[DIRAC_NO_COL_AVG_DIFF]; +#ifdef FIX_867 + Word16 q_buffer_energy[CLDFB_NO_CHANNELS_MAX*DIRAC_NO_COL_AVG_DIFF]; +#else + Word16 q_buffer_energy[DIRAC_NO_COL_AVG_DIFF]; +#endif #endif #ifndef IVAS_FLOAT_FIXED -- GitLab From 9490da5d9795478ff87607c900711d3524682989 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 14:17:01 +0100 Subject: [PATCH 13/36] fix formatting --- lib_com/ivas_dirac_com.c | 12 ++++++------ lib_dec/ivas_dirac_dec.c | 12 ++++++------ lib_rend/ivas_stat_rend.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index fddad1cf7..3028ef935 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1374,9 +1374,9 @@ void computeDiffuseness_fixed( move16(); #ifndef FIX_867 min_q_shift1 = s_min( min_q_shift1, getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ); - min_q_shift1 = sub(min_q_shift1, find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF)); + min_q_shift1 = sub( min_q_shift1, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); #else - min_q_shift1 = find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF); + min_q_shift1 = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); #endif @@ -1392,7 +1392,7 @@ void computeDiffuseness_fixed( min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); #ifdef FIX_867 - q_ene = min_q_shift1; + q_ene = min_q_shift1; #else q_ene = add( q_factor_energy[0], min_q_shift1 ); #endif @@ -1412,8 +1412,8 @@ void computeDiffuseness_fixed( FOR( k = 0; k < num_freq_bands; k++ ) { #ifdef FIX_867 - q_tmp = add(q_factor_energy[i*num_freq_bands + k], min_q_shift1); - tmp = L_shr(p_tmp_c[k], min_q_shift1); + q_tmp = add( q_factor_energy[i * num_freq_bands + k], min_q_shift1 ); + tmp = L_shr( p_tmp_c[k], min_q_shift1 ); #else tmp = L_shl( p_tmp_c[k], min_q_shift1 ); #endif @@ -1429,7 +1429,7 @@ void computeDiffuseness_fixed( move32(); } #ifdef FIX_867 - q_ene = s_min(q_ene, q_tmp); + q_ene = s_min( q_ene, q_tmp ); #endif } #ifndef FIX_867 diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index a61ecbe2c..ad27a06b4 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -979,9 +979,9 @@ static ivas_error ivas_dirac_rend_config_fx( } set32_fx( hDirACRend->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); #ifdef FIX_867 - set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX); + set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); #else - set16_fx(hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF); + set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF ); #endif } ELSE IF( ( EQ_16( flag_config, DIRAC_OPEN ) && hDirAC->hConfig->dec_param_estim == FALSE ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( ( hDirAC->hConfig->dec_param_estim == FALSE ) && EQ_16( dec_param_estim_old, TRUE ) ) ) ) @@ -4628,10 +4628,10 @@ void ivas_dirac_dec_render_sf_fx( Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); #ifdef FIX_867 - FOR(Word16 kk=0;kkq_buffer_energy[(index - 1)*num_freq_bands + kk] = DirAC_mem.reference_power_q[kk]; - } + FOR( Word16 kk = 0; kk < num_freq_bands; kk++ ) + { + hDirACRend->q_buffer_energy[( index - 1 ) * num_freq_bands + kk] = DirAC_mem.reference_power_q[kk]; + } #else hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q; #endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 5d21ae139..362c7d032 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -713,9 +713,9 @@ typedef struct ivas_dirac_rend_data_structure Word16 q_buffer_intensity_real[DIRAC_NO_COL_AVG_DIFF]; Word32 *buffer_energy_fx; /* Q(q_buffer_energy[]) */ #ifdef FIX_867 - Word16 q_buffer_energy[CLDFB_NO_CHANNELS_MAX*DIRAC_NO_COL_AVG_DIFF]; + Word16 q_buffer_energy[CLDFB_NO_CHANNELS_MAX * DIRAC_NO_COL_AVG_DIFF]; #else - Word16 q_buffer_energy[DIRAC_NO_COL_AVG_DIFF]; + Word16 q_buffer_energy[DIRAC_NO_COL_AVG_DIFF]; #endif #endif -- GitLab From 9e1250bb1a5d7f2af564d58d964cea5bd93dbaaf Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 14:37:03 +0100 Subject: [PATCH 14/36] fix compiler warning --- lib_rend/ivas_dirac_output_synthesis_dec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index d19a46e32..da980a502 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -6860,7 +6860,10 @@ static void computeTargetPSDs_direct_subframe_fx( Word16 *q_cy_cross_dir_smooth ) { Word16 ch_idx, cur_idx, i, q_tmp; - Word64 W_tmp[CLDFB_NO_CHANNELS_MAX], W_max; + Word64 W_tmp[CLDFB_NO_CHANNELS_MAX]; +#ifndef FIX_867 + Word64 W_max; +#endif set64_fx( W_tmp, 0, CLDFB_NO_CHANNELS_MAX ); /* segment auxiliary buffer */ -- GitLab From 3762a6899d8489a3f60d1ab87009d842e3faf7a6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 14:59:55 +0100 Subject: [PATCH 15/36] fix memory bug --- lib_rend/ivas_dirac_rend.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index de975656d..4db057765 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1291,10 +1291,14 @@ ivas_error ivas_dirac_alloc_mem_fx( /* PSD related buffers */ hDirAC_mem->cy_auto_dir_smooth_fx = NULL; +#ifdef FIX_867 + hDirAC_mem->q_cy_auto_dir_smooth = NULL; +#endif hDirAC_mem->proto_power_smooth_fx = NULL; hDirAC_mem->proto_power_diff_smooth_fx = NULL; hDirAC_mem->direct_responses_square_fx = NULL; hDirAC_mem->frame_dec_f_fx = NULL; + IF( NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { IF( ( hDirAC_mem->cy_auto_dir_smooth_fx = (Word32 *) malloc( sizeof( Word32 ) * size ) ) == NULL ) @@ -1368,7 +1372,10 @@ ivas_error ivas_dirac_alloc_mem_fx( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx = hDirAC_mem->cy_auto_dir_smooth_fx; #ifdef FIX_867 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = hDirAC_mem->q_cy_auto_dir_smooth; - set16_zero_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); + if (hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth ) + { + set16_zero_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); + } #else hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = 0; #endif -- GitLab From a24b1371a151a3e81f76cd7808b543e6ebae1b63 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 15:30:43 +0100 Subject: [PATCH 16/36] set all Q values for the reference power in 4 TC cases --- lib_dec/ivas_dirac_dec.c | 3 +++ lib_rend/ivas_dirac_output_synthesis_dec.c | 13 +++++++++++-- lib_rend/ivas_dirac_rend.c | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ad27a06b4..a4725453f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5840,6 +5840,9 @@ void ivas_dirac_dec_render_sf_fx( { hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[l] = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l]; move16(); + } + FOR( Word16 l = 0; l < hDirACRend->h_output_synthesis_psd_params.max_band_decorr; l++) + { hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[l] = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[l]; move16(); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index da980a502..186e97f84 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -957,12 +957,21 @@ void ivas_dirac_dec_output_synthesis_init_fx( IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { set32_fx( h_dirac_output_synthesis_state->gains_diff_prev_fx, 0, imult1616( h_dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ) ); - } +#ifdef FIX_867 + if (h_dirac_output_synthesis_state->gains_diff_prev_q) + { + set16_zero_fx(h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff); + } +#endif + } ELSE { set32_fx( h_dirac_output_synthesis_state->gains_diff_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); #ifdef FIX_867 - set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); + if (h_dirac_output_synthesis_state->gains_diff_prev_q) + { + set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); + } #endif } #ifndef FIX_867 diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 4db057765..d08c88cb7 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -2519,10 +2519,15 @@ void protoSignalComputation_shd_fx( reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[idx1], 1 ) ); /*2*Q(q_cldfb+min_q_shift)-31-1*/ move32(); +#ifdef FIX_867 + reference_power_q[l] = sub(add(*proto_direct_buffer_f_q, *proto_direct_buffer_f_q), 31); +#endif } *proto_direct_buffer_f_q = add( q_cldfb, min_q_shift ); +#ifndef FIX_867 *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); +#endif FOR( k = 1; k < 4; k++ ) { @@ -2552,12 +2557,19 @@ void protoSignalComputation_shd_fx( move32(); reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[l + ( k + 1 ) * num_freq_bands], 1 ) ); // 2*(q_cldfb+min_q_shift)-31-1 move32(); + +#ifdef FIX_867 + reference_power_q[l] = sub(add(add(q_cldfb, min_q_shift), add(q_cldfb, min_q_shift)), 31); + move16(); +#endif } } *proto_direct_buffer_f_q = q_cldfb; move16(); +#ifndef FIX_867 *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); +#endif } /* Additional transport channels = planar SBA components of degree higher than 1*/ -- GitLab From 6893d370431f30b2d89f827cefeba1eeeedb0a82 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 15:31:26 +0100 Subject: [PATCH 17/36] fix formatting --- lib_dec/ivas_dirac_dec.c | 6 +++--- lib_rend/ivas_dirac_output_synthesis_dec.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index a4725453f..8d4cab9c6 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5840,9 +5840,9 @@ void ivas_dirac_dec_render_sf_fx( { hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q[l] = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l]; move16(); - } - FOR( Word16 l = 0; l < hDirACRend->h_output_synthesis_psd_params.max_band_decorr; l++) - { + } + FOR( Word16 l = 0; l < hDirACRend->h_output_synthesis_psd_params.max_band_decorr; l++ ) + { hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q[l] = hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev[l]; move16(); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 186e97f84..477708f97 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -958,20 +958,20 @@ void ivas_dirac_dec_output_synthesis_init_fx( { set32_fx( h_dirac_output_synthesis_state->gains_diff_prev_fx, 0, imult1616( h_dirac_output_synthesis_params->max_band_decorr, hDirACRend->num_outputs_diff ) ); #ifdef FIX_867 - if (h_dirac_output_synthesis_state->gains_diff_prev_q) - { - set16_zero_fx(h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff); - } + if ( h_dirac_output_synthesis_state->gains_diff_prev_q ) + { + set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); + } #endif - } + } ELSE { set32_fx( h_dirac_output_synthesis_state->gains_diff_prev_fx, 0, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_dir ) ); #ifdef FIX_867 - if (h_dirac_output_synthesis_state->gains_diff_prev_q) - { - set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); - } + if ( h_dirac_output_synthesis_state->gains_diff_prev_q ) + { + set16_zero_fx( h_dirac_output_synthesis_state->gains_diff_prev_q, h_dirac_output_synthesis_params->max_band_decorr * hDirACRend->num_outputs_diff ); + } #endif } #ifndef FIX_867 @@ -6871,7 +6871,7 @@ static void computeTargetPSDs_direct_subframe_fx( Word16 ch_idx, cur_idx, i, q_tmp; Word64 W_tmp[CLDFB_NO_CHANNELS_MAX]; #ifndef FIX_867 - Word64 W_max; + Word64 W_max; #endif set64_fx( W_tmp, 0, CLDFB_NO_CHANNELS_MAX ); -- GitLab From b98b50d291f5c0bbf52782cd82acccf07cfbaf16 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Nov 2024 17:19:02 +0100 Subject: [PATCH 18/36] fix out-of-bounds access --- lib_rend/ivas_dirac_output_synthesis_dec.c | 5 +++-- lib_rend/ivas_dirac_rend.c | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 477708f97..95491a2dd 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2010,7 +2010,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) { - Scale_sig32( &aux_buf[ch_idx * num_freq_bands + k], 1, sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], temp_q ) ); + aux_buf[k] = + L_shl( aux_buf[k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } } @@ -2036,7 +2037,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands_diff ); /* h_dirac_output_synthesis_state->diffuse_power_factor_q+15-15*/ temp_q = h_dirac_output_synthesis_state->diffuse_power_factor_q; #ifdef FIX_867 - FOR( Word16 k = 0; k < num_freq_bands; k++ ) + FOR( Word16 k = 0; k < num_freq_bands_diff; k++ ) { IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[ch_idx * num_freq_bands + k] ) ) { diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index d08c88cb7..1b8922b01 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -2519,13 +2519,12 @@ void protoSignalComputation_shd_fx( reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[idx1], 1 ) ); /*2*Q(q_cldfb+min_q_shift)-31-1*/ move32(); -#ifdef FIX_867 - reference_power_q[l] = sub(add(*proto_direct_buffer_f_q, *proto_direct_buffer_f_q), 31); -#endif } *proto_direct_buffer_f_q = add( q_cldfb, min_q_shift ); -#ifndef FIX_867 +#ifdef FIX_867 + reference_power_q[l] = sub(add(*proto_direct_buffer_f_q, *proto_direct_buffer_f_q), 31); +#else *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); #endif -- GitLab From 0a2bad9b802f2c338bf2f0579e34ecbdb5374d6b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 22 Nov 2024 16:18:45 +0100 Subject: [PATCH 19/36] remove temporary Q array Q_temp_cy_cross_dir_smooth_fx --- lib_com/options.h | 4 +- lib_dec/ivas_dirac_dec.c | 6 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 83 +++++++++++++--------- lib_rend/ivas_dirac_rend.c | 31 ++++++-- 4 files changed, 81 insertions(+), 43 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1badae941..c1d0f40dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,8 +200,8 @@ #define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* FhG: fixes for decoder-side noise level estimation in MDCT-Stereo to prevent noise bursts in stereo switching */ /* ################## End DEVELOPMENT switches ######################### */ -//#define FIX_867 -//#define FIX_867_DBG +#define FIX_867 +#define FIX_867_DBG /* clang-format on */ #define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 8d4cab9c6..083d0cf96 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -5068,12 +5068,14 @@ void ivas_dirac_dec_render_sf_fx( { IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l], Q26 ) ) { - hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] = Q26; } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l], Q26 ) ) { - hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l] = L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] = Q26; } } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 95491a2dd..f7ec9b27d 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1609,20 +1609,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ /*Direct gain*/ - +#ifndef FIX_867 Word16 *Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); - tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { -#ifdef FIX_867 - Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk]; - move16(); -#else Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); -#endif } +#endif FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) { @@ -1702,13 +1697,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; move16(); } #else @@ -1733,8 +1727,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/ move32(); +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); +#else Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); +#endif } } FOR( ; k < num_freq_bands; k++ ) @@ -1803,13 +1801,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; move16(); } h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ @@ -1834,10 +1831,16 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ - move32(); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + move32(); +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); + move16(); +#else Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); +#endif } } } @@ -1859,16 +1862,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( #ifdef FIX_867 IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; - move16(); } h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); @@ -1892,10 +1894,18 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ - move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); - move16(); +#ifdef FIX_867 + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; /*Q(31-sqr_exp)*/ + move32(); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); +#else + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); + move16(); +#endif + } } FOR( ; k < num_freq_bands; k++ ) @@ -1910,16 +1920,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( #ifdef FIX_867 IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE { sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k]; - move16(); } #else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) @@ -1936,39 +1945,47 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } #endif - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); + /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ move32(); +#ifdef FIX_867 + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); +#else Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); +#endif move16(); } } } } + + tmp16 = imult1616(num_freq_bands, num_channels_dir); + +#ifndef FIX_867 Word16 temp = MAX_16; /*q0*/ move16(); - tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { temp = s_min( Q_temp_cy_cross_dir_smooth_fx[kk], temp ); } -#ifndef FIX_867 h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp; -#endif move16(); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = + L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ move32(); -#ifdef FIX_867 h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = temp; -#endif } free( Q_temp_cy_cross_dir_smooth_fx ); +#endif /*Directional gain (panning)*/ Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); #ifdef FIX_867 diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 1b8922b01..94026ff5d 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -2523,7 +2523,8 @@ void protoSignalComputation_shd_fx( *proto_direct_buffer_f_q = add( q_cldfb, min_q_shift ); #ifdef FIX_867 - reference_power_q[l] = sub(add(*proto_direct_buffer_f_q, *proto_direct_buffer_f_q), 31); + reference_power_q[l] = add(sub(add(*proto_direct_buffer_f_q, *proto_direct_buffer_f_q), 31), norm_l(reference_power_fx[l])); + reference_power_fx[l] = L_shl( reference_power_fx[l], norm_l(reference_power_fx[l]) ); #else *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); #endif @@ -2557,15 +2558,17 @@ void protoSignalComputation_shd_fx( reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[l + ( k + 1 ) * num_freq_bands], 1 ) ); // 2*(q_cldfb+min_q_shift)-31-1 move32(); -#ifdef FIX_867 - reference_power_q[l] = sub(add(add(q_cldfb, min_q_shift), add(q_cldfb, min_q_shift)), 31); - move16(); -#endif } } *proto_direct_buffer_f_q = q_cldfb; move16(); -#ifndef FIX_867 +#ifdef FIX_867 + FOR(l = 0; l < num_freq_bands; l++) + { + reference_power_q[l] = add(sub(add(add(q_cldfb, min_q_shift), add(q_cldfb, min_q_shift)), 31), norm_l(reference_power_fx[l]) ); + reference_power_fx[l] = L_shl(reference_power_fx[l], norm_l(reference_power_fx[l])); + } +#else *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); #endif @@ -2602,6 +2605,22 @@ void protoSignalComputation_shd_fx( } } +#ifdef FIX_867_DBG + FOR(l = 0; l < num_freq_bands; l++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("reference_power_fx", "w"); + + Word32 m = reference_power_fx[l]; + Word16 e = reference_power_q[l]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif + return; } #else -- GitLab From 3a2823183cad1e80d81770ac358d5d9c971260de Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 22 Nov 2024 16:48:57 +0100 Subject: [PATCH 20/36] fix formatting --- lib_rend/ivas_dirac_output_synthesis_dec.c | 63 +++++++++++----------- lib_rend/ivas_dirac_rend.c | 51 +++++++++--------- 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index f7ec9b27d..d7e2c1902 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1697,7 +1697,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ move32(); - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE @@ -1728,7 +1728,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/ move32(); #ifdef FIX_867 - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); #else Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); @@ -1801,7 +1801,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ move32(); - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE @@ -1831,12 +1831,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ - move32(); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + move32(); #ifdef FIX_867 - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); - move16(); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); #else Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); @@ -1862,8 +1862,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( #ifdef FIX_867 IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ move32(); h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); @@ -1895,17 +1895,16 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( ELSE { #ifdef FIX_867 - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; /*Q(31-sqr_exp)*/ - move32(); - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; /*Q(31-sqr_exp)*/ + move32(); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); #else - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ - move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); - move16(); + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + move16(); #endif - } } FOR( ; k < num_freq_bands; k++ ) @@ -1920,10 +1919,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( #ifdef FIX_867 IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ move32(); - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } ELSE @@ -1945,18 +1944,18 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } #endif - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); - /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); + /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } ELSE { h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ move32(); #ifdef FIX_867 - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub(31, sqr_exp); + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); #else Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); #endif @@ -1966,7 +1965,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } - tmp16 = imult1616(num_freq_bands, num_channels_dir); + tmp16 = imult1616( num_freq_bands, num_channels_dir ); #ifndef FIX_867 Word16 temp = MAX_16; /*q0*/ @@ -1979,8 +1978,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = - L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = + L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ move32(); h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = temp; } @@ -2027,8 +2026,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( NE_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ) { - aux_buf[k] = - L_shl( aux_buf[k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], temp_q ) ); + aux_buf[k] = + L_shl( aux_buf[k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k], temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ } } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 94026ff5d..172727254 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1292,7 +1292,7 @@ ivas_error ivas_dirac_alloc_mem_fx( /* PSD related buffers */ hDirAC_mem->cy_auto_dir_smooth_fx = NULL; #ifdef FIX_867 - hDirAC_mem->q_cy_auto_dir_smooth = NULL; + hDirAC_mem->q_cy_auto_dir_smooth = NULL; #endif hDirAC_mem->proto_power_smooth_fx = NULL; hDirAC_mem->proto_power_diff_smooth_fx = NULL; @@ -1372,10 +1372,10 @@ ivas_error ivas_dirac_alloc_mem_fx( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_fx = hDirAC_mem->cy_auto_dir_smooth_fx; #ifdef FIX_867 hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = hDirAC_mem->q_cy_auto_dir_smooth; - if (hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth ) - { - set16_zero_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); - } + if ( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth ) + { + set16_zero_fx( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth, hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_len ); + } #else hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth = 0; #endif @@ -2523,8 +2523,8 @@ void protoSignalComputation_shd_fx( *proto_direct_buffer_f_q = add( q_cldfb, min_q_shift ); #ifdef FIX_867 - reference_power_q[l] = add(sub(add(*proto_direct_buffer_f_q, *proto_direct_buffer_f_q), 31), norm_l(reference_power_fx[l])); - reference_power_fx[l] = L_shl( reference_power_fx[l], norm_l(reference_power_fx[l]) ); + reference_power_q[l] = add( sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ), norm_l( reference_power_fx[l] ) ); + reference_power_fx[l] = L_shl( reference_power_fx[l], norm_l( reference_power_fx[l] ) ); #else *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); #endif @@ -2557,17 +2557,16 @@ void protoSignalComputation_shd_fx( move32(); reference_power_fx[l] = L_add( reference_power_fx[l], L_shr( reference_power_fx[l + ( k + 1 ) * num_freq_bands], 1 ) ); // 2*(q_cldfb+min_q_shift)-31-1 move32(); - } } *proto_direct_buffer_f_q = q_cldfb; move16(); #ifdef FIX_867 - FOR(l = 0; l < num_freq_bands; l++) - { - reference_power_q[l] = add(sub(add(add(q_cldfb, min_q_shift), add(q_cldfb, min_q_shift)), 31), norm_l(reference_power_fx[l]) ); - reference_power_fx[l] = L_shl(reference_power_fx[l], norm_l(reference_power_fx[l])); - } + FOR( l = 0; l < num_freq_bands; l++ ) + { + reference_power_q[l] = add( sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ), norm_l( reference_power_fx[l] ) ); + reference_power_fx[l] = L_shl( reference_power_fx[l], norm_l( reference_power_fx[l] ) ); + } #else *reference_power_q = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); move16(); @@ -2606,19 +2605,19 @@ void protoSignalComputation_shd_fx( } #ifdef FIX_867_DBG - FOR(l = 0; l < num_freq_bands; l++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("reference_power_fx", "w"); - - Word32 m = reference_power_fx[l]; - Word16 e = reference_power_q[l]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + FOR( l = 0; l < num_freq_bands; l++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "reference_power_fx", "w" ); + + Word32 m = reference_power_fx[l]; + Word16 e = reference_power_q[l]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif return; -- GitLab From 2875f268c888f349a534c3a8a87e4ff03befcb01 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 26 Nov 2024 12:24:19 +0100 Subject: [PATCH 21/36] add debug code --- lib_rend/ivas_dirac_output_synthesis_dec.c | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index d7e2c1902..b1d875ff5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1872,7 +1872,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); #else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) @@ -2042,6 +2043,22 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], &h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ + +#ifdef FIX_867_DBG + FOR(Word16 l = 0; l < num_freq_bands; l++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("cy_cross_dir_smooth1", "w"); + + Word32 m = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands_diff + l]; + Word16 e = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands_diff + l]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif } /*Diffuse gain*/ @@ -2070,6 +2087,20 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ + + FOR(Word16 l = 0; l < num_freq_bands; l++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("cy_auto_diff_smooth1", "w"); + + Word32 m = h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l]; + Word16 e = h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[ch_idx * num_freq_bands_diff + l]; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } } return; -- GitLab From 33aefa01ec41d0f49e249317b00459cbb6cd5440 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 28 Nov 2024 14:35:03 +0100 Subject: [PATCH 22/36] fix diffuseness calculation --- lib_com/ivas_dirac_com.c | 98 +++++++++++++++++----- lib_dec/ivas_dirac_dec.c | 11 ++- lib_rend/ivas_dirac_output_synthesis_dec.c | 22 ++++- 3 files changed, 103 insertions(+), 28 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 3028ef935..8d52247ca 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1360,8 +1360,16 @@ void computeDiffuseness_fixed( move32(); Word32 *p_tmp; const Word32 *p_tmp_c; +#ifdef FIX_867 + const Word16 *p_q_tmp_c; +#endif Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; - Word16 q_ene, q_intensity, q_intensity_slow; +#ifdef FIX_867 + Word16 q_ene[CLDFB_NO_CHANNELS_MAX]; +#else + Word16 q_ene; +#endif + Word16 q_intensity, q_intensity_slow; /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ @@ -1370,16 +1378,15 @@ void computeDiffuseness_fixed( set_zero_fx( energy_slow, CLDFB_NO_CHANNELS_MAX ); /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ +#ifdef FIX_867 + min_q_shift1 = find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF); +#else min_q_shift1 = Q31; move16(); -#ifndef FIX_867 min_q_shift1 = s_min( min_q_shift1, getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ); min_q_shift1 = sub( min_q_shift1, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); -#else - min_q_shift1 = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); #endif - min_q_shift2 = Q31; move16(); FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) @@ -1390,9 +1397,8 @@ void computeDiffuseness_fixed( } } min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); - #ifdef FIX_867 - q_ene = min_q_shift1; + set16_fx( q_ene, Q31 - find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF), num_freq_bands ); #else q_ene = add( q_factor_energy[0], min_q_shift1 ); #endif @@ -1400,24 +1406,49 @@ void computeDiffuseness_fixed( q_intensity = add( q_factor_intensity[0], min_q_shift2 ); move16(); - FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { +#ifdef FIX_867 + p_tmp_c = buffer_energy + i * num_freq_bands; + p_q_tmp_c = q_factor_energy + i * num_freq_bands; + FOR(k = 0; k < num_freq_bands; k++) + { + /* Energy slow */ + Word32 tmp1; + Word16 tmp1_q; + +#ifdef FIX_867_DBG + assert(norm_l(p_tmp_c[k])==0); + assert(p_tmp_c[k]>=0); +#endif + + tmp1 = L_shr(p_tmp_c[k], min_q_shift1); + tmp1_q = sub(p_q_tmp_c[k], min_q_shift1); + + IF( LT_16(tmp1_q, q_ene[k]) ) + { + energy_slow[k] = L_shr(energy_slow[k], sub(q_ene[k], tmp1_q)); + q_ene[k] = tmp1_q; + + energy_slow[k] = L_add(energy_slow[k], tmp1); + } + ELSE + { + tmp1 = L_shr( tmp1, sub(tmp1_q, q_ene[k]) ); + energy_slow[k] = L_add(energy_slow[k], tmp1); + } +#ifdef FIX_867_DBG + assert(energy_slow[k]>=0); +#endif + } +#else /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; -#ifndef FIX_867 q_tmp = add( q_factor_energy[i], min_q_shift1 ); -#endif FOR( k = 0; k < num_freq_bands; k++ ) { -#ifdef FIX_867 - q_tmp = add( q_factor_energy[i * num_freq_bands + k], min_q_shift1 ); - tmp = L_shr( p_tmp_c[k], min_q_shift1 ); -#else tmp = L_shl( p_tmp_c[k], min_q_shift1 ); -#endif - IF( LT_16( q_tmp, q_ene ) ) { energy_slow[k] = L_add( L_shr( energy_slow[k], sub( q_ene, q_tmp ) ), tmp ); @@ -1428,18 +1459,12 @@ void computeDiffuseness_fixed( energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, sub( q_tmp, q_ene ) ) ); move32(); } -#ifdef FIX_867 - q_ene = s_min( q_ene, q_tmp ); -#endif } -#ifndef FIX_867 q_ene = s_min( q_ene, q_tmp ); #endif /* Intensity slow */ -#ifndef FIX_867 q_tmp = add( q_factor_intensity[i], min_q_shift2 ); -#endif FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; @@ -1458,6 +1483,7 @@ void computeDiffuseness_fixed( } } } + q_intensity = s_min( q_intensity, q_tmp ); } min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); @@ -1490,7 +1516,11 @@ void computeDiffuseness_fixed( tmp = Sqrt32( p_tmp[i], &exp1 ); tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); +#ifdef FIX_867 + q_tmp = add(sub(31, exp2), sub(sub(31, exp1), q_ene[i])); +#else q_tmp = add( sub( 31, exp2 ), sub( sub( 31, exp1 ), q_ene ) ); +#endif IF( LT_16( q_tmp, Q30 ) ) { @@ -1520,7 +1550,29 @@ void computeDiffuseness_fixed( } } *q_diffuseness = Q30; - move16(); + move16(); + +#if 0 + exp1 = L_norm_arr(diffuseness, num_freq_bands); + Scale_sig32(diffuseness,num_freq_bands,exp1); + *q_diffuseness = add(*q_diffuseness, exp1); +#endif + +#ifdef FIX_867 + FOR(Word16 l = 0; l < num_freq_bands; l++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("diffuseness", "w"); + + Word32 m = diffuseness[i]; + Word16 e = *q_diffuseness; + float f1_m = (float)m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif return; } diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 083d0cf96..15dfd4221 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4637,7 +4637,14 @@ void ivas_dirac_dec_render_sf_fx( #endif 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 ); + 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 + ); } /*-----------------------------------------------------------------* @@ -5064,7 +5071,7 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { #ifdef FIX_867 - FOR( Word16 l = 0; l < size_ho; l++ ) + FOR( Word16 l = 0; l < 0; l++ ) { IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l], Q26 ) ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index b1d875ff5..09e2851a3 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2045,18 +2045,19 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ #ifdef FIX_867_DBG + Word16 cur_idx = imult1616(ch_idx, num_freq_bands); FOR(Word16 l = 0; l < num_freq_bands; l++) { static FILE *f = 0; if (f == 0) f = fopen("cy_cross_dir_smooth1", "w"); - Word32 m = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands_diff + l]; - Word16 e = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands_diff + l]; + Word32 m = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[cur_idx + l]; + Word16 e = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[cur_idx + l]; float f1_m = (float)m; float f1_e = powf(2, e); float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); + fprintf(f, "%d %d %d %d %f\n", ch_idx, l, m, e, f1); } #endif } @@ -6377,6 +6378,21 @@ void ivas_dirac_dec_compute_gain_factors_fx( move32(); } +#ifdef FIX_867_DBG + FOR(Word16 l = 0; l < num_freq_bands; l++) + { + static FILE *f = 0; + if (f == 0) + f = fopen("direct_gain_factor1", "w"); + + Word32 m = direct_gain_factor[i]; + Word16 e = *max_exp_direct_fx; + float f1_m = (float) m; + float f1_e = powf(2, e); + float f1 = f1_m / f1_e; + fprintf(f, "%d %d %d %f\n", l, m, e, f1); + } +#endif return; } -- GitLab From cce54cc5dce9fa8a411e299b1ca1b0be27a2ac8c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 29 Nov 2024 12:06:45 +0100 Subject: [PATCH 23/36] rewrite DirAC gain calculation with variable Q --- lib_rend/ivas_dirac_output_synthesis_dec.c | 90 +++++++++++++++++++--- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 09e2851a3..781ab2f05 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2578,11 +2578,35 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q #ifdef FIX_867 // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ) ); // p_gains_dir_q - g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 1 ) ) ) ); // p_gains_dir_q + //g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + + Word32 tmp1 = L_shr(g2, 1); + Word16 tmp1_q = sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], 1); + + Word32 tmp2 = L_shr(Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++))), 1); + Word16 tmp2_q = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx*num_freq_bands + l], 1); + + IF(LT_16(tmp1_q, tmp2_q)) + { + tmp2 = L_shr(tmp2, sub(tmp2_q, tmp1_q)); + tmp2_q = tmp1_q; + } + ELSE + { + tmp1 = L_shr(tmp1, sub(tmp1_q, tmp2_q)); + tmp1_q = tmp2_q; + } + + g2 = L_add(tmp1, tmp2); + + g2 = L_max( g2, L_shr( 1825361101 /* 0.85f in Q31 */, sub(Q31, tmp1_q) ) ); // tmp_q1 + g2 = L_min( g2, L_shr( 1234803098 /* 1.15f in Q30 */, sub(Q30, tmp1_q) ) ); // tmp_q1 + + g2 = L_shl( g2, sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], tmp1_q)); + #else + g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q #endif @@ -2599,11 +2623,33 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q #ifdef FIX_867 - g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_dir_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_dir_q + Word32 tmp1 = L_shr(g2, 1); + Word16 tmp1_q = sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], 1); + + Word32 tmp2 = L_shr(Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++))), 1); + Word16 tmp2_q = sub(h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx*num_freq_bands + l], 1); + + IF(LT_16(tmp1_q, tmp2_q)) + { + tmp2 = L_shr(tmp2, sub(tmp2_q, tmp1_q)); + tmp2_q = tmp1_q; + } + ELSE + { + tmp1 = L_shr(tmp1, sub(tmp1_q, tmp2_q)); + tmp1_q = tmp2_q; + } + + g2 = L_add(tmp1, tmp2); //tmp1_q + + Word32 limit1 = L_shl(DIRAC_GAIN_LIMIT_Q26, sub(tmp1_q, Q26) ); // tmp1_q + g2 = L_max( g2, L_negate(limit1) ); + g2 = L_min( g2, limit1 ); + + g2 = L_shl(g2, sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], tmp1_q)); // p_gains_dir_q #else + g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q #endif @@ -2658,11 +2704,35 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g1 = POINT_1175_Q31; // Q31 move32(); g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max( g2, 0 ); // p_gains_diff_q -#ifdef FIX_867 // p_gains_diff_q - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev[ch_idx * num_freq_bands + l] ) ), Q5 ) ) ); // p_gains_diff_q + // p_gains_diff_q +#ifdef FIX_867 + Word32 tmp1 = L_shr(g2, 1); + Word16 tmp1_q = sub(h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx*num_freq_bands + l], 1); + + Word32 tmp2 = L_shr(Mpy_32_32(g1, (*(p_cy_auto_diff_smooth++))), 1); + Word16 tmp2_q = sub(h_dirac_output_synthesis_state.q_cy_auto_diff_smooth[ch_idx*num_freq_bands + l], 1); + + IF(LT_16(tmp1_q, tmp2_q)) + { + tmp2 = L_shr(tmp2, sub(tmp2_q, tmp1_q)); + tmp2_q = tmp1_q; + } + ELSE + { + tmp1 = L_shr(tmp1, sub(tmp1_q, tmp2_q)); + tmp1_q = tmp2_q; + } + + g2 = L_add(tmp1, tmp2); //tmp1_q + + Word32 limit1 = L_shl(DIRAC_GAIN_LIMIT_Q26, sub(tmp1_q, Q26)); // tmp1_q + g2 = L_max(g2, 0); + g2 = L_min(g2, limit1); + + g2 = L_shl(g2, sub(h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx*num_freq_bands + l], tmp1_q)); // p_gains_dir_q #else + g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_auto_diff_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max(g2, 0); g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ), Q5 ) ) ); // p_gains_diff_q #endif *( p_gains_diff++ ) = g2; // p_gains_diff_q -- GitLab From 2719e7fb988f84e3b3f87bd20b823b0c59eb848f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 29 Nov 2024 12:45:05 +0100 Subject: [PATCH 24/36] fix formatting --- lib_com/ivas_dirac_com.c | 92 ++++---- lib_dec/ivas_dirac_dec.c | 23 +- lib_rend/ivas_dirac_output_synthesis_dec.c | 246 ++++++++++----------- 3 files changed, 180 insertions(+), 181 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 8d52247ca..50e457950 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1361,13 +1361,13 @@ void computeDiffuseness_fixed( Word32 *p_tmp; const Word32 *p_tmp_c; #ifdef FIX_867 - const Word16 *p_q_tmp_c; + const Word16 *p_q_tmp_c; #endif Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; #ifdef FIX_867 - Word16 q_ene[CLDFB_NO_CHANNELS_MAX]; + Word16 q_ene[CLDFB_NO_CHANNELS_MAX]; #else - Word16 q_ene; + Word16 q_ene; #endif Word16 q_intensity, q_intensity_slow; @@ -1379,7 +1379,7 @@ void computeDiffuseness_fixed( /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ #ifdef FIX_867 - min_q_shift1 = find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF); + min_q_shift1 = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); #else min_q_shift1 = Q31; move16(); @@ -1398,7 +1398,7 @@ void computeDiffuseness_fixed( } min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); #ifdef FIX_867 - set16_fx( q_ene, Q31 - find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF), num_freq_bands ); + set16_fx( q_ene, Q31 - find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ), num_freq_bands ); #else q_ene = add( q_factor_energy[0], min_q_shift1 ); #endif @@ -1409,38 +1409,38 @@ void computeDiffuseness_fixed( FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { #ifdef FIX_867 - p_tmp_c = buffer_energy + i * num_freq_bands; - p_q_tmp_c = q_factor_energy + i * num_freq_bands; - FOR(k = 0; k < num_freq_bands; k++) - { - /* Energy slow */ - Word32 tmp1; - Word16 tmp1_q; + p_tmp_c = buffer_energy + i * num_freq_bands; + p_q_tmp_c = q_factor_energy + i * num_freq_bands; + FOR( k = 0; k < num_freq_bands; k++ ) + { + /* Energy slow */ + Word32 tmp1; + Word16 tmp1_q; #ifdef FIX_867_DBG - assert(norm_l(p_tmp_c[k])==0); - assert(p_tmp_c[k]>=0); + assert( norm_l( p_tmp_c[k] ) == 0 ); + assert( p_tmp_c[k] >= 0 ); #endif - tmp1 = L_shr(p_tmp_c[k], min_q_shift1); - tmp1_q = sub(p_q_tmp_c[k], min_q_shift1); - - IF( LT_16(tmp1_q, q_ene[k]) ) - { - energy_slow[k] = L_shr(energy_slow[k], sub(q_ene[k], tmp1_q)); - q_ene[k] = tmp1_q; - - energy_slow[k] = L_add(energy_slow[k], tmp1); - } - ELSE - { - tmp1 = L_shr( tmp1, sub(tmp1_q, q_ene[k]) ); - energy_slow[k] = L_add(energy_slow[k], tmp1); - } + tmp1 = L_shr( p_tmp_c[k], min_q_shift1 ); + tmp1_q = sub( p_q_tmp_c[k], min_q_shift1 ); + + IF( LT_16( tmp1_q, q_ene[k] ) ) + { + energy_slow[k] = L_shr( energy_slow[k], sub( q_ene[k], tmp1_q ) ); + q_ene[k] = tmp1_q; + + energy_slow[k] = L_add( energy_slow[k], tmp1 ); + } + ELSE + { + tmp1 = L_shr( tmp1, sub( tmp1_q, q_ene[k] ) ); + energy_slow[k] = L_add( energy_slow[k], tmp1 ); + } #ifdef FIX_867_DBG - assert(energy_slow[k]>=0); + assert( energy_slow[k] >= 0 ); #endif - } + } #else /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; @@ -1517,7 +1517,7 @@ void computeDiffuseness_fixed( tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); #ifdef FIX_867 - q_tmp = add(sub(31, exp2), sub(sub(31, exp1), q_ene[i])); + q_tmp = add( sub( 31, exp2 ), sub( sub( 31, exp1 ), q_ene[i] ) ); #else q_tmp = add( sub( 31, exp2 ), sub( sub( 31, exp1 ), q_ene ) ); #endif @@ -1550,7 +1550,7 @@ void computeDiffuseness_fixed( } } *q_diffuseness = Q30; - move16(); + move16(); #if 0 exp1 = L_norm_arr(diffuseness, num_freq_bands); @@ -1559,19 +1559,19 @@ void computeDiffuseness_fixed( #endif #ifdef FIX_867 - FOR(Word16 l = 0; l < num_freq_bands; l++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("diffuseness", "w"); - - Word32 m = diffuseness[i]; - Word16 e = *q_diffuseness; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + FOR( Word16 l = 0; l < num_freq_bands; l++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "diffuseness", "w" ); + + Word32 m = diffuseness[i]; + Word16 e = *q_diffuseness; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif return; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 15dfd4221..b3958ef91 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -4637,14 +4637,13 @@ void ivas_dirac_dec_render_sf_fx( #endif 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 - ); + 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 ); } /*-----------------------------------------------------------------* @@ -5075,14 +5074,14 @@ void ivas_dirac_dec_render_sf_fx( { IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l], Q26 ) ) { - hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l] = - L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth[l] = Q26; } IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l], Q26 ) ) { - hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l] = - L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] ) ); // Q26 + hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l] = + L_shl( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx[l], sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] ) ); // Q26 hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev[l] = Q26; } } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 781ab2f05..a6abb3f53 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1872,8 +1872,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = + L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); #else IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) @@ -2045,20 +2045,20 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands, 0 ); /*Q(h_dirac_output_synthesis_state->q_cy_cross_dir_smooth)*/ #ifdef FIX_867_DBG - Word16 cur_idx = imult1616(ch_idx, num_freq_bands); - FOR(Word16 l = 0; l < num_freq_bands; l++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("cy_cross_dir_smooth1", "w"); - - Word32 m = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[cur_idx + l]; - Word16 e = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[cur_idx + l]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %d %f\n", ch_idx, l, m, e, f1); - } + Word16 cur_idx = imult1616( ch_idx, num_freq_bands ); + FOR( Word16 l = 0; l < num_freq_bands; l++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "cy_cross_dir_smooth1", "w" ); + + Word32 m = h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[cur_idx + l]; + Word16 e = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[cur_idx + l]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %d %f\n", ch_idx, l, m, e, f1 ); + } #endif } @@ -2089,19 +2089,19 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ - FOR(Word16 l = 0; l < num_freq_bands; l++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("cy_auto_diff_smooth1", "w"); - - Word32 m = h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l]; - Word16 e = h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[ch_idx * num_freq_bands_diff + l]; - float f1_m = (float)m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + FOR( Word16 l = 0; l < num_freq_bands; l++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "cy_auto_diff_smooth1", "w" ); + + Word32 m = h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff + l]; + Word16 e = h_dirac_output_synthesis_state->q_cy_auto_diff_smooth[ch_idx * num_freq_bands_diff + l]; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } } return; @@ -2576,37 +2576,37 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { FOR( l = 0; l < num_freq_bands; l++ ) { - g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q -#ifdef FIX_867 // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - //g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - - Word32 tmp1 = L_shr(g2, 1); - Word16 tmp1_q = sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], 1); - - Word32 tmp2 = L_shr(Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++))), 1); - Word16 tmp2_q = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx*num_freq_bands + l], 1); - - IF(LT_16(tmp1_q, tmp2_q)) - { - tmp2 = L_shr(tmp2, sub(tmp2_q, tmp1_q)); - tmp2_q = tmp1_q; - } - ELSE - { - tmp1 = L_shr(tmp1, sub(tmp1_q, tmp2_q)); - tmp1_q = tmp2_q; - } - - g2 = L_add(tmp1, tmp2); - - g2 = L_max( g2, L_shr( 1825361101 /* 0.85f in Q31 */, sub(Q31, tmp1_q) ) ); // tmp_q1 - g2 = L_min( g2, L_shr( 1234803098 /* 1.15f in Q30 */, sub(Q30, tmp1_q) ) ); // tmp_q1 - - g2 = L_shl( g2, sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], tmp1_q)); + g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q +#ifdef FIX_867 // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + // g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + + Word32 tmp1 = L_shr( g2, 1 ); + Word16 tmp1_q = sub( h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + l], 1 ); + + Word32 tmp2 = L_shr( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ), 1 ); + Word16 tmp2_q = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx * num_freq_bands + l], 1 ); + + IF( LT_16( tmp1_q, tmp2_q ) ) + { + tmp2 = L_shr( tmp2, sub( tmp2_q, tmp1_q ) ); + tmp2_q = tmp1_q; + } + ELSE + { + tmp1 = L_shr( tmp1, sub( tmp1_q, tmp2_q ) ); + tmp1_q = tmp2_q; + } + + g2 = L_add( tmp1, tmp2 ); + + g2 = L_max( g2, L_shr( 1825361101 /* 0.85f in Q31 */, sub( Q31, tmp1_q ) ) ); // tmp_q1 + g2 = L_min( g2, L_shr( 1234803098 /* 1.15f in Q30 */, sub( Q30, tmp1_q ) ) ); // tmp_q1 + + g2 = L_shl( g2, sub( h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + l], tmp1_q ) ); #else - g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, Mpy_32_32( 1825361101 /* 0.85f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q g2 = L_min( g2, Mpy_32_32( 1234803098 /* 1.15f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q #endif @@ -2624,32 +2624,32 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q #ifdef FIX_867 - Word32 tmp1 = L_shr(g2, 1); - Word16 tmp1_q = sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], 1); - - Word32 tmp2 = L_shr(Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++))), 1); - Word16 tmp2_q = sub(h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx*num_freq_bands + l], 1); - - IF(LT_16(tmp1_q, tmp2_q)) - { - tmp2 = L_shr(tmp2, sub(tmp2_q, tmp1_q)); - tmp2_q = tmp1_q; - } - ELSE - { - tmp1 = L_shr(tmp1, sub(tmp1_q, tmp2_q)); - tmp1_q = tmp2_q; - } - - g2 = L_add(tmp1, tmp2); //tmp1_q - - Word32 limit1 = L_shl(DIRAC_GAIN_LIMIT_Q26, sub(tmp1_q, Q26) ); // tmp1_q - g2 = L_max( g2, L_negate(limit1) ); + Word32 tmp1 = L_shr( g2, 1 ); + Word16 tmp1_q = sub( h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + l], 1 ); + + Word32 tmp2 = L_shr( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ), 1 ); + Word16 tmp2_q = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth[ch_idx * num_freq_bands + l], 1 ); + + IF( LT_16( tmp1_q, tmp2_q ) ) + { + tmp2 = L_shr( tmp2, sub( tmp2_q, tmp1_q ) ); + tmp2_q = tmp1_q; + } + ELSE + { + tmp1 = L_shr( tmp1, sub( tmp1_q, tmp2_q ) ); + tmp1_q = tmp2_q; + } + + g2 = L_add( tmp1, tmp2 ); // tmp1_q + + Word32 limit1 = L_shl( DIRAC_GAIN_LIMIT_Q26, sub( tmp1_q, Q26 ) ); // tmp1_q + g2 = L_max( g2, L_negate( limit1 ) ); g2 = L_min( g2, limit1 ); - g2 = L_shl(g2, sub(h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx*num_freq_bands + l], tmp1_q)); // p_gains_dir_q + g2 = L_shl( g2, sub( h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + l], tmp1_q ) ); // p_gains_dir_q #else - g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q g2 = L_max( g2, W_extract_h( W_shl( W_mult_32_32( -DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ), Q5 ) ) ); // p_gains_dir_q #endif @@ -2703,37 +2703,37 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( { g1 = POINT_1175_Q31; // Q31 move32(); - g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q - // p_gains_diff_q + g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_diff ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q + // p_gains_diff_q #ifdef FIX_867 - Word32 tmp1 = L_shr(g2, 1); - Word16 tmp1_q = sub(h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx*num_freq_bands + l], 1); - - Word32 tmp2 = L_shr(Mpy_32_32(g1, (*(p_cy_auto_diff_smooth++))), 1); - Word16 tmp2_q = sub(h_dirac_output_synthesis_state.q_cy_auto_diff_smooth[ch_idx*num_freq_bands + l], 1); - - IF(LT_16(tmp1_q, tmp2_q)) - { - tmp2 = L_shr(tmp2, sub(tmp2_q, tmp1_q)); - tmp2_q = tmp1_q; - } - ELSE - { - tmp1 = L_shr(tmp1, sub(tmp1_q, tmp2_q)); - tmp1_q = tmp2_q; - } - - g2 = L_add(tmp1, tmp2); //tmp1_q - - Word32 limit1 = L_shl(DIRAC_GAIN_LIMIT_Q26, sub(tmp1_q, Q26)); // tmp1_q - g2 = L_max(g2, 0); - g2 = L_min(g2, limit1); - - g2 = L_shl(g2, sub(h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx*num_freq_bands + l], tmp1_q)); // p_gains_dir_q + Word32 tmp1 = L_shr( g2, 1 ); + Word16 tmp1_q = sub( h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx * num_freq_bands + l], 1 ); + + Word32 tmp2 = L_shr( Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ), 1 ); + Word16 tmp2_q = sub( h_dirac_output_synthesis_state.q_cy_auto_diff_smooth[ch_idx * num_freq_bands + l], 1 ); + + IF( LT_16( tmp1_q, tmp2_q ) ) + { + tmp2 = L_shr( tmp2, sub( tmp2_q, tmp1_q ) ); + tmp2_q = tmp1_q; + } + ELSE + { + tmp1 = L_shr( tmp1, sub( tmp1_q, tmp2_q ) ); + tmp1_q = tmp2_q; + } + + g2 = L_add( tmp1, tmp2 ); // tmp1_q + + Word32 limit1 = L_shl( DIRAC_GAIN_LIMIT_Q26, sub( tmp1_q, Q26 ) ); // tmp1_q + g2 = L_max( g2, 0 ); + g2 = L_min( g2, limit1 ); + + g2 = L_shl( g2, sub( h_dirac_output_synthesis_state.gains_diff_prev_q[ch_idx * num_freq_bands + l], tmp1_q ) ); // p_gains_dir_q #else - g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_auto_diff_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - g2 = L_max(g2, 0); - g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ), Q5 ) ) ); // p_gains_diff_q + g2 = L_add_sat( g2, Mpy_32_32( g1, ( *( p_cy_auto_diff_smooth++ ) ) ) ); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + g2 = L_max( g2, 0 ); + g2 = L_min( g2, W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ), Q5 ) ) ); // p_gains_diff_q #endif *( p_gains_diff++ ) = g2; // p_gains_diff_q move32(); @@ -6449,19 +6449,19 @@ void ivas_dirac_dec_compute_gain_factors_fx( } #ifdef FIX_867_DBG - FOR(Word16 l = 0; l < num_freq_bands; l++) - { - static FILE *f = 0; - if (f == 0) - f = fopen("direct_gain_factor1", "w"); - - Word32 m = direct_gain_factor[i]; - Word16 e = *max_exp_direct_fx; - float f1_m = (float) m; - float f1_e = powf(2, e); - float f1 = f1_m / f1_e; - fprintf(f, "%d %d %d %f\n", l, m, e, f1); - } + FOR( Word16 l = 0; l < num_freq_bands; l++ ) + { + static FILE *f = 0; + if ( f == 0 ) + f = fopen( "direct_gain_factor1", "w" ); + + Word32 m = direct_gain_factor[i]; + Word16 e = *max_exp_direct_fx; + float f1_m = (float) m; + float f1_e = powf( 2, e ); + float f1 = f1_m / f1_e; + fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); + } #endif return; -- GitLab From f08a9cfeeed1e8235074f60bfbbdc0b6456b0813 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 29 Nov 2024 12:45:38 +0100 Subject: [PATCH 25/36] disable FIX_867 --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c1d0f40dc..1badae941 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,8 +200,8 @@ #define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* FhG: fixes for decoder-side noise level estimation in MDCT-Stereo to prevent noise bursts in stereo switching */ /* ################## End DEVELOPMENT switches ######################### */ -#define FIX_867 -#define FIX_867_DBG +//#define FIX_867 +//#define FIX_867_DBG /* clang-format on */ #define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO -- GitLab From 39c4c6f263c05e8d624ad295f431d59ecc82815a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 29 Nov 2024 12:59:29 +0100 Subject: [PATCH 26/36] fix compile errors --- lib_rend/ivas_dirac_output_synthesis_dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index a6abb3f53..e78834634 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1979,10 +1979,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = - L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ move32(); - h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[kk] = temp; } free( Q_temp_cy_cross_dir_smooth_fx ); #endif @@ -2089,6 +2087,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ +#ifdef FIX_867_DBG FOR( Word16 l = 0; l < num_freq_bands; l++ ) { static FILE *f = 0; @@ -2102,6 +2101,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( float f1 = f1_m / f1_e; fprintf( f, "%d %d %d %f\n", l, m, e, f1 ); } +#endif } return; -- GitLab From 13e77ae57101196ba83b9f4daf17066500749774 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 29 Nov 2024 12:59:48 +0100 Subject: [PATCH 27/36] fix formatting --- lib_rend/ivas_dirac_output_synthesis_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index e78834634..339976e51 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2579,7 +2579,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g1 = Madd_32_32( POINT_3679_Q31, onset_filter[l], POINT_1175_Q31 - POINT_3679_Q31 ); // Q31, (Q31, Q31) -> Q31 g2 = Mpy_32_32( L_sub( ONE_IN_Q31, g1 ), *( p_gains_dir ) ); // (Q31, p_gains_dir_q) -> p_gains_dir_q #ifdef FIX_867 // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q - // g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q + // g2 = L_add_sat(g2, Mpy_32_32(g1, (*(p_cy_cross_dir_smooth++)))); // p_gains_diff_q, (Q31, p_gains_diff_q) -> p_gains_diff_q Word32 tmp1 = L_shr( g2, 1 ); Word16 tmp1_q = sub( h_dirac_output_synthesis_state.gains_dir_prev_q[ch_idx * num_freq_bands + l], 1 ); -- GitLab From 02f2bf877258e80b110eb47d6bfae70ad5917fcb Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 29 Nov 2024 14:52:17 +0100 Subject: [PATCH 28/36] enable FIX_867 --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1badae941..c1d0f40dc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,8 +200,8 @@ #define NONBE_FIX_1204_MDCT_STEREO_NOISE_EST_SCALING /* FhG: fixes for decoder-side noise level estimation in MDCT-Stereo to prevent noise bursts in stereo switching */ /* ################## End DEVELOPMENT switches ######################### */ -//#define FIX_867 -//#define FIX_867_DBG +#define FIX_867 +#define FIX_867_DBG /* clang-format on */ #define NONBE_FIX_1010_STEREO_CNG_DIV_BY_ZERO -- GitLab From 677426d52a4567d7c0ca23f0f4e111d1054ee77e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Jan 2025 08:45:30 +0100 Subject: [PATCH 29/36] disable FIX_867 --- lib_com/options.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 85f3447a7..1c8203e66 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,6 +109,7 @@ #define FIX_1132_STACK_CORRUPTION /* Stack corruption issue due of extending index access*/ #define FIX_ISSUE_1092 /* Ittiam: Fix for Issue 1092: BASOP asserts in stereo fx encoder for selection test inputs*/ -#define FIX_867 -#define FIX_867_DBG +//#define FIX_867 +//#define FIX_867_DBG + #endif -- GitLab From 014cf249730780c10db6657558a588cd8e9d6a73 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Jan 2025 08:55:32 +0100 Subject: [PATCH 30/36] fix formatting --- lib_rend/ivas_dirac_output_synthesis_dec.c | 4 ++-- lib_rend/ivas_stat_rend.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 9c01d6f40..bef833764 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -727,13 +727,13 @@ void ivas_dirac_dec_output_synthesis_close_fx( *------------------------------------------------------------------------*/ void ivas_dirac_dec_output_synthesis_process_slot_fx( - const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ + const Word32 *reference_power, /* i : Estimated power Q(q_reference_power)*/ #ifdef FIX_867 const Word16 *q_reference_power, /* i : Estimated power Q */ #else const Word16 q_reference_power, /* i : Estimated power Q */ #endif - const Word32 *onset, /* i : onset filter Q31*/ + const Word32 *onset, /* i : onset filter Q31*/ const Word16 *azimuth, const Word16 *elevation, const Word32 *diffuseness, /* Q(q_diffuseness)*/ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 1be86e7bc..7f55c0b4e 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -290,7 +290,7 @@ typedef struct dirac_output_synthesis_state_structure const Word32 *onset_filter_fx; /* Q31 */ /* Temporal smoothing memories */ - Word32 *reference_power_smooth_prev_fx; /* Q(reference_power_smooth_prev_q) */ + Word32 *reference_power_smooth_prev_fx; /* Q(reference_power_smooth_prev_q) */ #ifdef FIX_867 Word16 *reference_power_smooth_prev_q; #else @@ -359,9 +359,9 @@ typedef struct dirac_output_synthesis_state_structure Word16 *q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 *q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ #else - Word16 q_cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_dir_smooth; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ #endif Word16 cy_auto_dir_smooth_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ @@ -378,9 +378,9 @@ typedef struct dirac_output_synthesis_state_structure Word16 *q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 *q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ #else - Word16 q_cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ - Word16 q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_dir_smooth_prev; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_cross_dir_smooth_prev; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ + Word16 q_cy_auto_diff_smooth_prev; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ #endif Word16 cy_auto_dir_smooth_prev_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ -- GitLab From 9acde778dbb5cbf3d44218b7a18c6fe0758f72d8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 9 Jan 2025 14:35:51 +0100 Subject: [PATCH 31/36] fix merge error --- lib_rend/ivas_stat_rend.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 7f55c0b4e..46283da5c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -230,10 +230,6 @@ typedef struct dirac_dec_stack_mem Word16 *q_cy_auto_dir_smooth; Word16 *q_cy_cross_dir_smooth; Word16 *q_cy_auto_diff_smooth; -#else - Word16 cy_cross_dir_smooth; - Word16 cy_auto_dir_smooth; - Word16 cy_auto_diff_smooth; #endif Word32 *reference_power_fx; -- GitLab From 072ce070c1ace6c503cc10dad8e2b982c15bacdc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Jan 2025 11:36:11 +0100 Subject: [PATCH 32/36] remove unnecessary condition --- lib_rend/ivas_dirac_output_synthesis_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index bef833764..97709f1ea 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2762,7 +2762,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); *( p_power_smooth_prev ) = L_add( *( p_power_smooth_prev ), Mpy_32_32( g1, ( *p_power_smooth ) ) ); //(Q31, q_proto_power_smooth) -> q_proto_power_smooth move32(); - +#ifndef FIX_867 IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) ) { p_power_smooth_prev++; @@ -2774,6 +2774,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); } ELSE +#endif { L_tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q31, *( p_power_smooth_prev++ ), &exp ); /*Q=31-(exp-(31-q_proto_power_smooth))*/ exp_arr[k * num_freq_bands + l] = exp; -- GitLab From 55fa9da202f3c1b00907b2f52466cfba0ae65412 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Jan 2025 11:40:40 +0100 Subject: [PATCH 33/36] fix compile error --- lib_com/options.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f15a37c65..0c2c0bfe3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,3 +120,5 @@ #define FIX_867 #define FIX_867_DBG + +#endif \ No newline at end of file -- GitLab From 4bd522549770a8db866fbaaa4a958eb4c30da004 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Jan 2025 11:57:24 +0100 Subject: [PATCH 34/36] fix formatting --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0c2c0bfe3..6a70ddd37 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -121,4 +121,4 @@ #define FIX_867 #define FIX_867_DBG -#endif \ No newline at end of file +#endif -- GitLab From 39ad4a8f125a08869535e6e48bec4185fef78efa Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Jan 2025 13:11:33 +0100 Subject: [PATCH 35/36] disable FIX_867 --- lib_com/ivas_dirac_com.c | 2 +- lib_com/options.h | 4 +-- lib_dec/ivas_dirac_dec.c | 8 +----- lib_rend/ivas_dirac_output_synthesis_dec.c | 30 ++++++++++------------ 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d079d4126..59b7710a9 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -1127,7 +1127,7 @@ void computeDiffuseness_fixed( *q_diffuseness = add(*q_diffuseness, exp1); #endif -#ifdef FIX_867 +#ifdef FIX_867_DBG FOR( Word16 l = 0; l < num_freq_bands; l++ ) { static FILE *f = 0; diff --git a/lib_com/options.h b/lib_com/options.h index 6a70ddd37..3d69f0c53 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,7 @@ #define FIX_ISSUE_1152 /* Ittiam: Fix for issue 1152: Assertion error observed in evs_enc_fx (with option stereo_dmx_evs) from find_tilt_fx function*/ #define FIX_ISSUE_1156 /* Ittiam: Fix for Issue 1156: Encoder crash for Stereo at 32kbps in SWB_BWE_encoding_ivas_fx() */ -#define FIX_867 -#define FIX_867_DBG +//#define FIX_867 +//#define FIX_867_DBG #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index d1835552d..e1d9306c5 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3122,13 +3122,7 @@ void ivas_dirac_dec_render_sf_fx( #endif 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 ); + 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 ); } /*-----------------------------------------------------------------* diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 97709f1ea..d80867b20 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -908,6 +908,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ /*Direct gain*/ + #ifndef FIX_867 Word16 *Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); tmp16 = imult1616( num_freq_bands, num_channels_dir ); @@ -1130,8 +1131,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ move32(); #ifdef FIX_867 h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); @@ -1199,8 +1199,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); #else - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ move32(); Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); @@ -1244,15 +1243,12 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } #endif - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); - /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ move32(); } ELSE { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = - L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ move32(); #ifdef FIX_867 h_dirac_output_synthesis_state->q_cy_cross_dir_smooth[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); @@ -1826,7 +1822,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( sub( q_com, Q31 ) ); /*q31->q_com*/ Scale_sig32( &h_dirac_output_synthesis_state.cy_auto_diff_smooth_prev_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff, - sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ + sub( q_com, h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev ) ); /*h_dirac_output_synthesis_state.q_cy_auto_diff_smooth_prev->q_com*/ #endif } @@ -1859,8 +1855,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l] ) ) ); // p_gains_dir_q g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev[ch_idx * num_freq_bands + l], 1 ) ) ) ); // p_gains_dir_q #else - g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q - g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q + g2 = L_max( g2, Mpy_32_32( 2126008812 /* 0.99f in Q31 */, L_shl( 1, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ) ) ); // p_gains_dir_q + g2 = L_min( g2, Mpy_32_32( ONE_IN_Q31 /* 2.0f in Q30 */, L_shl( 1, add( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, 1 ) ) ) ); // p_gains_dir_q #endif *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); @@ -3008,7 +3004,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( #ifdef FIX_867 *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_diff_prev_q #else - *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q + *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q #endif move32(); @@ -3118,7 +3114,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( #ifdef FIX_867 *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_dir_prev_q #else - *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q, sub( Q31, exp ) ) ); // gains_dir_prev_q + *( p_gains_dir ) = L_shl_sat( *( p_gains_dir ), sub( h_dirac_output_synthesis_state->gains_dir_prev_q, sub( Q31, exp ) ) ); // gains_dir_prev_q #endif move32(); @@ -3208,7 +3204,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( #ifdef FIX_867 *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q[k * num_freq_bands + l], sub( Q31, exp ) ) ); // gains_diff_prev_q #else - *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q + *( p_gains_diff ) = L_shl_sat( *( p_gains_diff ), sub( h_dirac_output_synthesis_state->gains_diff_prev_q, sub( Q31, exp ) ) ); // gains_diff_prev_q #endif move32(); @@ -4735,11 +4731,11 @@ static void computeTargetPSDs_direct_fx( Word16 ch_idx, cur_idx; /* segment auxiliary buffer */ - Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 direct_power[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ #ifdef FIX_867 Word32 aux_buffer_res; /* size: num_freq_bands. */ #else - Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ + Word32 aux_buffer_res[CLDFB_NO_CHANNELS_MAX]; /* size: num_freq_bands. */ #endif /* estimate direct and diffuse power */ -- GitLab From 48651688c21b18830faef10a77ba59f8a5471238 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 14 Jan 2025 16:31:39 +0100 Subject: [PATCH 36/36] fix encapsulation --- lib_com/ivas_dirac_com.c | 1 + lib_com/options.h | 1 - lib_rend/ivas_dirac_output_synthesis_dec.c | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 59b7710a9..4c0d8d03d 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -966,6 +966,7 @@ void computeDiffuseness_fixed( } } min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); + #ifdef FIX_867 set16_fx( q_ene, Q31 - find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ), num_freq_bands ); #else diff --git a/lib_com/options.h b/lib_com/options.h index 3d69f0c53..5217cc8c6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,7 +84,6 @@ #define SIMPLIFY_CODE_BE // Simplify synthesis loop #define CR_2109_to_2112_cd0_ce0 /* This is related to the CRs include in the 26.444 package of 21-12. Concerns lead_deindexing and */ #define FIX_QMETADATA_PENALTY /* Nokia: transform penalty calculation in qmetadata into integer operations */ - #define FIX_1013_CRASH_HQ_CORE_DEC /* Ittiam: Saturation added on the lines of EVS */ #define NONE_BE_FIX_BASOP_1044_OSBA_PRERENDER_MIX_GAINS /* DLB: adjust prerendering and mixing gain in OSBA encoder. This is fix to float codes*/ #define NONBE_1233_HQ_CLASSIFIER_DIV_BY_ZERO /* Eri: issue 1233: Address possible division by zero in hf_spectrum_sparseness() */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index d80867b20..b4274eabe 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -2754,7 +2754,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( g1 = alpha[l]; // Q31 move32(); g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 +#ifdef FIX_867 + *p_power_smooth_prev = L_add( 3*EPSILON_FX, Mpy_32_32( g2, ( *p_power_smooth_prev ) ) ); //(Q31, q_proto_power_smooth) -> q_proto_power_smooth +#else *p_power_smooth_prev = L_add( EPSILON_FX, Mpy_32_32( g2, ( *p_power_smooth_prev ) ) ); //(Q31, q_proto_power_smooth) -> q_proto_power_smooth +#endif move32(); *( p_power_smooth_prev ) = L_add( *( p_power_smooth_prev ), Mpy_32_32( g1, ( *p_power_smooth ) ) ); //(Q31, q_proto_power_smooth) -> q_proto_power_smooth move32(); -- GitLab