Loading lib_com/cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ #define FOUR_IN_Q28 1073741824 #define MAX_WORD16 32767 #define ONE_IN_Q45 (Word64)0x200000000000 #define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants Loading lib_com/ivas_cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ typedef enum RENDERER_OSBA_LS } RENDERER_TYPE; #define MAX_FREQUENCY_BANDS 64 /*----------------------------------------------------------------------------------* * IVAS general constants Loading lib_com/ivas_dirac_com.c +32 −17 Original line number Diff line number Diff line Loading @@ -966,38 +966,55 @@ void computeDiffuseness_fixed( p_tmp_c = buffer_energy + i * num_freq_bands; q_tmp = add( q_factor_energy[i], min_q_shift1 ); Word16 shift_q = sub( q_tmp, q_ene ); IF( shift_q < 0 ) { FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp_c[k], min_q_shift1 ); IF( LT_16( q_tmp, q_ene ) ) { energy_slow[k] = L_add( L_shr( energy_slow[k], sub( q_ene, q_tmp ) ), tmp ); energy_slow[k] = L_add( L_shl( energy_slow[k], shift_q ), tmp ); move32(); } } ELSE { energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, sub( q_tmp, q_ene ) ) ); FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp_c[k], min_q_shift1 ); energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, shift_q ) ); move32(); } } q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ q_tmp = add( q_factor_intensity[i], min_q_shift2 ); shift_q = sub( q_tmp, q_intensity ); IF( shift_q > 0 ) { FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp[k], min_q_shift2 ); IF( LT_16( q_intensity, q_tmp ) ) { intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shr( tmp, sub( q_tmp, q_intensity ) ) ); intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shr( tmp, shift_q ) ); move32(); } } } ELSE { intensity_slow[j * num_freq_bands + k] = L_add( L_shr( intensity_slow[j * num_freq_bands + k], sub( q_intensity, q_tmp ) ), tmp ); FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp[k], min_q_shift2 ); intensity_slow[j * num_freq_bands + k] = L_add( L_shl( intensity_slow[j * num_freq_bands + k], shift_q ), tmp ); move32(); } } Loading @@ -1017,9 +1034,7 @@ void computeDiffuseness_fixed( FOR( k = 0; k < num_freq_bands; k++ ) { p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] ); move32(); intensity_slow_abs[k] = L_add( intensity_slow_abs[k], p_tmp[k] ); intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); move32(); } } Loading lib_com/ivas_fb_mixer.c +35 −43 Original line number Diff line number Diff line Loading @@ -915,7 +915,10 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); Word16 idx_short_stride_bin_to_band = 0; move16(); Word16 quo, tmp, exp_diff; Word32 temp = Mpy_32_32( sampling_rate, 42949673 /* FRAMES_PER_SEC in Q31 */ ); frame_len = extract_l( temp ); FOR( i = 0; i < bands; i++ ) { Loading @@ -932,13 +935,11 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 short_stride_pow_spec_fx[MDFT_FB_BANDS_240]; Word32 short_stride_nrg_fx = 0; move16(); Word16 exp_diff = 0, tmp; exp_diff = 0; move16(); Word32 cldfb_nrg_fx = 0; Word16 cldfb_nrg_e = 0; move16(); move16(); Word64 cldfb_nrg_fx = 0; move64(); Word16 short_stride = pFb->fb_bin_to_band.short_stride; move16(); Word32 res_dec1, res_frac, res_dec2; Loading @@ -959,38 +960,24 @@ static Word16 ivas_calculate_abs_fr_fx( { Word32 sq_abs_fx; Word16 sq_abs_e; // Word32 real = L_shr( *long_mdft_ptr_re_fx, 3 ); // Q27 Word32 real = *long_mdft_ptr_re_fx; // Q30 move32(); // Word32 imag = L_shr( *long_mdft_ptr_im_fx, 3 ); // Q27 Word32 imag = *long_mdft_ptr_im_fx; // Q30 Word16 real_exp, imag_exp; move32(); Word32 real_sq, imag_sq; real_sq = Mpy_32_32( real, real ); // Q30 + Q30 - 31 = Q29 real_exp = 2; move32(); imag_sq = Mpy_32_32( imag, imag ); // Q30 + Q30 - 31 = Q29 imag_exp = 2; move32(); sq_abs_fx = BASOP_Util_Add_Mant32Exp( real_sq, real_exp, imag_sq, imag_exp, &sq_abs_e ); // Q(31 - sq_abs_e) Word64 acc = W_mac_32_32( W_mult_32_32( real, real ), imag, imag ); // Q61 sq_abs_fx = W_extract_h( acc ); // Q28 long_mdft_ptr_re_fx++; long_mdft_ptr_im_fx++; /* accumulate bin energies within a short stride bin */ short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); // Q(31 - sq_abs_e) -> Q22 short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shr( sq_abs_fx, 6 ) ); // Q22 move32(); IF( !( ( j + 1 ) % num_bins_per_short_stride_bin ) ) IF( !( add( j, 1 ) % num_bins_per_short_stride_bin ) ) { /* new short stride bin */ short_stride_pow_spec_fx[j / num_bins_per_short_stride_bin] = short_stride_nrg_fx; /* energy rather than magnitude works better for covariance weighting*/ Loading @@ -1001,33 +988,38 @@ static Word16 ivas_calculate_abs_fr_fx( } /* accumulate bin energies within a CLDFB band */ cldfb_nrg_fx = BASOP_Util_Add_Mant32Exp( cldfb_nrg_fx, cldfb_nrg_e, sq_abs_fx, sq_abs_e, &cldfb_nrg_e ); cldfb_nrg_fx = W_mac_32_32( cldfb_nrg_fx, sq_abs_fx, 1 ); // Q29 IF( !( ( j + 1 ) % num_bins_per_cldfb_band ) ) IF( !( add( j, 1 ) % num_bins_per_cldfb_band ) ) { Word32 temp = Sqrt32( cldfb_nrg_fx, &cldfb_nrg_e ); temp = L_shl( temp, sub( cldfb_nrg_e, Q9 ) ); // Q22 Word16 exp = W_norm( cldfb_nrg_fx ); cldfb_nrg_fx = W_shl( cldfb_nrg_fx, exp ); exp = sub( 34, exp ); // 31 - (Q29 + exp -32) temp = Sqrt32( W_extract_h( cldfb_nrg_fx ), &exp ); temp = L_shl( temp, sub( exp, Q9 ) ); // Q22 pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j / num_bins_per_cldfb_band][i] = temp; // Q22 move32(); cldfb_nrg_fx = 0; move32(); cldfb_nrg_e = 0; move16(); } } quo = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, short_stride_max_per_spar_band_fx, &exp_diff ); /* Q of quo = Q30 - Q22 + (15 - exp_diff) --> Q23 - exp_diff. With Mult_32_16, Q23 - exp_diff - 15 --> Q8 - exp_diff */ exp_diff = sub( Q8, exp_diff ); /*loop over the short MDFT bins*/ FOR( j = 0; j < short_stride; j++ ) { tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], short_stride_max_per_spar_band_fx, &exp_diff ); short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 short_stride_pow_spec_fx[j] = L_shr( Mult_32_16( short_stride_pow_spec_fx[j], quo ), exp_diff ); // Q22 move32(); short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], 1258291 ), 0 ); // 0.3f * ONE_IN_Q22 move32(); tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], 2936012, &exp_diff ); // 0.7f * ONE_IN_Q22 short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 short_stride_pow_spec_fx[j] = L_shl( Mpy_32_32( short_stride_pow_spec_fx[j], 1533916891 /* 1/0.7 in Q30 */ ), 1 ); // Q22 move32(); IF( short_stride_pow_spec_fx[j] > 0 ) { assert( idx_short_stride_bin_to_band < 2 * MDFT_FB_BANDS_240 ); /* array size of p_short_stride_bin_to_band */ Loading Loading @@ -1083,6 +1075,13 @@ static Word16 ivas_calculate_abs_fr_fx( sum_over_spar_bands_fx = L_max( sum_over_spar_bands_fx, EPSILON_FX ); // Q22 move32(); exp_diff = 0; move16(); tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, sum_over_spar_bands_fx, &exp_diff ); /* Q of quo = Q30 - Q22 + (15 - exp_diff) --> Q23 - exp_diff. With Mult_32_16, Q23 - exp_diff - 15 --> Q8 - exp_diff */ exp_diff = sub( Q8, exp_diff ); FOR( i = 0; i < bands; i++ ) { test(); Loading @@ -1096,20 +1095,13 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); } Word16 exp_diff = 0; move16(); Word16 tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], sum_over_spar_bands_fx, &exp_diff ); pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shr( Mult_32_16( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], tmp ), exp_diff ); move32(); } pFb->fb_bin_to_band.p_spar_start_bands[j] = spar_start; move16(); } Word16 exp; frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); frame_len = shr( frame_len, sub( 15, exp ) ); set32_fx( ppFilterbank_FRs_s_fx, 0, frame_len ); /*Commented logic is for calculating number of active bands, can be removed if not needed */ Loading @@ -1136,7 +1128,7 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 temp_fx = 0; move32(); Word16 exp_diff = 0; exp_diff = 0; move16(); Word32 real = L_shr( *pFilterbank_bin_to_band_re_fx, 3 ); // Q27 Word32 imag = L_shr( *pFilterbank_bin_to_band_im_fx, 3 ); // Q27 Loading Loading @@ -1195,7 +1187,7 @@ static Word16 ivas_calculate_abs_fr_fx( { Word16 abs_active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; Word16 abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[j]; Word16 exp_diff = 0, tmp; exp_diff = 0; move16(); move16(); Loading lib_com/ivas_spar_com.c +33 −43 Original line number Diff line number Diff line Loading @@ -7044,7 +7044,7 @@ void ivas_dirac_dec_get_response_fx( Word16 Q_out ) { Word16 index_azimuth, index_elevation; Word16 el, e, az; Word16 el, e, az, q_diff; Word32 cos_1_fx, cos_2_fx, sin_1_fx, cos_az_fx[3]; Word32 sin_az_fx[3]; Word32 f_fx; Loading @@ -7055,49 +7055,39 @@ void ivas_dirac_dec_get_response_fx( index_azimuth = add( azimuth, 180 ) % 360; move16(); index_elevation = add( elevation, 90 ); IF( GT_16( index_elevation, 90 ) ) { e = -1; move16(); } ELSE { e = 1; move16(); } IF( GT_16( index_elevation, 90 ) ) if ( GT_16( index_elevation, 90 ) ) { el = sub( 180, index_elevation ); move16(); e = -1; } ELSE { el = index_elevation; move16(); } IF( GT_16( index_azimuth, 180 ) ) if ( GT_16( index_elevation, 90 ) ) { az = sub( 360, index_azimuth ); move16(); el = sub( 180, index_elevation ); } ELSE { az = index_azimuth; move16(); } IF( GT_16( index_azimuth, 180 ) ) if ( GT_16( index_azimuth, 180 ) ) { f_fx = -1; move16(); az = sub( 360, index_azimuth ); } ELSE { f_fx = 1; move16(); if ( GT_16( index_azimuth, 180 ) ) { f_fx = -1; } cos_1_fx = L_shr( dirac_gains_trg_term_fx[az][0], 1 ); // q30 cos_2_fx = L_shl( Mpy_32_32( cos_1_fx, cos_1_fx ), 1 ); // q30 sin_1_fx = L_shr( dirac_gains_trg_term_fx[az][1], 1 ); // q30 Loading @@ -7122,54 +7112,54 @@ void ivas_dirac_dec_get_response_fx( response_fx[0] = L_shl_sat( 1, Q_out ); // Q_out move32(); q_diff = sub( Q_out, 29 ); FOR( l = 1; l <= ambisonics_order; l++ ) { b_2 = imult1616( l, l ); b1_2 = add( imult1616( l, l ), shl( l, 1 ) ); b1_2 = add( b_2, shl( l, 1 ) ); FOR( m = 0; m < l; m += 2 ) { b = add( b_2, m ); b = b_2 + m; a = dirac_gains_P_idx[b]; move16(); c_fx_better = local_result_table[el][a]; // q30 move32(); response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); b1 = sub( b1_2, m ); response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out b1 = b1_2 - m; response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); } FOR( m = 1; m < l; m += 2 ) { b = add( b_2, m ); b = b_2 + m; a = dirac_gains_P_idx[b]; move16(); c_fx_better = local_result_table[el][a]; // q30 move32(); if ( EQ_16( e, -1 ) ) { c_fx_better = L_negate( c_fx_better ); // q30 } response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); b1 = sub( b1_2, m ); response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out b1 = b1_2 - m; response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); } b = add( b_2, l ); a = dirac_gains_P_idx[b]; move16(); c_fx_better = local_result_table_2[el][a]; // q30 move32(); IF( EQ_16( ( l % 2 ), 1 ) ) IF( EQ_16( s_and( l, 0x01 ), 1 ) ) { if ( EQ_16( e, -1 ) ) { c_fx_better = L_negate( c_fx_better ); // q30 move32(); } } response_fx[b] = L_shl( c_fx_better, sub( Q_out, 30 ) ); // Q_out Loading Loading
lib_com/cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ #define FOUR_IN_Q28 1073741824 #define MAX_WORD16 32767 #define ONE_IN_Q45 (Word64)0x200000000000 #define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants Loading
lib_com/ivas_cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ typedef enum RENDERER_OSBA_LS } RENDERER_TYPE; #define MAX_FREQUENCY_BANDS 64 /*----------------------------------------------------------------------------------* * IVAS general constants Loading
lib_com/ivas_dirac_com.c +32 −17 Original line number Diff line number Diff line Loading @@ -966,38 +966,55 @@ void computeDiffuseness_fixed( p_tmp_c = buffer_energy + i * num_freq_bands; q_tmp = add( q_factor_energy[i], min_q_shift1 ); Word16 shift_q = sub( q_tmp, q_ene ); IF( shift_q < 0 ) { FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp_c[k], min_q_shift1 ); IF( LT_16( q_tmp, q_ene ) ) { energy_slow[k] = L_add( L_shr( energy_slow[k], sub( q_ene, q_tmp ) ), tmp ); energy_slow[k] = L_add( L_shl( energy_slow[k], shift_q ), tmp ); move32(); } } ELSE { energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, sub( q_tmp, q_ene ) ) ); FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp_c[k], min_q_shift1 ); energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, shift_q ) ); move32(); } } q_ene = s_min( q_ene, q_tmp ); /* Intensity slow */ q_tmp = add( q_factor_intensity[i], min_q_shift2 ); shift_q = sub( q_tmp, q_intensity ); IF( shift_q > 0 ) { FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp[k], min_q_shift2 ); IF( LT_16( q_intensity, q_tmp ) ) { intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shr( tmp, sub( q_tmp, q_intensity ) ) ); intensity_slow[j * num_freq_bands + k] = L_add( intensity_slow[j * num_freq_bands + k], L_shr( tmp, shift_q ) ); move32(); } } } ELSE { intensity_slow[j * num_freq_bands + k] = L_add( L_shr( intensity_slow[j * num_freq_bands + k], sub( q_intensity, q_tmp ) ), tmp ); FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { tmp = L_shl( p_tmp[k], min_q_shift2 ); intensity_slow[j * num_freq_bands + k] = L_add( L_shl( intensity_slow[j * num_freq_bands + k], shift_q ), tmp ); move32(); } } Loading @@ -1017,9 +1034,7 @@ void computeDiffuseness_fixed( FOR( k = 0; k < num_freq_bands; k++ ) { p_tmp[k] = Mpy_32_32( p_tmp[k], p_tmp[k] ); move32(); intensity_slow_abs[k] = L_add( intensity_slow_abs[k], p_tmp[k] ); intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); move32(); } } Loading
lib_com/ivas_fb_mixer.c +35 −43 Original line number Diff line number Diff line Loading @@ -915,7 +915,10 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); Word16 idx_short_stride_bin_to_band = 0; move16(); Word16 quo, tmp, exp_diff; Word32 temp = Mpy_32_32( sampling_rate, 42949673 /* FRAMES_PER_SEC in Q31 */ ); frame_len = extract_l( temp ); FOR( i = 0; i < bands; i++ ) { Loading @@ -932,13 +935,11 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 short_stride_pow_spec_fx[MDFT_FB_BANDS_240]; Word32 short_stride_nrg_fx = 0; move16(); Word16 exp_diff = 0, tmp; exp_diff = 0; move16(); Word32 cldfb_nrg_fx = 0; Word16 cldfb_nrg_e = 0; move16(); move16(); Word64 cldfb_nrg_fx = 0; move64(); Word16 short_stride = pFb->fb_bin_to_band.short_stride; move16(); Word32 res_dec1, res_frac, res_dec2; Loading @@ -959,38 +960,24 @@ static Word16 ivas_calculate_abs_fr_fx( { Word32 sq_abs_fx; Word16 sq_abs_e; // Word32 real = L_shr( *long_mdft_ptr_re_fx, 3 ); // Q27 Word32 real = *long_mdft_ptr_re_fx; // Q30 move32(); // Word32 imag = L_shr( *long_mdft_ptr_im_fx, 3 ); // Q27 Word32 imag = *long_mdft_ptr_im_fx; // Q30 Word16 real_exp, imag_exp; move32(); Word32 real_sq, imag_sq; real_sq = Mpy_32_32( real, real ); // Q30 + Q30 - 31 = Q29 real_exp = 2; move32(); imag_sq = Mpy_32_32( imag, imag ); // Q30 + Q30 - 31 = Q29 imag_exp = 2; move32(); sq_abs_fx = BASOP_Util_Add_Mant32Exp( real_sq, real_exp, imag_sq, imag_exp, &sq_abs_e ); // Q(31 - sq_abs_e) Word64 acc = W_mac_32_32( W_mult_32_32( real, real ), imag, imag ); // Q61 sq_abs_fx = W_extract_h( acc ); // Q28 long_mdft_ptr_re_fx++; long_mdft_ptr_im_fx++; /* accumulate bin energies within a short stride bin */ short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shl( sq_abs_fx, sub( Q22, sub( Q31, sq_abs_e ) ) ) ); // Q(31 - sq_abs_e) -> Q22 short_stride_nrg_fx = L_add( short_stride_nrg_fx, L_shr( sq_abs_fx, 6 ) ); // Q22 move32(); IF( !( ( j + 1 ) % num_bins_per_short_stride_bin ) ) IF( !( add( j, 1 ) % num_bins_per_short_stride_bin ) ) { /* new short stride bin */ short_stride_pow_spec_fx[j / num_bins_per_short_stride_bin] = short_stride_nrg_fx; /* energy rather than magnitude works better for covariance weighting*/ Loading @@ -1001,33 +988,38 @@ static Word16 ivas_calculate_abs_fr_fx( } /* accumulate bin energies within a CLDFB band */ cldfb_nrg_fx = BASOP_Util_Add_Mant32Exp( cldfb_nrg_fx, cldfb_nrg_e, sq_abs_fx, sq_abs_e, &cldfb_nrg_e ); cldfb_nrg_fx = W_mac_32_32( cldfb_nrg_fx, sq_abs_fx, 1 ); // Q29 IF( !( ( j + 1 ) % num_bins_per_cldfb_band ) ) IF( !( add( j, 1 ) % num_bins_per_cldfb_band ) ) { Word32 temp = Sqrt32( cldfb_nrg_fx, &cldfb_nrg_e ); temp = L_shl( temp, sub( cldfb_nrg_e, Q9 ) ); // Q22 Word16 exp = W_norm( cldfb_nrg_fx ); cldfb_nrg_fx = W_shl( cldfb_nrg_fx, exp ); exp = sub( 34, exp ); // 31 - (Q29 + exp -32) temp = Sqrt32( W_extract_h( cldfb_nrg_fx ), &exp ); temp = L_shl( temp, sub( exp, Q9 ) ); // Q22 pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j / num_bins_per_cldfb_band][i] = temp; // Q22 move32(); cldfb_nrg_fx = 0; move32(); cldfb_nrg_e = 0; move16(); } } quo = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, short_stride_max_per_spar_band_fx, &exp_diff ); /* Q of quo = Q30 - Q22 + (15 - exp_diff) --> Q23 - exp_diff. With Mult_32_16, Q23 - exp_diff - 15 --> Q8 - exp_diff */ exp_diff = sub( Q8, exp_diff ); /*loop over the short MDFT bins*/ FOR( j = 0; j < short_stride; j++ ) { tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], short_stride_max_per_spar_band_fx, &exp_diff ); short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 short_stride_pow_spec_fx[j] = L_shr( Mult_32_16( short_stride_pow_spec_fx[j], quo ), exp_diff ); // Q22 move32(); short_stride_pow_spec_fx[j] = L_max( L_sub( short_stride_pow_spec_fx[j], 1258291 ), 0 ); // 0.3f * ONE_IN_Q22 move32(); tmp = BASOP_Util_Divide3232_Scale( short_stride_pow_spec_fx[j], 2936012, &exp_diff ); // 0.7f * ONE_IN_Q22 short_stride_pow_spec_fx[j] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 short_stride_pow_spec_fx[j] = L_shl( Mpy_32_32( short_stride_pow_spec_fx[j], 1533916891 /* 1/0.7 in Q30 */ ), 1 ); // Q22 move32(); IF( short_stride_pow_spec_fx[j] > 0 ) { assert( idx_short_stride_bin_to_band < 2 * MDFT_FB_BANDS_240 ); /* array size of p_short_stride_bin_to_band */ Loading Loading @@ -1083,6 +1075,13 @@ static Word16 ivas_calculate_abs_fr_fx( sum_over_spar_bands_fx = L_max( sum_over_spar_bands_fx, EPSILON_FX ); // Q22 move32(); exp_diff = 0; move16(); tmp = BASOP_Util_Divide3232_Scale( ONE_IN_Q30, sum_over_spar_bands_fx, &exp_diff ); /* Q of quo = Q30 - Q22 + (15 - exp_diff) --> Q23 - exp_diff. With Mult_32_16, Q23 - exp_diff - 15 --> Q8 - exp_diff */ exp_diff = sub( Q8, exp_diff ); FOR( i = 0; i < bands; i++ ) { test(); Loading @@ -1096,20 +1095,13 @@ static Word16 ivas_calculate_abs_fr_fx( move16(); } Word16 exp_diff = 0; move16(); Word16 tmp = BASOP_Util_Divide3232_Scale( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], sum_over_spar_bands_fx, &exp_diff ); pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shl( L_deposit_l( tmp ), add( Q7, exp_diff ) ); // Q22 pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i] = L_shr( Mult_32_16( pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[j][i], tmp ), exp_diff ); move32(); } pFb->fb_bin_to_band.p_spar_start_bands[j] = spar_start; move16(); } Word16 exp; frame_len = BASOP_Util_Divide3232_Scale( sampling_rate, FRAMES_PER_SEC, &exp ); frame_len = shr( frame_len, sub( 15, exp ) ); set32_fx( ppFilterbank_FRs_s_fx, 0, frame_len ); /*Commented logic is for calculating number of active bands, can be removed if not needed */ Loading @@ -1136,7 +1128,7 @@ static Word16 ivas_calculate_abs_fr_fx( Word32 temp_fx = 0; move32(); Word16 exp_diff = 0; exp_diff = 0; move16(); Word32 real = L_shr( *pFilterbank_bin_to_band_re_fx, 3 ); // Q27 Word32 imag = L_shr( *pFilterbank_bin_to_band_im_fx, 3 ); // Q27 Loading Loading @@ -1195,7 +1187,7 @@ static Word16 ivas_calculate_abs_fr_fx( { Word16 abs_active_bins = pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; Word16 abs_start_offset = pFb->fb_bin_to_band.pFb_start_bin_per_band[j]; Word16 exp_diff = 0, tmp; exp_diff = 0; move16(); move16(); Loading
lib_com/ivas_spar_com.c +33 −43 Original line number Diff line number Diff line Loading @@ -7044,7 +7044,7 @@ void ivas_dirac_dec_get_response_fx( Word16 Q_out ) { Word16 index_azimuth, index_elevation; Word16 el, e, az; Word16 el, e, az, q_diff; Word32 cos_1_fx, cos_2_fx, sin_1_fx, cos_az_fx[3]; Word32 sin_az_fx[3]; Word32 f_fx; Loading @@ -7055,49 +7055,39 @@ void ivas_dirac_dec_get_response_fx( index_azimuth = add( azimuth, 180 ) % 360; move16(); index_elevation = add( elevation, 90 ); IF( GT_16( index_elevation, 90 ) ) { e = -1; move16(); } ELSE { e = 1; move16(); } IF( GT_16( index_elevation, 90 ) ) if ( GT_16( index_elevation, 90 ) ) { el = sub( 180, index_elevation ); move16(); e = -1; } ELSE { el = index_elevation; move16(); } IF( GT_16( index_azimuth, 180 ) ) if ( GT_16( index_elevation, 90 ) ) { az = sub( 360, index_azimuth ); move16(); el = sub( 180, index_elevation ); } ELSE { az = index_azimuth; move16(); } IF( GT_16( index_azimuth, 180 ) ) if ( GT_16( index_azimuth, 180 ) ) { f_fx = -1; move16(); az = sub( 360, index_azimuth ); } ELSE { f_fx = 1; move16(); if ( GT_16( index_azimuth, 180 ) ) { f_fx = -1; } cos_1_fx = L_shr( dirac_gains_trg_term_fx[az][0], 1 ); // q30 cos_2_fx = L_shl( Mpy_32_32( cos_1_fx, cos_1_fx ), 1 ); // q30 sin_1_fx = L_shr( dirac_gains_trg_term_fx[az][1], 1 ); // q30 Loading @@ -7122,54 +7112,54 @@ void ivas_dirac_dec_get_response_fx( response_fx[0] = L_shl_sat( 1, Q_out ); // Q_out move32(); q_diff = sub( Q_out, 29 ); FOR( l = 1; l <= ambisonics_order; l++ ) { b_2 = imult1616( l, l ); b1_2 = add( imult1616( l, l ), shl( l, 1 ) ); b1_2 = add( b_2, shl( l, 1 ) ); FOR( m = 0; m < l; m += 2 ) { b = add( b_2, m ); b = b_2 + m; a = dirac_gains_P_idx[b]; move16(); c_fx_better = local_result_table[el][a]; // q30 move32(); response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); b1 = sub( b1_2, m ); response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out b1 = b1_2 - m; response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); } FOR( m = 1; m < l; m += 2 ) { b = add( b_2, m ); b = b_2 + m; a = dirac_gains_P_idx[b]; move16(); c_fx_better = local_result_table[el][a]; // q30 move32(); if ( EQ_16( e, -1 ) ) { c_fx_better = L_negate( c_fx_better ); // q30 } response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out response_fx[b] = L_shl( Mpy_32_32( c_fx_better, sin_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); b1 = sub( b1_2, m ); response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), sub( Q_out, 29 ) ); // Q_out b1 = b1_2 - m; response_fx[b1] = L_shl( Mpy_32_32( c_fx_better, cos_az_fx[l - m - 1] ), q_diff ); // Q_out move32(); } b = add( b_2, l ); a = dirac_gains_P_idx[b]; move16(); c_fx_better = local_result_table_2[el][a]; // q30 move32(); IF( EQ_16( ( l % 2 ), 1 ) ) IF( EQ_16( s_and( l, 0x01 ), 1 ) ) { if ( EQ_16( e, -1 ) ) { c_fx_better = L_negate( c_fx_better ); // q30 move32(); } } response_fx[b] = L_shl( c_fx_better, sub( Q_out, 30 ) ); // Q_out Loading