diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 6aeff8ec548fe8a13aba886d138eebbfb0f3db7d..4c0d8d03dbbbe6c035170bc6c16a89c4c4537c96 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -929,8 +929,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 */ @@ -939,10 +947,14 @@ 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(); 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 ) ); +#endif min_q_shift2 = Q31; move16(); @@ -955,13 +967,51 @@ 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 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 ) { +#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; @@ -981,6 +1031,7 @@ void computeDiffuseness_fixed( } } q_ene = s_min( q_ene, q_tmp ); +#endif /* Intensity slow */ q_tmp = add( q_factor_intensity[i], min_q_shift2 ); @@ -1035,7 +1086,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 ) ) { @@ -1067,6 +1122,28 @@ void computeDiffuseness_fixed( *q_diffuseness = Q30; 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_DBG + 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_com/options.h b/lib_com/options.h index 5840a67ddce7fb37e15a147583477c9c799cae8b..5217cc8c6bd1c5f1ce38286185da85cc731b5367 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -116,4 +116,8 @@ #define FIX_ISSUE_1157 /* Ittiam: Fix for Issue 1157: Encoder crash for Stereo at 48/64kbps DTX on/off in kernel_switch_trafo_fx() */ #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 + #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 95cca12a098cc772bf24cc54c6a5b604e95565e5..e1d9306c5db63e218cfaed8d5c25903ee2038119 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -917,7 +917,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 ); +#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 ) ) ) ) { @@ -2224,7 +2228,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; @@ -2232,6 +2241,9 @@ void ivas_dirac_dec_render_sf_fx( Word16 tmp1; push_wmops( "ivas_dirac_dec_render" ); +#ifdef FIX_867 + set16_fx( q_reference_power_smooth, Q31, CLDFB_SLOTS_PER_SUBFRAME * MAX_OUTPUT_CHANNELS ); +#endif /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; @@ -2304,15 +2316,47 @@ 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] ); + 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 @@ -2326,6 +2370,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 } @@ -2421,13 +2466,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 ); @@ -2444,10 +2521,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(); @@ -2464,6 +2573,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 ); @@ -2812,7 +2923,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, @@ -2825,7 +2940,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, @@ -2844,7 +2963,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, @@ -2870,7 +2993,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, @@ -2887,7 +3014,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, @@ -2912,7 +3043,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, @@ -2977,7 +3112,14 @@ 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 + 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 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 ); @@ -3102,10 +3244,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(); @@ -3126,7 +3278,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 ); @@ -3139,6 +3309,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(); @@ -3209,6 +3380,54 @@ 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 ); + + 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 ) ) { Word32 temp; @@ -3251,6 +3470,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 } } @@ -3328,6 +3548,23 @@ void ivas_dirac_dec_render_sf_fx( IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { +#ifdef FIX_867 + FOR( Word16 l = 0; l < 0; 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 @@ -3338,6 +3575,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 @@ -3350,6 +3588,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 @@ -3358,10 +3610,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 @@ -3370,6 +3640,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, @@ -3381,8 +3652,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 ) @@ -3391,8 +3667,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[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 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 } } } @@ -3402,8 +3686,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[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 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 } } } @@ -3442,6 +3734,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 ); @@ -3472,6 +3799,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 ) { @@ -3527,7 +3855,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 @@ -3536,6 +3882,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 @@ -3550,7 +3897,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 ); @@ -3971,10 +4322,23 @@ 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(); + } + 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(); + } +#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 d9377b5c04af2eeb5fc953ee36347426e46d73cd..b4274eabebfcd5f1062ba235b35dfe2d4d05fd8d 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -200,6 +200,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 ) ) @@ -209,6 +215,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(); } @@ -218,6 +230,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(); @@ -227,6 +245,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(); } @@ -236,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_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(); } @@ -246,6 +276,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(); @@ -255,6 +291,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(); } @@ -264,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_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(); } @@ -273,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( 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(); } @@ -306,8 +360,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 ) @@ -455,8 +519,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 ) @@ -468,22 +537,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 ) @@ -493,19 +577,37 @@ 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 ) ) { 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 + 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 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 ) { @@ -625,9 +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 */ - 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)*/ @@ -803,14 +909,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( /*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++ ) { 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++ ) { @@ -839,7 +946,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 { @@ -879,6 +990,22 @@ 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(); + 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*/ + 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) */ @@ -892,6 +1019,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(); } @@ -899,8 +1027,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++ ) @@ -919,7 +1051,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 { @@ -959,6 +1095,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(); + 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*/ + 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 )*/ @@ -974,13 +1127,19 @@ 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 { 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 } } } @@ -999,6 +1158,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(); + 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*/ + } + 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)*/ @@ -1014,13 +1190,20 @@ 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 { +#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++ ) @@ -1032,6 +1215,20 @@ 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(); + 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*/ + } +#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 )*/ @@ -1045,6 +1242,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(); } @@ -1052,15 +1250,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 + 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 ); @@ -1073,8 +1278,25 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move32(); } 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 + 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++ ) @@ -1085,6 +1307,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, @@ -1092,15 +1315,44 @@ 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] ) ) + { + 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)*/ + } + } +#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], &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 + 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 } /*Diffuse gain*/ @@ -1111,14 +1363,40 @@ 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_diff; 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], 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; + 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 ); + } +#endif } return; @@ -1150,11 +1428,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(); @@ -1163,9 +1449,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; @@ -1259,8 +1550,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], @@ -1269,6 +1569,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*/ @@ -1296,6 +1597,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], @@ -1310,12 +1641,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++ ) @@ -1326,6 +1660,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, @@ -1333,12 +1685,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 ) ) { @@ -1365,8 +1720,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], @@ -1375,6 +1739,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*/ @@ -1385,6 +1750,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], @@ -1393,12 +1778,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++ ) @@ -1409,6 +1797,25 @@ 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, @@ -1416,12 +1823,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 } /*-----------------------------------------------------------------* @@ -1438,12 +1848,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, 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 - *( p_gains_dir++ ) = g2; // p_gains_dir_q +#endif + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -1454,12 +1869,41 @@ 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 +#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_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(); } } @@ -1470,12 +1914,39 @@ 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 +#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 ) ); + 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 + *( p_gains_dir++ ) = g2; // p_gains_dir_q move32(); } } @@ -1500,12 +1971,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(); } } @@ -1520,11 +1996,39 @@ 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 = 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 +#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 - *( p_gains_diff++ ) = g2; // p_gains_diff_q +#endif + *( p_gains_diff++ ) = g2; // p_gains_diff_q move32(); } } @@ -1543,12 +2047,28 @@ 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 } +#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++ ) { @@ -1617,10 +2137,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 } } } @@ -1648,10 +2176,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 } } } @@ -1662,12 +2197,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(); @@ -1766,17 +2317,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 ) @@ -1822,7 +2395,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]; @@ -1866,7 +2444,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 @@ -1904,11 +2499,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*/ @@ -1922,6 +2548,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, @@ -1930,7 +2557,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 } /*-----------------------------------------------------------------* @@ -1943,7 +2574,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 ) ) { @@ -1951,9 +2586,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 ); @@ -1962,9 +2603,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 ); @@ -1974,9 +2621,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(); } @@ -2101,11 +2754,15 @@ 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(); - +#ifndef FIX_867 IF( EQ_32( *( p_power_smooth_prev ), EPSILON_FX ) ) { p_power_smooth_prev++; @@ -2117,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; @@ -2175,6 +2833,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 ); @@ -2189,25 +2869,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++ ) { @@ -2228,14 +2938,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 ) @@ -2243,11 +2963,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 ) { @@ -2268,11 +2997,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(); +#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 ) @@ -2280,23 +3017,62 @@ 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++; } /*Only direct prototype*/ 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 ); + } +#endif + /*Direct*/ g1 = alpha[l]; // Q31 move32(); 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 @@ -2311,16 +3087,39 @@ 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 ) ); +#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 ) ), +#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) 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 ) @@ -2328,19 +3127,45 @@ 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(); } + + +#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 ) ) ), Mpy_32_32( g2, ( *( p_cy_auto_diff_smooth_prev ) ) ) ); // (Q31, q_cy_auto_diff_smooth_prev) -> q_cy_auto_diff_smooth_prev @@ -2365,14 +3190,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(); +#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 ) @@ -2380,11 +3217,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++; } } @@ -2484,6 +3330,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++ ) @@ -2499,6 +3363,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(); /*-----------------------------------------------------------------* @@ -2515,13 +3380,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(); @@ -2531,6 +3424,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(); @@ -3568,6 +4462,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; } @@ -3826,20 +4735,56 @@ 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. */ +#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) */ +#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] ); + + 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 ); + 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) */ @@ -3849,13 +4794,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; } @@ -3875,12 +4823,31 @@ 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 */ 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++ ) { @@ -3897,7 +4864,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[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(); FOR( i = 0; i < num_freq_bands; i++ ) @@ -3918,10 +4897,52 @@ static void computeTargetPSDs_direct_subframe_fx( q_cy_auto_dir_smooth[ch_idx] = add( *q_reference_power, q_tmp ); move16(); 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 + + +#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 ); + } + } +#endif return; } @@ -3947,22 +4968,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; } @@ -3991,9 +5032,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 < sub( num_freq_bands, start_band ); i++ ) + { + q_cy_auto_diff_smooth[cur_idx + start_band + i] = q_reference_power[i]; + move16(); + } +#endif } +#ifndef FIX_867 *q_cy_auto_diff_smooth = *q_reference_power; +#endif move16(); return; @@ -4014,6 +5064,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. */ @@ -4052,6 +5105,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 @@ -4062,11 +5164,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 1982862bfba0627955807d33f96e4beae4eab510..62c59ae447618fc0112cc3b11fd7fb422cfeb446 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -734,10 +734,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 ) @@ -745,6 +749,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(); @@ -801,7 +813,15 @@ 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; + 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 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; @@ -813,6 +833,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 @@ -829,6 +855,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(); } @@ -839,14 +871,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 ) @@ -948,10 +996,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 ) @@ -974,6 +1036,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 ) @@ -1477,7 +1546,12 @@ 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] ) ); +#else *reference_power_q = sub( add( *proto_direct_buffer_f_q, *proto_direct_buffer_f_q ), 31 ); +#endif FOR( k = 1; k < 4; k++ ) { @@ -1511,8 +1585,16 @@ void protoSignalComputation_shd_fx( } *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] ) ); + } +#else *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*/ @@ -1546,6 +1628,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; } @@ -1608,7 +1706,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 ) ) @@ -2430,6 +2532,16 @@ 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] ) @@ -2444,6 +2556,24 @@ void protoSignalComputation2_fx( } *q_reference_power = sub( add( q_reference_power_64fx, norm_shift ), 32 ); 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(); @@ -2520,11 +2650,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 ) ); @@ -3678,7 +3815,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 ); @@ -3691,12 +3832,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 @@ -3709,6 +3872,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 ); @@ -3724,7 +3888,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, @@ -3734,6 +3902,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 @@ -3746,6 +3932,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 ); @@ -3758,7 +3945,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, @@ -3768,6 +3959,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 @@ -3780,6 +3989,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 @@ -3898,11 +4108,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 } } @@ -3960,7 +4182,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(); @@ -3976,6 +4227,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, @@ -3987,14 +4239,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 { @@ -4025,6 +4294,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 ); @@ -4036,6 +4324,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; @@ -4089,6 +4378,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 ) @@ -4098,6 +4410,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, @@ -4106,7 +4419,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 ); @@ -4114,6 +4431,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 @@ -4126,6 +4468,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 396b1163a214518338cb8ba5699a79715a5162c4..2426bd149e93e95b11db7537e9a8a60dfbfa0d7d 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -624,7 +624,11 @@ void ivas_dirac_dec_output_synthesis_close( ); 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 38b2fe524c84a9eaccd902770f6fd8e5637c9afe..46283da5c568a6d8840622d63f3291bfbf979bd0 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -226,10 +226,20 @@ 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 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 */ @@ -277,7 +287,11 @@ typedef struct dirac_output_synthesis_state_structure /* Temporal smoothing memories */ 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 */ /* only pointer to local buffers */ @@ -320,8 +334,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; @@ -331,9 +350,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. */ @@ -344,9 +369,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. */ +#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. */ @@ -446,7 +477,12 @@ 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[]) */ +#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 + Word16 *frequency_axis_fx; /* Q0 */ Word16 *diffuse_response_function_fx; /* Q15 */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 14bb3b95754fca390e83e823c07a324dfdbbbfb0..b7290990fc6e101aa0216ffe632629a486c30538 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8283,37 +8283,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; @@ -8327,32 +8375,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 ) )