Loading lib_com/swb_tbe_com_fx.c +281 −290 Original line number Diff line number Diff line Loading @@ -435,7 +435,6 @@ void flip_and_downmix_generic_fx32( /* Hilber transform stage - 0 - single precision */ Hilbert_transform_fx( tmp, tmp, tmpi_R, tmpi_I, length, 0 ); Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 ); Copy32( mem3_ext, tmpi2_I, HILBERT_ORDER2 ); Loading Loading @@ -609,6 +608,7 @@ static void Hilbert_transform_sp_fx( /*---------------------------------------------- * flip_spectrum_fx *----------------------------------------------*/ void flip_spectrum_fx( const Word16 input[], /* i : input spectrum */ Word16 output[], /* o : output spectrum */ Loading Loading @@ -731,6 +731,7 @@ void Calc_rc0_h( return; } #ifndef HARMONIZE_TBE3 static void Calc_rc0_h_ivas_enc_fx( Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ Loading Loading @@ -789,6 +790,7 @@ static void Calc_rc0_h_ivas_enc_fx( move16(); } } #endif static void Calc_st_filt_tbe_fx( #ifdef HARMONIZE_TBE3 Loading Loading @@ -938,9 +940,7 @@ static void filt_mu_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*(14 - exp) */ ga = shl_sat( tmp, exp ); /*Q14 */ /* ga = (float) 1. / ((float) 1. - (float) fabs (mu)); */ ptrs = sig_in; /* points on sig_in(-1) */ FOR( n = 0; n < SubFrameLength; n++ ) Loading Loading @@ -1108,11 +1108,11 @@ void PostShortTerm_fx( /* Control short term pst filter gain and compute parcor0 */ #ifdef HARMONIZE_TBE3 Calc_st_filt_tbe_fx( element_mode, enc_dec, apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); Calc_st_filt_tbe_fx( element_mode, enc_dec, apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* parcor0 in Q15, sig_ltp_fx in Q_bwe_exc */ #else Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* i: parcor0 in Q15, o: sig_ltp_fx in Q_bwe_exc */ #endif /* parcor0 in Q15, sig_ltp_fx in Q_bwe_exc */ /* 1/A(gamma1) filtering, mem_stp is updated */ #ifdef HARMONIZE_TBE3 Loading @@ -1127,8 +1127,7 @@ void PostShortTerm_fx( } /* (1 + mu z-1) tilt filtering */ filt_mu_fx( sig_ltp_fx, sig_out, parcor0_fx, L_SUBFR16k ); /* o: sig_out in Q_bwe_exc */ filt_mu_fx( sig_ltp_fx, sig_out, parcor0_fx, L_SUBFR16k ); /* sig_out in Q_bwe_exc */ /* gain control */ scale_st_swb( sig_in, sig_out, ptr_gain_prec, L_SUBFR16k ); Loading Loading @@ -2265,7 +2264,7 @@ void GenShapedSHBExcitation_fx( *mem_csfilt = Mult_32_16( L_tmp, varEnvShape ); move32(); } { /* Track the low band envelope */ L_tmp = *mem_csfilt; move32(); Loading @@ -2279,8 +2278,7 @@ void GenShapedSHBExcitation_fx( } *mem_csfilt = L_tmp; move32(); } { /* create a random excitation - Reuse exc16k memory */ White_exc16k = exc16k; create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode ); Loading Loading @@ -2326,12 +2324,10 @@ void GenShapedSHBExcitation_fx( } /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/ Q_pow22 = shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ); } IF( GE_32( bitrate, ACELP_24k40 ) ) { IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */ { { Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k, ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); Loading @@ -2345,10 +2341,9 @@ void GenShapedSHBExcitation_fx( move16(); } } } ELSE /* decoder side */ { { /* *vf_ind is an integer scale by 0.125f*/ /* *vf_ind is an integer scale by 0.125f*/ tmp = shl( *vf_ind, ( 15 - 3 ) ); tmp2 = MAX_16; move16(); Loading @@ -2358,7 +2353,6 @@ void GenShapedSHBExcitation_fx( move16(); } } } { voice_factors[0] = mult_r( voice_factors[0], tmp2 ); move16(); Loading Loading @@ -6303,7 +6297,6 @@ void create_random_vector_fx( /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ Loading @@ -6318,14 +6311,14 @@ void interp_code_5over2_fx( { Word16 i, kk, kkp1, i_len2; Word32 Ltemp; Word16 factor_i_fx[5] = { 6554, 19661, 32767, 19661, 6554 }; const Word16 factor_i_fx[5] = { 6554, 19661, 32767, 19661, 6554 }; move16(); move16(); move16(); move16(); move16(); move16(); Word16 factor_j_fx[5] = { 26214, 13107, 0, 13107, 26214 }; const Word16 factor_j_fx[5] = { 26214, 13107, 0, 13107, 26214 }; move16(); move16(); move16(); Loading Loading @@ -6408,7 +6401,6 @@ void interp_code_5over2_fx( /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ Loading Loading @@ -6958,7 +6950,6 @@ static void Estimate_mix_factors_fx( /* temp_p1_p3 = (float)sqrt(pow1/pow3); */ temp_p1_p3 = root_a_over_b_fx( pow1, Q_pow1, pow3, ( 2 * Q_shb + 1 ), &exp2 ); /* temp_p1_p3 in (Q31+exp2) */ sc1 = sub( Q_bwe_exc, sub( Q_frac, exp1 ) ); sc2 = sub( Q_bwe_exc, sub( Q_shb, exp2 ) ); FOR( i = 0; i < L_FRAME16k; i++ ) Loading lib_dec/swb_tbe_dec_fx.c +8 −4 Original line number Diff line number Diff line Loading @@ -4637,9 +4637,10 @@ void swb_tbe_dec_ivas_fx( hBWE_TD = st->hBWE_TD; #ifndef HARMONIZE_TBE3 Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif /* initializations */ GainFrame_fx = 0; move32(); Loading Loading @@ -4681,6 +4682,10 @@ void swb_tbe_dec_ivas_fx( ELSE #endif { #ifdef HARMONIZE_TBE3 Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); tilt_swb_fec_fx = round_fx_sat( L_shl_sat( tilt_swb_fec_32_fx, sub( 11 + 16, tilt_swb_fec_fx_q ) ) ); } Loading Loading @@ -5368,7 +5373,6 @@ void swb_tbe_dec_ivas_fx( move16(); Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ /* -------- end of rescaling memories -------- */ Q_bwe_exc_fb = hBWE_TD->prev_Q_bwe_exc_fb; Loading Loading @@ -6408,7 +6412,7 @@ void swb_tbe_dec_ivas_fx( /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ GenSHBSynth_fx32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); } Loading lib_enc/swb_tbe_enc_fx.c +46 −66 Original line number Diff line number Diff line Loading @@ -299,7 +299,6 @@ static void find_max_mem_wb_enc( Lmax = L_abs( hBWE_TD->mem_csfilt_fx[i] ); } IF( Lmax == 0 ) { n_mem_32 = 31; Loading Loading @@ -2659,9 +2658,9 @@ void swb_tbe_enc_ivas_fx( L_tmp = L_mac( L_tmp, tmp, tmp ); } sd_uq_q_fx = round_fx( L_tmp ); /* sd_uq_q_fx in Q15 */ /* voice factor modification to limit any spurious jumps in the middle of voiced subframes*/ /* mean(voice_factors_fx[i], 4); */ L_tmp = L_mult( voice_factors_fx[0], 8192 ); L_tmp = L_mac( L_tmp, voice_factors_fx[1], 8192 ); L_tmp = L_mac( L_tmp, voice_factors_fx[2], 8192 ); Loading Loading @@ -2811,12 +2810,9 @@ void swb_tbe_enc_ivas_fx( } /* -------- Calculate the SHB Energy -------- */ /*shb_ener_sf[0] = 0.003125f * sum2_f( shb_frame + L_SHB_LAHEAD, 320 );*/ FOR( i = L_SHB_LAHEAD; i < L_FRAME16k + L_SHB_LAHEAD; i++ ) { /* shbEner = shbEner + in[i] * in[i] */ shb_ener_sf_Q31 = L_mac0_sat( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); /* o: shb_ener_sf_Q31 in (2*Q_shb) */ shb_ener_sf_Q31 = L_mac0_sat( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); /* shb_ener_sf_Q31 in (2*Q_shb) */ } shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ ); shb_ener_sf_Q31 = L_add( 1l /*1 Q0*/, shb_ener_sf_Q31 ); Loading Loading @@ -2935,10 +2931,8 @@ void swb_tbe_enc_ivas_fx( move16(); FOR( k = 0; k < 4; k++ ) { // seg_mean[k] = max(1.0f, mean(&EnvSHBres_4k[k * seg_len], seg_len)); seg_mean[k] = s_max( 1, mean_no_sat_fx( &EnvSHBres_4k_fx[k * seg_len], seg_len ) ); /* Q_shb */ move16(); // den_seg_mean[k] = 1.0f / seg_mean[k]; tmp = BASOP_Util_Divide1616_Scale( MAX16B, seg_mean[k], &tmp_e ); tmp_e = sub( tmp_e, sub( 15, Q_shb ) ); den_seg_mean[k] = shl_sat( tmp, tmp_e ); /* Q15 */ Loading @@ -2954,7 +2948,6 @@ void swb_tbe_enc_ivas_fx( { env_mean_normf_fx[0] = hBWE_TD->old_mean_EnvSHBres_fx; /* Q15 */ move16(); // step = (den_seg_mean[0] - hBWE_TD->old_mean_EnvSHBres) * den_seg_len_2; step = mult( sub( den_seg_mean[0], hBWE_TD->old_mean_EnvSHBres_fx ), den_seg_len_2 ); /* Q15 */ FOR( i = 1; i < seg_len_2; i++ ) { Loading @@ -2967,7 +2960,6 @@ void swb_tbe_enc_ivas_fx( p_env = &env_mean_normf_fx[seg_len_2]; FOR( k = 1; k < 4; k++ ) { // step = ( den_seg_mean[k] - den_seg_mean[k - 1] ) * den_seg_len; step = mult( sub( den_seg_mean[k], den_seg_mean[k - 1] ), den_seg_len ); FOR( i = 0; i < seg_len; i++ ) { Loading Loading @@ -3015,10 +3007,8 @@ void swb_tbe_enc_ivas_fx( Copy( &buf_EnvSHBres_fx[L_FRAME4k], hBWE_TD->old_EnvSHBres_fx, L_FRAME4k ); // Q_shb /* calculate energy normalization factor for the auto-correlation function */ // pow0 = sum2_f( &buf_EnvSHBres[L_FRAME4k], L_FRAME4k ) + 1.0f; pow_e = sub( 15, Q_shb ); pow0_fx = sum2_16_exp_fx( &buf_EnvSHBres_fx[L_FRAME4k], L_FRAME4k, &pow_e, 0 /* Give guard bits */ ) + 1; // if (hBWE_TD->prev_enr_EnvSHBres == 1.0f) IF( BASOP_Util_Cmp_Mant32Exp( hBWE_TD->prev_enr_EnvSHBres_fx, hBWE_TD->prev_enr_EnvSHBres_e, 1, 31 ) == 0 ) { // scale = 1.0f / pow0; Loading @@ -3027,7 +3017,6 @@ void swb_tbe_enc_ivas_fx( } ELSE { // scale = 1.0f / max( pow0, hBWE_TD->prev_enr_EnvSHBres ); L_tmp1 = pow0_fx; move32(); IF( BASOP_Util_Cmp_Mant32Exp( L_tmp1, pow_e, hBWE_TD->prev_enr_EnvSHBres_fx, hBWE_TD->prev_enr_EnvSHBres_e ) < 0 ) Loading Loading @@ -3064,7 +3053,6 @@ void swb_tbe_enc_ivas_fx( tmp_e = W_norm( W_tmp ); L_tmp1 = W_extract_h( W_shl( W_tmp, tmp_e ) ); // 2 * Q_shb + tmp_e - 31 L_tmp = Mpy_32_16_1( L_tmp1, scale_fx ); /* 2 * Q_shb + tmp_e - 31 - scale_e */ //*p_acorr++ = extract_h( L_shl( L_tmp, add( 16, Q_shb ) - ( 2 * Q_shb + tmp_e - 31 - scale_e ) ) ); *p_acorr++ = extract_h( L_shl( L_tmp, sub( add( 16, Q_shb ), sub( sub( add( shl( Q_shb, 1 ), tmp_e ), 31 ), scale_e ) ) ) ); move16(); } Loading @@ -3076,11 +3064,9 @@ void swb_tbe_enc_ivas_fx( /* multiply with the maximum of the SHB autocorrelation function */ maximum_fx( acorr_EnvSHBres, ENVSHBRES_ACORR_MAX - ENVSHBRES_ACORR_MIN, &temp ); // acorr_v2a *= temp; L_tmp = Mpy_32_16_1( L_tmp, temp ); /* 31 - tmp_e + Q_shb - 15 */ // alpha = 25.0f; alpha_fx = -1677721600; // Q26 alpha_fx = -1677721600; // -25.0 in Q26 move32(); // acorr_v2a = 2.0f / ( 1.0f + (float) expf( -alpha * acorr_v2a ) ) - 1.0f; Loading @@ -3104,7 +3090,6 @@ void swb_tbe_enc_ivas_fx( res_e = BASOP_Util_Add_MantExp( acorr_v2a_fx, res_e, -1, 15, &acorr_v2a_fx ); /* limit in the range 0.0 - 1.0 */ // acorr_v2a = min( 1.0f, max( 0.0f, acorr_v2a ) ); acorr_v2a_fx = shl_sat( acorr_v2a_fx, res_e ); if ( acorr_v2a_fx < 0 ) Loading Loading @@ -4111,14 +4096,9 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_FRAME16k; i++ ) { L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[NUM_SHB_SUBFR * i / L_FRAME16k] ); /* Q : 18 + tmp +15 -15*/ /*White_exc16k_fx[i] = round_fx( L_shl(Mult_32_16( L_tmp1, White_exc16k_fx[i]),(23 - tmp -*Q_white_exc)) );*/ /*18 + tmp +*Q_white_exc -15 + 23 - tmp -*Q_white_exc -16 = 10*/ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ move16(); /*Lmax = L_max(Lmax,White_exc16k_fx[i]);*/ tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); /*White_exc16k_fx[i] =32767;*/ /*White_exc16k_fx[i] = shr(White_exc16k_fx[i],5);*/ } *Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */ move16(); Loading Loading @@ -5407,7 +5387,8 @@ return; static void determine_gain_weights_fx( const Word32 *gain, /* i : Gain parameter Q18 */ Word16 *weights, /* o : gain weights Q12/Q6*/ const Word16 dims /* i : number of gains */ ) const Word16 dims /* i : number of gains */ ) { Word16 j; Word16 exp, exp1, frac, tmp, exp2; Loading Loading @@ -5475,8 +5456,8 @@ static void singlevectortest_gain_fx( const Word16 cb_size, /* i : codebook size */ Word16 *index, /* o : quanitzation index */ Word32 *recon, /* o : Reconstruction Q18 */ const Word32 *codebook /* i : Codebook Q18*/ ) const Word32 *codebook /* i : Codebook Q18*/ ) { Word16 k, interNum, flag; Word32 meanU, meanQ; Loading Loading @@ -5690,7 +5671,6 @@ static Word16 Find_LSF_grid_fx( Word16 tmp, exp, tmp1; Word32 L_tmp; tmp = shl( m, 1 ); lsf_map[0] = sub( tmp, lsf_q[NUM_MAP_LSF - 1 - 0] ); move16(); Loading @@ -5703,7 +5683,6 @@ static Word16 Find_LSF_grid_fx( lsf_map[4] = sub( tmp, lsf_q[NUM_MAP_LSF - 1 - 4] ); move16(); IF( GT_16( m, MAX_LSF_FX_2 ) ) { offset = lsf_map[0]; Loading Loading @@ -5918,6 +5897,7 @@ static void gainFrSmooth_En_fx( return; } #define MAXINT32 MAX_32 static void first_VQstages_fx( const Word16 *const *cb, Loading Loading @@ -6366,6 +6346,7 @@ static void Quant_BWE_LSF_fx( return; } /*-------------------------------------------------------------------* * fb_tbe_enc() * Loading Loading @@ -6623,7 +6604,6 @@ void tbe_write_bitstream_fx( TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; test(); test(); test(); Loading Loading
lib_com/swb_tbe_com_fx.c +281 −290 Original line number Diff line number Diff line Loading @@ -435,7 +435,6 @@ void flip_and_downmix_generic_fx32( /* Hilber transform stage - 0 - single precision */ Hilbert_transform_fx( tmp, tmp, tmpi_R, tmpi_I, length, 0 ); Copy32( mem2_ext, tmpi2_R, HILBERT_ORDER2 ); Copy32( mem3_ext, tmpi2_I, HILBERT_ORDER2 ); Loading Loading @@ -609,6 +608,7 @@ static void Hilbert_transform_sp_fx( /*---------------------------------------------- * flip_spectrum_fx *----------------------------------------------*/ void flip_spectrum_fx( const Word16 input[], /* i : input spectrum */ Word16 output[], /* o : output spectrum */ Loading Loading @@ -731,6 +731,7 @@ void Calc_rc0_h( return; } #ifndef HARMONIZE_TBE3 static void Calc_rc0_h_ivas_enc_fx( Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ Loading Loading @@ -789,6 +790,7 @@ static void Calc_rc0_h_ivas_enc_fx( move16(); } } #endif static void Calc_st_filt_tbe_fx( #ifdef HARMONIZE_TBE3 Loading Loading @@ -938,9 +940,7 @@ static void filt_mu_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), tmp ); /*(14 - exp) */ ga = shl_sat( tmp, exp ); /*Q14 */ /* ga = (float) 1. / ((float) 1. - (float) fabs (mu)); */ ptrs = sig_in; /* points on sig_in(-1) */ FOR( n = 0; n < SubFrameLength; n++ ) Loading Loading @@ -1108,11 +1108,11 @@ void PostShortTerm_fx( /* Control short term pst filter gain and compute parcor0 */ #ifdef HARMONIZE_TBE3 Calc_st_filt_tbe_fx( element_mode, enc_dec, apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); Calc_st_filt_tbe_fx( element_mode, enc_dec, apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* parcor0 in Q15, sig_ltp_fx in Q_bwe_exc */ #else Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* i: parcor0 in Q15, o: sig_ltp_fx in Q_bwe_exc */ #endif /* parcor0 in Q15, sig_ltp_fx in Q_bwe_exc */ /* 1/A(gamma1) filtering, mem_stp is updated */ #ifdef HARMONIZE_TBE3 Loading @@ -1127,8 +1127,7 @@ void PostShortTerm_fx( } /* (1 + mu z-1) tilt filtering */ filt_mu_fx( sig_ltp_fx, sig_out, parcor0_fx, L_SUBFR16k ); /* o: sig_out in Q_bwe_exc */ filt_mu_fx( sig_ltp_fx, sig_out, parcor0_fx, L_SUBFR16k ); /* sig_out in Q_bwe_exc */ /* gain control */ scale_st_swb( sig_in, sig_out, ptr_gain_prec, L_SUBFR16k ); Loading Loading @@ -2265,7 +2264,7 @@ void GenShapedSHBExcitation_fx( *mem_csfilt = Mult_32_16( L_tmp, varEnvShape ); move32(); } { /* Track the low band envelope */ L_tmp = *mem_csfilt; move32(); Loading @@ -2279,8 +2278,7 @@ void GenShapedSHBExcitation_fx( } *mem_csfilt = L_tmp; move32(); } { /* create a random excitation - Reuse exc16k memory */ White_exc16k = exc16k; create_random_vector_fx( White_exc16k, L_FRAME, bwe_seed, element_mode ); Loading Loading @@ -2326,12 +2324,10 @@ void GenShapedSHBExcitation_fx( } /*Q_pow22 = sub( shl(*Q_bwe_exc,1), 18 );*/ Q_pow22 = shl( sub( *Q_bwe_exc, NOISE_QADJ ), 1 ); } IF( GE_32( bitrate, ACELP_24k40 ) ) { IF( EQ_16( *vf_ind, 20 ) ) /* encoder side */ { { Estimate_mix_factors_fx( shb_res, Q_shb, exc16kWhtnd, *Q_bwe_exc, White_exc16k, ( *Q_bwe_exc - NOISE_QADJ ), pow1, Q_pow1, pow22, Q_pow22, voiceFacEst, vf_ind ); Loading @@ -2345,10 +2341,9 @@ void GenShapedSHBExcitation_fx( move16(); } } } ELSE /* decoder side */ { { /* *vf_ind is an integer scale by 0.125f*/ /* *vf_ind is an integer scale by 0.125f*/ tmp = shl( *vf_ind, ( 15 - 3 ) ); tmp2 = MAX_16; move16(); Loading @@ -2358,7 +2353,6 @@ void GenShapedSHBExcitation_fx( move16(); } } } { voice_factors[0] = mult_r( voice_factors[0], tmp2 ); move16(); Loading Loading @@ -6303,7 +6297,6 @@ void create_random_vector_fx( /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ Loading @@ -6318,14 +6311,14 @@ void interp_code_5over2_fx( { Word16 i, kk, kkp1, i_len2; Word32 Ltemp; Word16 factor_i_fx[5] = { 6554, 19661, 32767, 19661, 6554 }; const Word16 factor_i_fx[5] = { 6554, 19661, 32767, 19661, 6554 }; move16(); move16(); move16(); move16(); move16(); move16(); Word16 factor_j_fx[5] = { 26214, 13107, 0, 13107, 26214 }; const Word16 factor_j_fx[5] = { 26214, 13107, 0, 13107, 26214 }; move16(); move16(); move16(); Loading Loading @@ -6408,7 +6401,6 @@ void interp_code_5over2_fx( /* INPUT/OUTPUT ARGUMENTS : */ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* _ None */ /*--------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ Loading Loading @@ -6958,7 +6950,6 @@ static void Estimate_mix_factors_fx( /* temp_p1_p3 = (float)sqrt(pow1/pow3); */ temp_p1_p3 = root_a_over_b_fx( pow1, Q_pow1, pow3, ( 2 * Q_shb + 1 ), &exp2 ); /* temp_p1_p3 in (Q31+exp2) */ sc1 = sub( Q_bwe_exc, sub( Q_frac, exp1 ) ); sc2 = sub( Q_bwe_exc, sub( Q_shb, exp2 ) ); FOR( i = 0; i < L_FRAME16k; i++ ) Loading
lib_dec/swb_tbe_dec_fx.c +8 −4 Original line number Diff line number Diff line Loading @@ -4637,9 +4637,10 @@ void swb_tbe_dec_ivas_fx( hBWE_TD = st->hBWE_TD; #ifndef HARMONIZE_TBE3 Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif /* initializations */ GainFrame_fx = 0; move32(); Loading Loading @@ -4681,6 +4682,10 @@ void swb_tbe_dec_ivas_fx( ELSE #endif { #ifdef HARMONIZE_TBE3 Word32 old_syn_12k8_16k_fx[L_FRAME16k]; Copy_Scale_sig_16_32_DEPREC( old_syn_12k8_16k_fx16, old_syn_12k8_16k_fx, st->L_frame, Q11 - ( -Q1 ) ); // Q(11 - (-1)) #endif calc_tilt_bwe_fx_loc( old_syn_12k8_16k_fx, &tilt_swb_fec_32_fx, &tilt_swb_fec_fx_q, L_FRAME ); tilt_swb_fec_fx = round_fx_sat( L_shl_sat( tilt_swb_fec_32_fx, sub( 11 + 16, tilt_swb_fec_fx_q ) ) ); } Loading Loading @@ -5368,7 +5373,6 @@ void swb_tbe_dec_ivas_fx( move16(); Q_bwe_exc = sub( Q_bwe_exc, 16 ); /* Q_bwe_exc reflecting the single precision dynamic norm-ed buffers from here */ /* -------- end of rescaling memories -------- */ Q_bwe_exc_fb = hBWE_TD->prev_Q_bwe_exc_fb; Loading Loading @@ -6408,7 +6412,7 @@ void swb_tbe_dec_ivas_fx( /* generate 32kHz SHB synthesis from 12.8(16)kHz signal */ GenSHBSynth_fx32( shaped_shb_excitation_fx_32, error_fx, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->L_frame, &( hBWE_TD->syn_dm_phase ) ); Copy_Scale_sig_32_16( st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); Copy_Scale_sig_32_16( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 2 * ALLPASSSECTIONS_STEEP, -( Q11 - Q_bwe_exc ) ); Copy32( error_fx + L_FRAME32k - L_SHB_TRANSITION_LENGTH, hBWE_TD->old_tbe_synth_fx_32, L_SHB_TRANSITION_LENGTH ); } Loading
lib_enc/swb_tbe_enc_fx.c +46 −66 Original line number Diff line number Diff line Loading @@ -299,7 +299,6 @@ static void find_max_mem_wb_enc( Lmax = L_abs( hBWE_TD->mem_csfilt_fx[i] ); } IF( Lmax == 0 ) { n_mem_32 = 31; Loading Loading @@ -2659,9 +2658,9 @@ void swb_tbe_enc_ivas_fx( L_tmp = L_mac( L_tmp, tmp, tmp ); } sd_uq_q_fx = round_fx( L_tmp ); /* sd_uq_q_fx in Q15 */ /* voice factor modification to limit any spurious jumps in the middle of voiced subframes*/ /* mean(voice_factors_fx[i], 4); */ L_tmp = L_mult( voice_factors_fx[0], 8192 ); L_tmp = L_mac( L_tmp, voice_factors_fx[1], 8192 ); L_tmp = L_mac( L_tmp, voice_factors_fx[2], 8192 ); Loading Loading @@ -2811,12 +2810,9 @@ void swb_tbe_enc_ivas_fx( } /* -------- Calculate the SHB Energy -------- */ /*shb_ener_sf[0] = 0.003125f * sum2_f( shb_frame + L_SHB_LAHEAD, 320 );*/ FOR( i = L_SHB_LAHEAD; i < L_FRAME16k + L_SHB_LAHEAD; i++ ) { /* shbEner = shbEner + in[i] * in[i] */ shb_ener_sf_Q31 = L_mac0_sat( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); /* o: shb_ener_sf_Q31 in (2*Q_shb) */ shb_ener_sf_Q31 = L_mac0_sat( shb_ener_sf_Q31, shb_frame_fx[i], shb_frame_fx[i] ); /* shb_ener_sf_Q31 in (2*Q_shb) */ } shb_ener_sf_Q31 = Mult_32_16( shb_ener_sf_Q31, 102 /*0.003125f Q15*/ ); shb_ener_sf_Q31 = L_add( 1l /*1 Q0*/, shb_ener_sf_Q31 ); Loading Loading @@ -2935,10 +2931,8 @@ void swb_tbe_enc_ivas_fx( move16(); FOR( k = 0; k < 4; k++ ) { // seg_mean[k] = max(1.0f, mean(&EnvSHBres_4k[k * seg_len], seg_len)); seg_mean[k] = s_max( 1, mean_no_sat_fx( &EnvSHBres_4k_fx[k * seg_len], seg_len ) ); /* Q_shb */ move16(); // den_seg_mean[k] = 1.0f / seg_mean[k]; tmp = BASOP_Util_Divide1616_Scale( MAX16B, seg_mean[k], &tmp_e ); tmp_e = sub( tmp_e, sub( 15, Q_shb ) ); den_seg_mean[k] = shl_sat( tmp, tmp_e ); /* Q15 */ Loading @@ -2954,7 +2948,6 @@ void swb_tbe_enc_ivas_fx( { env_mean_normf_fx[0] = hBWE_TD->old_mean_EnvSHBres_fx; /* Q15 */ move16(); // step = (den_seg_mean[0] - hBWE_TD->old_mean_EnvSHBres) * den_seg_len_2; step = mult( sub( den_seg_mean[0], hBWE_TD->old_mean_EnvSHBres_fx ), den_seg_len_2 ); /* Q15 */ FOR( i = 1; i < seg_len_2; i++ ) { Loading @@ -2967,7 +2960,6 @@ void swb_tbe_enc_ivas_fx( p_env = &env_mean_normf_fx[seg_len_2]; FOR( k = 1; k < 4; k++ ) { // step = ( den_seg_mean[k] - den_seg_mean[k - 1] ) * den_seg_len; step = mult( sub( den_seg_mean[k], den_seg_mean[k - 1] ), den_seg_len ); FOR( i = 0; i < seg_len; i++ ) { Loading Loading @@ -3015,10 +3007,8 @@ void swb_tbe_enc_ivas_fx( Copy( &buf_EnvSHBres_fx[L_FRAME4k], hBWE_TD->old_EnvSHBres_fx, L_FRAME4k ); // Q_shb /* calculate energy normalization factor for the auto-correlation function */ // pow0 = sum2_f( &buf_EnvSHBres[L_FRAME4k], L_FRAME4k ) + 1.0f; pow_e = sub( 15, Q_shb ); pow0_fx = sum2_16_exp_fx( &buf_EnvSHBres_fx[L_FRAME4k], L_FRAME4k, &pow_e, 0 /* Give guard bits */ ) + 1; // if (hBWE_TD->prev_enr_EnvSHBres == 1.0f) IF( BASOP_Util_Cmp_Mant32Exp( hBWE_TD->prev_enr_EnvSHBres_fx, hBWE_TD->prev_enr_EnvSHBres_e, 1, 31 ) == 0 ) { // scale = 1.0f / pow0; Loading @@ -3027,7 +3017,6 @@ void swb_tbe_enc_ivas_fx( } ELSE { // scale = 1.0f / max( pow0, hBWE_TD->prev_enr_EnvSHBres ); L_tmp1 = pow0_fx; move32(); IF( BASOP_Util_Cmp_Mant32Exp( L_tmp1, pow_e, hBWE_TD->prev_enr_EnvSHBres_fx, hBWE_TD->prev_enr_EnvSHBres_e ) < 0 ) Loading Loading @@ -3064,7 +3053,6 @@ void swb_tbe_enc_ivas_fx( tmp_e = W_norm( W_tmp ); L_tmp1 = W_extract_h( W_shl( W_tmp, tmp_e ) ); // 2 * Q_shb + tmp_e - 31 L_tmp = Mpy_32_16_1( L_tmp1, scale_fx ); /* 2 * Q_shb + tmp_e - 31 - scale_e */ //*p_acorr++ = extract_h( L_shl( L_tmp, add( 16, Q_shb ) - ( 2 * Q_shb + tmp_e - 31 - scale_e ) ) ); *p_acorr++ = extract_h( L_shl( L_tmp, sub( add( 16, Q_shb ), sub( sub( add( shl( Q_shb, 1 ), tmp_e ), 31 ), scale_e ) ) ) ); move16(); } Loading @@ -3076,11 +3064,9 @@ void swb_tbe_enc_ivas_fx( /* multiply with the maximum of the SHB autocorrelation function */ maximum_fx( acorr_EnvSHBres, ENVSHBRES_ACORR_MAX - ENVSHBRES_ACORR_MIN, &temp ); // acorr_v2a *= temp; L_tmp = Mpy_32_16_1( L_tmp, temp ); /* 31 - tmp_e + Q_shb - 15 */ // alpha = 25.0f; alpha_fx = -1677721600; // Q26 alpha_fx = -1677721600; // -25.0 in Q26 move32(); // acorr_v2a = 2.0f / ( 1.0f + (float) expf( -alpha * acorr_v2a ) ) - 1.0f; Loading @@ -3104,7 +3090,6 @@ void swb_tbe_enc_ivas_fx( res_e = BASOP_Util_Add_MantExp( acorr_v2a_fx, res_e, -1, 15, &acorr_v2a_fx ); /* limit in the range 0.0 - 1.0 */ // acorr_v2a = min( 1.0f, max( 0.0f, acorr_v2a ) ); acorr_v2a_fx = shl_sat( acorr_v2a_fx, res_e ); if ( acorr_v2a_fx < 0 ) Loading Loading @@ -4111,14 +4096,9 @@ void swb_tbe_enc_ivas_fx( FOR( i = 0; i < L_FRAME16k; i++ ) { L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[NUM_SHB_SUBFR * i / L_FRAME16k] ); /* Q : 18 + tmp +15 -15*/ /*White_exc16k_fx[i] = round_fx( L_shl(Mult_32_16( L_tmp1, White_exc16k_fx[i]),(23 - tmp -*Q_white_exc)) );*/ /*18 + tmp +*Q_white_exc -15 + 23 - tmp -*Q_white_exc -16 = 10*/ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ move16(); /*Lmax = L_max(Lmax,White_exc16k_fx[i]);*/ tmp1 = s_max( tmp1, abs_s( White_exc16k_fx[i] ) ); /*White_exc16k_fx[i] =32767;*/ /*White_exc16k_fx[i] = shr(White_exc16k_fx[i],5);*/ } *Q_white_exc = sub( add( *Q_white_exc, tmp ), 13 ); /* *Q_white_exc + 18 + tmp -15 -16 */ move16(); Loading Loading @@ -5407,7 +5387,8 @@ return; static void determine_gain_weights_fx( const Word32 *gain, /* i : Gain parameter Q18 */ Word16 *weights, /* o : gain weights Q12/Q6*/ const Word16 dims /* i : number of gains */ ) const Word16 dims /* i : number of gains */ ) { Word16 j; Word16 exp, exp1, frac, tmp, exp2; Loading Loading @@ -5475,8 +5456,8 @@ static void singlevectortest_gain_fx( const Word16 cb_size, /* i : codebook size */ Word16 *index, /* o : quanitzation index */ Word32 *recon, /* o : Reconstruction Q18 */ const Word32 *codebook /* i : Codebook Q18*/ ) const Word32 *codebook /* i : Codebook Q18*/ ) { Word16 k, interNum, flag; Word32 meanU, meanQ; Loading Loading @@ -5690,7 +5671,6 @@ static Word16 Find_LSF_grid_fx( Word16 tmp, exp, tmp1; Word32 L_tmp; tmp = shl( m, 1 ); lsf_map[0] = sub( tmp, lsf_q[NUM_MAP_LSF - 1 - 0] ); move16(); Loading @@ -5703,7 +5683,6 @@ static Word16 Find_LSF_grid_fx( lsf_map[4] = sub( tmp, lsf_q[NUM_MAP_LSF - 1 - 4] ); move16(); IF( GT_16( m, MAX_LSF_FX_2 ) ) { offset = lsf_map[0]; Loading Loading @@ -5918,6 +5897,7 @@ static void gainFrSmooth_En_fx( return; } #define MAXINT32 MAX_32 static void first_VQstages_fx( const Word16 *const *cb, Loading Loading @@ -6366,6 +6346,7 @@ static void Quant_BWE_LSF_fx( return; } /*-------------------------------------------------------------------* * fb_tbe_enc() * Loading Loading @@ -6623,7 +6604,6 @@ void tbe_write_bitstream_fx( TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; test(); test(); test(); Loading