Loading lib_com/cldfb.c +414 −36 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_com/ivas_dirac_com_fx.c +105 −2 Original line number Diff line number Diff line Loading @@ -917,15 +917,16 @@ void computeDiffuseness_fixed( move32(); Word32 *p_tmp; const Word32 *p_tmp_c; #ifndef OPT_SBA_DEC_PATH Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; Word16 q_ene, q_intensity, q_intensity_slow; #endif /* OPT_SBA_DEC_PATH */ /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, CLDFB_NO_CHANNELS_MAX ) ); set_zero_fx( intensity_slow_abs, CLDFB_NO_CHANNELS_MAX ); set_zero_fx( energy_slow, CLDFB_NO_CHANNELS_MAX ); #ifndef OPT_SBA_DEC_PATH /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ min_q_shift1 = Q31; move16(); Loading Loading @@ -1064,6 +1065,108 @@ void computeDiffuseness_fixed( move32(); } } #else /* OPT_SBA_DEC_PATH */ Word16 gaurd_bits = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); Word16 norm_arr = getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ); Word16 shift_ene = sub( norm_arr, gaurd_bits ); Word16 q_ene = q_factor_energy[0]; // = add(*q_factor_energy, shift_ene); move16(); norm_arr = 31; move16(); FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { norm_arr = s_min( norm_arr, getScaleFactor32( buffer_intensity[i][j], num_freq_bands ) ); } } Word16 shift_inten = sub( norm_arr, gaurd_bits ); Word16 q_inten = q_factor_intensity[0]; // = add(*q_factor_intensity, shift_inten); move16(); FOR( i = 1; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { q_ene = s_min( q_ene, q_factor_energy[i] ); q_inten = s_min( q_inten, q_factor_intensity[i] ); } q_ene = add( q_ene, shift_ene ); q_inten = add( q_inten, shift_inten ); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; shift_ene = sub( q_ene, q_factor_energy[i] ); shift_inten = sub( q_inten, q_factor_intensity[i] ); FOR( k = 0; k < num_freq_bands; k++ ) { energy_slow[k] = L_add( energy_slow[k], L_shl( *p_tmp_c, shift_ene ) ); move32(); p_tmp_c++; } /* Intensity slow */ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shl( *p_tmp, shift_inten ) ); move32(); p_tmp++; } } } gaurd_bits = shr( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 1 ); norm_arr = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); Word16 shift = sub( norm_arr, gaurd_bits ); scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), shift ); q_inten = add( q_inten, shift ); /* intensity_slow.^2 + intensity_slow_abs*/ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = intensity_slow + j * num_freq_bands; FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); move32(); } } Word16 q_inten_slow = sub( add( q_inten, q_inten ), 31 ); /* Compute Diffuseness */ Word16 exp1, exp2, q_tmp; Word16 diff = sub( 62, q_ene ); p_tmp = intensity_slow_abs; FOR( i = 0; i < num_freq_bands; ++i ) { exp1 = sub( 31, q_inten_slow ); tmp = Sqrt32( p_tmp[i], &exp1 ); tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); q_tmp = sub( diff, add( exp1, exp2 ) ); // bring to Q30 tmp = L_shl_sat( tmp, sub( Q30, q_tmp ) ); diffuseness[i] = L_sub( ONE_IN_Q30, tmp ); move32(); if ( LT_32( diffuseness[i], 0 ) ) { diffuseness[i] = 0; move32(); } } #endif /* OPT_SBA_DEC_PATH */ *q_diffuseness = Q30; move16(); Loading lib_com/ivas_filters_fx.c +14 −3 Original line number Diff line number Diff line Loading @@ -223,7 +223,6 @@ void ivas_filter_process_exp_fx( return; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter() * Loading Loading @@ -263,13 +262,25 @@ static void ivas_iir_2_filter_fx( { L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e ); #ifndef OPT_SBA_DEC_PATH L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e #else /* OPT_SBA_DEC_PATH */ L_tmp_e = s_max( filter_state->state_e[stage][j], L_prod_e ); L_tmp_e = add( L_tmp_e, 1 ); L_tmp = L_add( L_shr( filter_state->state_fx[stage][j], sub( L_tmp_e, filter_state->state_e[stage][j] ) ), L_shr( L_tmp_prod, sub( L_tmp_e, L_prod_e ) ) ); #endif /* OPT_SBA_DEC_PATH */ L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] ); #ifndef OPT_SBA_DEC_PATH filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] #else /* OPT_SBA_DEC_PATH */ Word16 com_e = s_max( L_tmp_e, L_prod_e ); filter_state->state_e[stage][j - 1] = add( com_e, 1 ); filter_state->state_fx[stage][j - 1] = L_sub( L_shr( L_tmp, sub( filter_state->state_e[stage][j - 1], L_tmp_e ) ), L_shr( L_tmp_prod, sub( filter_state->state_e[stage][j - 1], L_prod_e ) ) ); move16(); #endif /* OPT_SBA_DEC_PATH */ move32(); /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/ IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) ) Loading lib_com/ivas_spar_com_fx.c +109 −72 Original line number Diff line number Diff line Loading @@ -51,16 +51,24 @@ * Local constants *------------------------------------------------------------------------------------------*/ #define IVAS_FLT_EPS ( 1e-10F ) #define IVAS_FIX_EPS ( 1 ) #define IVAS_FIX_EPS_Q40 ( 110 ) #define IVAS_DBL_EPS ( (double) 1e-20 ) #define IVAS_REMIX_MULT_FAC ( 0.5f ) #define IVAS_ACTIVEW_DM_F ( 1.0f ) #define IVAS_ACTIVEW_DM_F_Q30 ( ONE_IN_Q30 ) /*1 Q30*/ #define IVAS_ACTIVEW_DM_F_DTX ( 0.25f ) #define IVAS_ACTIVEW_DM_F_DTX_Q30 ( 268435456 ) /*0.25 Q30*/ #define IVAS_ACTIVEW_DM_F_VLBR ( 0.25f ) #define IVAS_ACTIVEW_DM_F_VLBR_Q30 ( 268435456 ) /*0.25 Q30*/ #define IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH ( 3.0f ) #define IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH_Q29 ( 1610612736 ) /*3 Q29*/ #define IVAS_P_NORM_SCALING ( 1.0f ) #define IVAS_P_NORM_SCALING_FX ( ONE_IN_Q31 ) // 1 Q31 #define IVAS_P_NORM_SCALING_DTX ( 0.75f ) #define IVAS_P_NORM_SCALING_DTX_FX ( 1610612736 ) // 0.75 Q31 #define IVAS_MAT_DIM_3 ( 3 ) Loading Loading @@ -1618,18 +1626,8 @@ static void ivas_get_Wscaling_factor_enc_fx( ivas_calc_post_pred_per_band_enc_fx( cov_real, q_cov_real, mixer_mat, q_mixer_mat, num_ch, b, postpred_cov_re, &q_postpred_cov_re ); } tmp = L_shl_sat( IVAS_FIX_EPS_Q40, sub( q_postpred_cov_re, 40 ) ); IF( LE_32( postpred_cov_re[0][0], tmp ) ) { Gw_sq = Mpy_32_32( cov_real[0][0][b], 1250000000 ); /*1/1e-10 = 1250000000 Q(-4)*/ q_Gw_sq = add( q_cov_real[0][0][b], -4 - 31 ); } ELSE { Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], postpred_cov_re[0][0], &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re)) Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], L_max( postpred_cov_re[0][0], IVAS_FIX_EPS ), &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re)) q_Gw_sq = add( sub( 15, tmp_exp ), sub( q_cov_real[0][0][b], q_postpred_cov_re ) ); } shift = MAX16B; move16(); Loading Loading @@ -1994,15 +1992,12 @@ static void ivas_calc_post_pred_per_band_enc_fx( Word32 postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*q_postpred_cov_re*/ Word16 *q_postpred_cov_re ) { Word16 i, j, k; Word16 i, j, k, guard_bits, tmp, q_temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], q_tmp_re, q_W_tmp; Word32 dmx_mat_conj[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 q_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 min_val; Word32 tmp_re; Word16 tmp_q; Word16 tmp_e; Word32 max_val; Word64 tmp_re, W_tmp; Word16 q_postpred_cov_re_per_value[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; FOR( i = 0; i < num_ch; i++ ) { Loading @@ -2019,71 +2014,135 @@ static void ivas_calc_post_pred_per_band_enc_fx( set32_fx( postpred_cov_re[i], 0, num_ch ); } min_val = MAX16B; move16(); max_val = 1; move32(); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { temp_mat[i][j] = 0; move32(); temp_mat_e[i][j] = 0; tmp_re = 0; move64(); q_tmp_re = 31; move16(); FOR( k = 0; k < num_ch; k++ ) { tmp_re = Mpy_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ); tmp_e = sub( 62, add( q_cov_real[i][k][band_idx], q_mixer_mat ) ); IF( tmp_re ) W_tmp = W_shr( W_mult0_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ), q_mixer_mat ); /*q_cov_real[i][k][band_idx]*/ IF( LT_16( q_cov_real[i][k][band_idx], q_tmp_re ) ) { tmp_re = W_add( W_shr( tmp_re, sub( q_tmp_re, q_cov_real[i][k][band_idx] ) ), W_tmp ); /*q_cov_real[i][k][band_idx]*/ q_tmp_re = q_cov_real[i][k][band_idx]; move16(); } ELSE { tmp_re = W_add( tmp_re, W_shr( W_tmp, sub( q_cov_real[i][k][band_idx], q_tmp_re ) ) ); /*q_tmp_re*/ } } IF( tmp_re == 0 ) { q_temp_mat[i][j] = 31; move16(); temp_mat[i][j] = 0; move32(); } ELSE { temp_mat[i][j] = BASOP_Util_Add_Mant32Exp( temp_mat[i][j], temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); q_temp_mat[i][j] = q_tmp_re; move16(); q_tmp_re = W_norm( tmp_re ); temp_mat[i][j] = W_extract_h( W_shl( tmp_re, q_tmp_re ) ); /*q_temp_mat[i][j]+ q_tmp_re -32*/ move32(); q_temp_mat[i][j] = sub( add( q_temp_mat[i][j], q_tmp_re ), 32 ); move16(); } max_val = L_max( max_val, L_abs( temp_mat[i][j] ) ); } } guard_bits = find_guarded_bits_fx( num_ch ); tmp = norm_l( max_val ); IF( LT_16( tmp, guard_bits ) ) { guard_bits = sub( guard_bits, tmp ); } ELSE { guard_bits = 0; move16(); } *q_postpred_cov_re = 31; move16(); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { q_postpred_cov_re_buf[i][j] = *q_postpred_cov_re; tmp_re = 0; move64(); q_tmp_re = 31; move16(); FOR( k = 0; k < num_ch; k++ ) { tmp_re = Mpy_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ); tmp_q = sub( q_mixer_mat, temp_mat_e[k][j] ); IF( tmp_re ) W_tmp = W_shr( W_mult0_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ), guard_bits ); // q_temp_mat[k][j]+ q_mixer_mat-guard_bits q_W_tmp = sub( add( q_temp_mat[k][j], q_mixer_mat ), guard_bits ); IF( LT_16( q_W_tmp, q_tmp_re ) ) { tmp_e = sub( 31, q_postpred_cov_re_buf[i][j] ); postpred_cov_re[i][j] = BASOP_Util_Add_Mant32Exp( postpred_cov_re[i][j], tmp_e, tmp_re, sub( Q31, tmp_q ), &tmp_e ); move32(); q_postpred_cov_re_buf[i][j] = sub( 31, tmp_e ); tmp_re = W_add( W_shr( tmp_re, sub( q_tmp_re, q_W_tmp ) ), W_tmp ); // q_W_tmp q_tmp_re = q_W_tmp; move16(); } ELSE { tmp_re = W_add( tmp_re, W_shr( W_tmp, sub( q_W_tmp, q_tmp_re ) ) ); // q_tmp_re } IF( postpred_cov_re[i][j] ) } if ( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) ) { min_val = s_min( min_val, q_postpred_cov_re_buf[i][j] ); tmp_re = 0; move64(); } q_postpred_cov_re_per_value[i][j] = q_tmp_re; move16(); IF( tmp_re == 0 ) { postpred_cov_re[i][j] = W_extract_l( tmp_re ); /* q_tmp_re*/ move32(); } ELSE { q_tmp_re = W_norm( tmp_re ); postpred_cov_re[i][j] = W_extract_h( W_shl( tmp_re, q_tmp_re ) ); /* q_tmp_re+ q_postpred_cov_re_per_value[i][j] -32*/ move32(); q_postpred_cov_re_per_value[i][j] = sub( add( q_tmp_re, q_postpred_cov_re_per_value[i][j] ), 32 ); move16(); } *q_postpred_cov_re = s_min( *q_postpred_cov_re, q_postpred_cov_re_per_value[i][j] ); move16(); } } /*Changing Q of postpred_cov_re to min_val*/ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { IF( postpred_cov_re[i][j] ) IF( postpred_cov_re[i][j] >= 0 ) { postpred_cov_re[i][j] = L_shr( postpred_cov_re[i][j], sub( q_postpred_cov_re_per_value[i][j], *q_postpred_cov_re ) ); //*q_postpred_cov_re move32(); } ELSE { postpred_cov_re[i][j] = L_shl( postpred_cov_re[i][j], sub( min_val, q_postpred_cov_re_buf[i][j] ) ); postpred_cov_re[i][j] = L_negate( L_shr( L_negate( postpred_cov_re[i][j] ), sub( q_postpred_cov_re_per_value[i][j], *q_postpred_cov_re ) ) ); //*q_postpred_cov_re move32(); } } } FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < i; j++ ) Loading @@ -2093,14 +2152,6 @@ static void ivas_calc_post_pred_per_band_enc_fx( } } if ( EQ_16( min_val, MAX16B ) ) { min_val = Q31; move16(); } *q_postpred_cov_re = min_val; move16(); return; } Loading Loading @@ -2636,8 +2687,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( trace = W_add( trace, W_deposit32_l( L_abs( cov_uu_re[i - num_dmx][i - num_dmx] ) ) ); // q_cov_uu_re } factor = postpred_cov_re[0][0]; // q_postpred_cov_re move32(); factor = L_max( IVAS_FIX_EPS, postpred_cov_re[0][0] ); // q_postpred_cov_re q_factor = q_postpred_cov_re; move16(); IF( trace != 0 ) Loading @@ -2658,20 +2708,10 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( factor = L_max( factor, tmp ); // q_factor } tmp = L_shl_sat( IVAS_FIX_EPS_Q40, sub( q_factor, 40 ) ); Word16 factor_exp = 0; move16(); IF( LE_32( factor, tmp ) ) { factor = 1250000000; factor_exp = Q31 - ( -4 ); } ELSE { factor = BASOP_Util_Divide3232_Scale( 1, factor, &factor_exp ); // q=15-(factor_exp+31-(31-q_factor)) factor_exp = add( factor_exp, q_factor ); } /* normalise Hermitian (except for rounding) cov_uu */ FOR( i = num_dmx; i < num_ch; i++ ) Loading Loading @@ -3271,9 +3311,6 @@ void ivas_calc_c_p_coeffs_enc_fx( Word16 i, j, q_postpred_cov_re; Word32 postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; q_postpred_cov_re = 0; move16(); FOR( i = 0; i < IVAS_SPAR_MAX_CH; i++ ) { set_zero_fx( postpred_cov_re[i], IVAS_SPAR_MAX_CH ); Loading lib_com/ivas_transient_det_fx.c +8 −0 Original line number Diff line number Diff line Loading @@ -403,7 +403,15 @@ void ivas_td_decorr_get_ducking_gains_fx( FOR( i = 0; i < frame_len; i++ ) { // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ #ifndef OPT_SBA_DEC_PATH e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] ); #else /* OPT_SBA_DEC_PATH */ Word32 tmp = L_abs( e_fast_fx[i] ); Word16 nrm = norm_l( tmp ); nrm = sub( nrm, 1 ); // 1 headroom for add e_fast_e[i] = sub( e_fast_e[i], nrm ); e_fast_fx[i] = L_add( L_shl( tmp, nrm ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, e_fast_e[i] ) ); #endif /* OPT_SBA_DEC_PATH */ move32(); e_slow_fx[i] = e_fast_fx[i]; move32(); Loading Loading
lib_com/ivas_dirac_com_fx.c +105 −2 Original line number Diff line number Diff line Loading @@ -917,15 +917,16 @@ void computeDiffuseness_fixed( move32(); Word32 *p_tmp; const Word32 *p_tmp_c; #ifndef OPT_SBA_DEC_PATH Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; Word16 q_ene, q_intensity, q_intensity_slow; #endif /* OPT_SBA_DEC_PATH */ /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, CLDFB_NO_CHANNELS_MAX ) ); set_zero_fx( intensity_slow_abs, CLDFB_NO_CHANNELS_MAX ); set_zero_fx( energy_slow, CLDFB_NO_CHANNELS_MAX ); #ifndef OPT_SBA_DEC_PATH /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ min_q_shift1 = Q31; move16(); Loading Loading @@ -1064,6 +1065,108 @@ void computeDiffuseness_fixed( move32(); } } #else /* OPT_SBA_DEC_PATH */ Word16 gaurd_bits = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); Word16 norm_arr = getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ); Word16 shift_ene = sub( norm_arr, gaurd_bits ); Word16 q_ene = q_factor_energy[0]; // = add(*q_factor_energy, shift_ene); move16(); norm_arr = 31; move16(); FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { norm_arr = s_min( norm_arr, getScaleFactor32( buffer_intensity[i][j], num_freq_bands ) ); } } Word16 shift_inten = sub( norm_arr, gaurd_bits ); Word16 q_inten = q_factor_intensity[0]; // = add(*q_factor_intensity, shift_inten); move16(); FOR( i = 1; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { q_ene = s_min( q_ene, q_factor_energy[i] ); q_inten = s_min( q_inten, q_factor_intensity[i] ); } q_ene = add( q_ene, shift_ene ); q_inten = add( q_inten, shift_inten ); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; shift_ene = sub( q_ene, q_factor_energy[i] ); shift_inten = sub( q_inten, q_factor_intensity[i] ); FOR( k = 0; k < num_freq_bands; k++ ) { energy_slow[k] = L_add( energy_slow[k], L_shl( *p_tmp_c, shift_ene ) ); move32(); p_tmp_c++; } /* Intensity slow */ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shl( *p_tmp, shift_inten ) ); move32(); p_tmp++; } } } gaurd_bits = shr( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 1 ); norm_arr = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); Word16 shift = sub( norm_arr, gaurd_bits ); scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), shift ); q_inten = add( q_inten, shift ); /* intensity_slow.^2 + intensity_slow_abs*/ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = intensity_slow + j * num_freq_bands; FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); move32(); } } Word16 q_inten_slow = sub( add( q_inten, q_inten ), 31 ); /* Compute Diffuseness */ Word16 exp1, exp2, q_tmp; Word16 diff = sub( 62, q_ene ); p_tmp = intensity_slow_abs; FOR( i = 0; i < num_freq_bands; ++i ) { exp1 = sub( 31, q_inten_slow ); tmp = Sqrt32( p_tmp[i], &exp1 ); tmp = BASOP_Util_Divide3232_Scale_cadence( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); q_tmp = sub( diff, add( exp1, exp2 ) ); // bring to Q30 tmp = L_shl_sat( tmp, sub( Q30, q_tmp ) ); diffuseness[i] = L_sub( ONE_IN_Q30, tmp ); move32(); if ( LT_32( diffuseness[i], 0 ) ) { diffuseness[i] = 0; move32(); } } #endif /* OPT_SBA_DEC_PATH */ *q_diffuseness = Q30; move16(); Loading
lib_com/ivas_filters_fx.c +14 −3 Original line number Diff line number Diff line Loading @@ -223,7 +223,6 @@ void ivas_filter_process_exp_fx( return; } /*-----------------------------------------------------------------------------------------* * Function ivas_iir_2_filter() * Loading Loading @@ -263,13 +262,25 @@ static void ivas_iir_2_filter_fx( { L_tmp_prod = Mpy_32_32( filter_state->num_fx[stage][j], tmp_pIn_buf_i_fx ); // Q31-L_prod_e L_prod_e = add( filter_state->num_e[stage][j], tmp_pIn_buf_i_e ); #ifndef OPT_SBA_DEC_PATH L_tmp = BASOP_Util_Add_Mant32Exp( filter_state->state_fx[stage][j], filter_state->state_e[stage][j], L_tmp_prod, L_prod_e, &L_tmp_e ); // Q31 - L_tmp_e #else /* OPT_SBA_DEC_PATH */ L_tmp_e = s_max( filter_state->state_e[stage][j], L_prod_e ); L_tmp_e = add( L_tmp_e, 1 ); L_tmp = L_add( L_shr( filter_state->state_fx[stage][j], sub( L_tmp_e, filter_state->state_e[stage][j] ) ), L_shr( L_tmp_prod, sub( L_tmp_e, L_prod_e ) ) ); #endif /* OPT_SBA_DEC_PATH */ L_tmp_prod = Mpy_32_32( filter_state->den_fx[stage][j], pOut_fx[i] ); // Q31 - ( pIn_Out_e[i]+filter_state->den_e[stage][j] ) L_prod_e = add( pIn_Out_e[i], filter_state->den_e[stage][j] ); #ifndef OPT_SBA_DEC_PATH filter_state->state_fx[stage][j - 1] = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_e, L_negate( L_tmp_prod ), L_prod_e, &filter_state->state_e[stage][j - 1] ); // Q31 - filter_state->state_e[stage][j - 1] #else /* OPT_SBA_DEC_PATH */ Word16 com_e = s_max( L_tmp_e, L_prod_e ); filter_state->state_e[stage][j - 1] = add( com_e, 1 ); filter_state->state_fx[stage][j - 1] = L_sub( L_shr( L_tmp, sub( filter_state->state_e[stage][j - 1], L_tmp_e ) ), L_shr( L_tmp_prod, sub( filter_state->state_e[stage][j - 1], L_prod_e ) ) ); move16(); #endif /* OPT_SBA_DEC_PATH */ move32(); /*In case when exponent is less than -31 the value is very small and negligible hence resetting it to zero to avoid exponent overflow*/ IF( LT_16( filter_state->state_e[stage][j - 1], -31 ) ) Loading
lib_com/ivas_spar_com_fx.c +109 −72 Original line number Diff line number Diff line Loading @@ -51,16 +51,24 @@ * Local constants *------------------------------------------------------------------------------------------*/ #define IVAS_FLT_EPS ( 1e-10F ) #define IVAS_FIX_EPS ( 1 ) #define IVAS_FIX_EPS_Q40 ( 110 ) #define IVAS_DBL_EPS ( (double) 1e-20 ) #define IVAS_REMIX_MULT_FAC ( 0.5f ) #define IVAS_ACTIVEW_DM_F ( 1.0f ) #define IVAS_ACTIVEW_DM_F_Q30 ( ONE_IN_Q30 ) /*1 Q30*/ #define IVAS_ACTIVEW_DM_F_DTX ( 0.25f ) #define IVAS_ACTIVEW_DM_F_DTX_Q30 ( 268435456 ) /*0.25 Q30*/ #define IVAS_ACTIVEW_DM_F_VLBR ( 0.25f ) #define IVAS_ACTIVEW_DM_F_VLBR_Q30 ( 268435456 ) /*0.25 Q30*/ #define IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH ( 3.0f ) #define IVAS_LIN_ACTIVEW_QUAD_ACTIVEW_THRESH_Q29 ( 1610612736 ) /*3 Q29*/ #define IVAS_P_NORM_SCALING ( 1.0f ) #define IVAS_P_NORM_SCALING_FX ( ONE_IN_Q31 ) // 1 Q31 #define IVAS_P_NORM_SCALING_DTX ( 0.75f ) #define IVAS_P_NORM_SCALING_DTX_FX ( 1610612736 ) // 0.75 Q31 #define IVAS_MAT_DIM_3 ( 3 ) Loading Loading @@ -1618,18 +1626,8 @@ static void ivas_get_Wscaling_factor_enc_fx( ivas_calc_post_pred_per_band_enc_fx( cov_real, q_cov_real, mixer_mat, q_mixer_mat, num_ch, b, postpred_cov_re, &q_postpred_cov_re ); } tmp = L_shl_sat( IVAS_FIX_EPS_Q40, sub( q_postpred_cov_re, 40 ) ); IF( LE_32( postpred_cov_re[0][0], tmp ) ) { Gw_sq = Mpy_32_32( cov_real[0][0][b], 1250000000 ); /*1/1e-10 = 1250000000 Q(-4)*/ q_Gw_sq = add( q_cov_real[0][0][b], -4 - 31 ); } ELSE { Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], postpred_cov_re[0][0], &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re)) Gw_sq = BASOP_Util_Divide3232_Scale( cov_real[0][0][b], L_max( postpred_cov_re[0][0], IVAS_FIX_EPS ), &tmp_exp ); // 15-(tmp_exp-(q_cov_real[0][0][b]- q_postpred_cov_re)) q_Gw_sq = add( sub( 15, tmp_exp ), sub( q_cov_real[0][0][b], q_postpred_cov_re ) ); } shift = MAX16B; move16(); Loading Loading @@ -1994,15 +1992,12 @@ static void ivas_calc_post_pred_per_band_enc_fx( Word32 postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*q_postpred_cov_re*/ Word16 *q_postpred_cov_re ) { Word16 i, j, k; Word16 i, j, k, guard_bits, tmp, q_temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], q_tmp_re, q_W_tmp; Word32 dmx_mat_conj[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 q_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 min_val; Word32 tmp_re; Word16 tmp_q; Word16 tmp_e; Word32 max_val; Word64 tmp_re, W_tmp; Word16 q_postpred_cov_re_per_value[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; FOR( i = 0; i < num_ch; i++ ) { Loading @@ -2019,71 +2014,135 @@ static void ivas_calc_post_pred_per_band_enc_fx( set32_fx( postpred_cov_re[i], 0, num_ch ); } min_val = MAX16B; move16(); max_val = 1; move32(); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { temp_mat[i][j] = 0; move32(); temp_mat_e[i][j] = 0; tmp_re = 0; move64(); q_tmp_re = 31; move16(); FOR( k = 0; k < num_ch; k++ ) { tmp_re = Mpy_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ); tmp_e = sub( 62, add( q_cov_real[i][k][band_idx], q_mixer_mat ) ); IF( tmp_re ) W_tmp = W_shr( W_mult0_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ), q_mixer_mat ); /*q_cov_real[i][k][band_idx]*/ IF( LT_16( q_cov_real[i][k][band_idx], q_tmp_re ) ) { tmp_re = W_add( W_shr( tmp_re, sub( q_tmp_re, q_cov_real[i][k][band_idx] ) ), W_tmp ); /*q_cov_real[i][k][band_idx]*/ q_tmp_re = q_cov_real[i][k][band_idx]; move16(); } ELSE { tmp_re = W_add( tmp_re, W_shr( W_tmp, sub( q_cov_real[i][k][band_idx], q_tmp_re ) ) ); /*q_tmp_re*/ } } IF( tmp_re == 0 ) { q_temp_mat[i][j] = 31; move16(); temp_mat[i][j] = 0; move32(); } ELSE { temp_mat[i][j] = BASOP_Util_Add_Mant32Exp( temp_mat[i][j], temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); q_temp_mat[i][j] = q_tmp_re; move16(); q_tmp_re = W_norm( tmp_re ); temp_mat[i][j] = W_extract_h( W_shl( tmp_re, q_tmp_re ) ); /*q_temp_mat[i][j]+ q_tmp_re -32*/ move32(); q_temp_mat[i][j] = sub( add( q_temp_mat[i][j], q_tmp_re ), 32 ); move16(); } max_val = L_max( max_val, L_abs( temp_mat[i][j] ) ); } } guard_bits = find_guarded_bits_fx( num_ch ); tmp = norm_l( max_val ); IF( LT_16( tmp, guard_bits ) ) { guard_bits = sub( guard_bits, tmp ); } ELSE { guard_bits = 0; move16(); } *q_postpred_cov_re = 31; move16(); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { q_postpred_cov_re_buf[i][j] = *q_postpred_cov_re; tmp_re = 0; move64(); q_tmp_re = 31; move16(); FOR( k = 0; k < num_ch; k++ ) { tmp_re = Mpy_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ); tmp_q = sub( q_mixer_mat, temp_mat_e[k][j] ); IF( tmp_re ) W_tmp = W_shr( W_mult0_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ), guard_bits ); // q_temp_mat[k][j]+ q_mixer_mat-guard_bits q_W_tmp = sub( add( q_temp_mat[k][j], q_mixer_mat ), guard_bits ); IF( LT_16( q_W_tmp, q_tmp_re ) ) { tmp_e = sub( 31, q_postpred_cov_re_buf[i][j] ); postpred_cov_re[i][j] = BASOP_Util_Add_Mant32Exp( postpred_cov_re[i][j], tmp_e, tmp_re, sub( Q31, tmp_q ), &tmp_e ); move32(); q_postpred_cov_re_buf[i][j] = sub( 31, tmp_e ); tmp_re = W_add( W_shr( tmp_re, sub( q_tmp_re, q_W_tmp ) ), W_tmp ); // q_W_tmp q_tmp_re = q_W_tmp; move16(); } ELSE { tmp_re = W_add( tmp_re, W_shr( W_tmp, sub( q_W_tmp, q_tmp_re ) ) ); // q_tmp_re } IF( postpred_cov_re[i][j] ) } if ( LT_64( W_abs( tmp_re ), L_shl( IVAS_FIX_EPS, guard_bits ) ) ) { min_val = s_min( min_val, q_postpred_cov_re_buf[i][j] ); tmp_re = 0; move64(); } q_postpred_cov_re_per_value[i][j] = q_tmp_re; move16(); IF( tmp_re == 0 ) { postpred_cov_re[i][j] = W_extract_l( tmp_re ); /* q_tmp_re*/ move32(); } ELSE { q_tmp_re = W_norm( tmp_re ); postpred_cov_re[i][j] = W_extract_h( W_shl( tmp_re, q_tmp_re ) ); /* q_tmp_re+ q_postpred_cov_re_per_value[i][j] -32*/ move32(); q_postpred_cov_re_per_value[i][j] = sub( add( q_tmp_re, q_postpred_cov_re_per_value[i][j] ), 32 ); move16(); } *q_postpred_cov_re = s_min( *q_postpred_cov_re, q_postpred_cov_re_per_value[i][j] ); move16(); } } /*Changing Q of postpred_cov_re to min_val*/ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { IF( postpred_cov_re[i][j] ) IF( postpred_cov_re[i][j] >= 0 ) { postpred_cov_re[i][j] = L_shr( postpred_cov_re[i][j], sub( q_postpred_cov_re_per_value[i][j], *q_postpred_cov_re ) ); //*q_postpred_cov_re move32(); } ELSE { postpred_cov_re[i][j] = L_shl( postpred_cov_re[i][j], sub( min_val, q_postpred_cov_re_buf[i][j] ) ); postpred_cov_re[i][j] = L_negate( L_shr( L_negate( postpred_cov_re[i][j] ), sub( q_postpred_cov_re_per_value[i][j], *q_postpred_cov_re ) ) ); //*q_postpred_cov_re move32(); } } } FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < i; j++ ) Loading @@ -2093,14 +2152,6 @@ static void ivas_calc_post_pred_per_band_enc_fx( } } if ( EQ_16( min_val, MAX16B ) ) { min_val = Q31; move16(); } *q_postpred_cov_re = min_val; move16(); return; } Loading Loading @@ -2636,8 +2687,7 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( trace = W_add( trace, W_deposit32_l( L_abs( cov_uu_re[i - num_dmx][i - num_dmx] ) ) ); // q_cov_uu_re } factor = postpred_cov_re[0][0]; // q_postpred_cov_re move32(); factor = L_max( IVAS_FIX_EPS, postpred_cov_re[0][0] ); // q_postpred_cov_re q_factor = q_postpred_cov_re; move16(); IF( trace != 0 ) Loading @@ -2658,20 +2708,10 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( factor = L_max( factor, tmp ); // q_factor } tmp = L_shl_sat( IVAS_FIX_EPS_Q40, sub( q_factor, 40 ) ); Word16 factor_exp = 0; move16(); IF( LE_32( factor, tmp ) ) { factor = 1250000000; factor_exp = Q31 - ( -4 ); } ELSE { factor = BASOP_Util_Divide3232_Scale( 1, factor, &factor_exp ); // q=15-(factor_exp+31-(31-q_factor)) factor_exp = add( factor_exp, q_factor ); } /* normalise Hermitian (except for rounding) cov_uu */ FOR( i = num_dmx; i < num_ch; i++ ) Loading Loading @@ -3271,9 +3311,6 @@ void ivas_calc_c_p_coeffs_enc_fx( Word16 i, j, q_postpred_cov_re; Word32 postpred_cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; q_postpred_cov_re = 0; move16(); FOR( i = 0; i < IVAS_SPAR_MAX_CH; i++ ) { set_zero_fx( postpred_cov_re[i], IVAS_SPAR_MAX_CH ); Loading
lib_com/ivas_transient_det_fx.c +8 −0 Original line number Diff line number Diff line Loading @@ -403,7 +403,15 @@ void ivas_td_decorr_get_ducking_gains_fx( FOR( i = 0; i < frame_len; i++ ) { // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ #ifndef OPT_SBA_DEC_PATH e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] ); #else /* OPT_SBA_DEC_PATH */ Word32 tmp = L_abs( e_fast_fx[i] ); Word16 nrm = norm_l( tmp ); nrm = sub( nrm, 1 ); // 1 headroom for add e_fast_e[i] = sub( e_fast_e[i], nrm ); e_fast_fx[i] = L_add( L_shl( tmp, nrm ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, e_fast_e[i] ) ); #endif /* OPT_SBA_DEC_PATH */ move32(); e_slow_fx[i] = e_fast_fx[i]; move32(); Loading