From 74da034e2f981f0fb97bc005f7f993a04fbfcaea Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 21 Aug 2023 16:44:04 +0200 Subject: [PATCH 1/7] avoid arithmetic with NULL pointers in DirAC synthesis --- lib_rend/ivas_dirac_output_synthesis_dec.c | 5 ++++- lib_rend/ivas_dirac_rend.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 7c73d0fc9e..5a1f260c71 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1522,7 +1522,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( } /*Diffuse stream*/ - p_power_smooth_diff = h_dirac_output_synthesis_state->proto_diffuse_buffer_f + buf_idx * 2 * h_dirac_output_synthesis_params->max_band_decorr * nchan_out_woLFE; + if ( h_dirac_output_synthesis_params->max_band_decorr != 0 ) + { + p_power_smooth_diff = h_dirac_output_synthesis_state->proto_diffuse_buffer_f + buf_idx * 2 * h_dirac_output_synthesis_params->max_band_decorr * nchan_out_woLFE; + } p_gain_1 = gains_diff; p_gain_2 = h_dirac_output_synthesis_state->gains_diff_prev; for ( k = 0; k < nchan_out_woLFE; k++ ) diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 326930e0db..3d7ebe82ea 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1642,6 +1642,11 @@ void ivas_dirac_dec_compute_diffuse_proto( num_freq_bands_diff = h_dirac_output_synthesis_params->max_band_decorr; + if ( num_freq_bands_diff == 0 ) + { + return; + } + p_diff_buffer = h_dirac_output_synthesis_state->proto_diffuse_buffer_f + slot_idx * 2 * num_freq_bands_diff * hDirACRend->hOutSetup.nchan_out_woLFE; p_diff_buffer_1 = p_diff_buffer + 1; p_power_smooth = h_dirac_output_synthesis_state->proto_power_diff_smooth; -- GitLab From eefa535e46f7b17bbac8fb0adf3cb0ca5d09626f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 22 Aug 2023 15:59:29 +0200 Subject: [PATCH 2/7] wrap changes into new define FIX_632_USAN_ERROR_NULL_POINTER --- lib_com/options.h | 1 + lib_rend/ivas_dirac_output_synthesis_dec.c | 196 +++++++++++---------- lib_rend/ivas_dirac_rend.c | 3 +- 3 files changed, 102 insertions(+), 98 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index be3261f808..4db05aad22 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,7 @@ #define FIX_718_JBM_MD_UDPATE /* Fhg: fix issue #718, wrong setting of the update flag in the TD obj renderer in the JBM path */ #define FIX_719_CRASH_IN_CLEANUP /* VA: issue 719: fix Decoder crash after call to goto to cleanup */ +#define FIX_632_USAN_ERROR_NULL_POINTER /* FhG: issue 632 USAN offset to null pointer proto_diffuse_buffer_f in dirac rendering*/ /* ################## End BE DEVELOPMENT switches ######################### */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 5a1f260c71..68ef93bb7d 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -628,118 +628,118 @@ void ivas_dirac_dec_output_synthesis_process_slot( } else // ( dec_param_estim == TRUE ) if ( dec_param_estim == TRUE ) - { + { - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - hVBAPdata, - NULL, - NULL, - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + hVBAPdata, + NULL, + NULL, + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); + + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + { + int16_t k; + if ( ch_idx != 0 ) { - int16_t k; - if ( ch_idx != 0 ) - { - float a, b, c; + float a, b, c; - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } - else + for ( ; k < num_freq_bands; k++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } } - - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } - - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirACRend->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } + } - return; + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) + { + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - else + + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirACRend->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); } + + return; + } + else + { + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); } + } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) @@ -1522,10 +1522,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( } /*Diffuse stream*/ +#ifdef FIX_632_USAN_ERROR_NULL_POINTER if ( h_dirac_output_synthesis_params->max_band_decorr != 0 ) { p_power_smooth_diff = h_dirac_output_synthesis_state->proto_diffuse_buffer_f + buf_idx * 2 * h_dirac_output_synthesis_params->max_band_decorr * nchan_out_woLFE; } +#endif p_gain_1 = gains_diff; p_gain_2 = h_dirac_output_synthesis_state->gains_diff_prev; for ( k = 0; k < nchan_out_woLFE; k++ ) @@ -1671,8 +1673,8 @@ static void ivas_dirac_dec_get_response_split_order( dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2; dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2; - index_azimuth = ( (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ) + 180 ) % 360; - index_elevation = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ) + 90; + index_azimuth = ( ( int16_t )( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ) + 180 ) % 360; + index_elevation = ( int16_t )( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ) + 90; e = index_elevation > 90 ? -1 : 1; el = index_elevation > 90 ? 180 - index_elevation : index_elevation; diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 3d7ebe82ea..5739bc71e6 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -1641,11 +1641,12 @@ void ivas_dirac_dec_compute_diffuse_proto( h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state ); num_freq_bands_diff = h_dirac_output_synthesis_params->max_band_decorr; - +#ifdef FIX_632_USAN_ERROR_NULL_POINTER if ( num_freq_bands_diff == 0 ) { return; } +#endif p_diff_buffer = h_dirac_output_synthesis_state->proto_diffuse_buffer_f + slot_idx * 2 * num_freq_bands_diff * hDirACRend->hOutSetup.nchan_out_woLFE; p_diff_buffer_1 = p_diff_buffer + 1; -- GitLab From 3a7a256111cb77c65238696f31c54c7430c0710e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 22 Aug 2023 16:06:05 +0200 Subject: [PATCH 3/7] fix formatting --- lib_rend/ivas_dirac_output_synthesis_dec.c | 194 ++++++++++----------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 68ef93bb7d..54cef101ab 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -628,118 +628,118 @@ void ivas_dirac_dec_output_synthesis_process_slot( } else // ( dec_param_estim == TRUE ) if ( dec_param_estim == TRUE ) - { - - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - hVBAPdata, - NULL, - NULL, - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); - - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, + hDirACRend, + hVBAPdata, + NULL, + NULL, + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); + + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) - { - int16_t k; - if ( ch_idx != 0 ) - { - float a, b, c; + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + { + int16_t k; + if ( ch_idx != 0 ) { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + float a, b, c; + + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + } } - for ( ; k < num_freq_bands; k++ ) + else { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } } - else + + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - } - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + { + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirACRend->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); + } - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + return; + } + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirACRend->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); } - - return; - } - else - { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); } - } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) @@ -1673,8 +1673,8 @@ static void ivas_dirac_dec_get_response_split_order( dv_r_1 = p_Rmat[3] * dv_0 + p_Rmat[4] * dv_1 + p_Rmat[5] * dv_2; dv_r_2 = p_Rmat[6] * dv_0 + p_Rmat[7] * dv_1 + p_Rmat[8] * dv_2; - index_azimuth = ( ( int16_t )( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ) + 180 ) % 360; - index_elevation = ( int16_t )( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ) + 90; + index_azimuth = ( (int16_t) ( atan2f( dv_r_1, dv_r_0 ) * _180_OVER_PI ) + 180 ) % 360; + index_elevation = (int16_t) ( atan2f( dv_r_2, sqrtf( dv_r_0 * dv_r_0 + dv_r_1 * dv_r_1 ) ) * _180_OVER_PI ) + 90; e = index_elevation > 90 ? -1 : 1; el = index_elevation > 90 ? 180 - index_elevation : index_elevation; -- GitLab From d34c9c46ad1159163466ddae4c6018bfdb500999 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 22 Aug 2023 16:07:28 +0200 Subject: [PATCH 4/7] fix path with FIX_632_USAN_ERROR_NULL_POINTER disabled --- 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 54cef101ab..568341abe1 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -1524,10 +1524,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( /*Diffuse stream*/ #ifdef FIX_632_USAN_ERROR_NULL_POINTER if ( h_dirac_output_synthesis_params->max_band_decorr != 0 ) +#endif { p_power_smooth_diff = h_dirac_output_synthesis_state->proto_diffuse_buffer_f + buf_idx * 2 * h_dirac_output_synthesis_params->max_band_decorr * nchan_out_woLFE; } -#endif p_gain_1 = gains_diff; p_gain_2 = h_dirac_output_synthesis_state->gains_diff_prev; for ( k = 0; k < nchan_out_woLFE; k++ ) -- GitLab From 505b80866ee0f4d923a0a31fc833f28b6e954ed9 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 12 Sep 2023 09:44:39 +0200 Subject: [PATCH 5/7] remove error from ubsan.supp file --- scripts/ubsan.supp | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/ubsan.supp b/scripts/ubsan.supp index 0e32af3ae1..f5fba87eda 100644 --- a/scripts/ubsan.supp +++ b/scripts/ubsan.supp @@ -38,8 +38,6 @@ implicit-signed-integer-truncation:tcq_position_arith.c implicit-signed-integer-truncation:tools.c null:ivas_dirac_com.c pointer-overflow:ivas_dirac_dec.c -pointer-overflow:ivas_dirac_output_synthesis_dec.c -pointer-overflow:ivas_dirac_rend.c shift-base:basop32.c shift-base:enh40.c shift-base:enh40.h -- GitLab From 8b0810be5e651e151795309e6b08cfd91cd4f95e Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 12 Sep 2023 15:53:08 +0200 Subject: [PATCH 6/7] remove one more line that should be fixed as well --- scripts/ubsan.supp | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/ubsan.supp b/scripts/ubsan.supp index f5fba87eda..117cc54c58 100644 --- a/scripts/ubsan.supp +++ b/scripts/ubsan.supp @@ -37,7 +37,6 @@ implicit-signed-integer-truncation:pvq_core_enc.c implicit-signed-integer-truncation:tcq_position_arith.c implicit-signed-integer-truncation:tools.c null:ivas_dirac_com.c -pointer-overflow:ivas_dirac_dec.c shift-base:basop32.c shift-base:enh40.c shift-base:enh40.h -- GitLab From 24ddae527595f8aef4fbe138d33f7a1bd18d41e2 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 12 Sep 2023 16:04:39 +0200 Subject: [PATCH 7/7] Revert "remove one more line that should be fixed as well" This reverts commit 8b0810be5e651e151795309e6b08cfd91cd4f95e. --- scripts/ubsan.supp | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ubsan.supp b/scripts/ubsan.supp index 117cc54c58..f5fba87eda 100644 --- a/scripts/ubsan.supp +++ b/scripts/ubsan.supp @@ -37,6 +37,7 @@ implicit-signed-integer-truncation:pvq_core_enc.c implicit-signed-integer-truncation:tcq_position_arith.c implicit-signed-integer-truncation:tools.c null:ivas_dirac_com.c +pointer-overflow:ivas_dirac_dec.c shift-base:basop32.c shift-base:enh40.c shift-base:enh40.h -- GitLab