Loading lib_com/prot_fx.h +23 −13 Original line number Diff line number Diff line Loading @@ -2669,11 +2669,19 @@ void flip_and_downmix_generic_fx( ); void Calc_rc0_h( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ ); void PostShortTerm_fx( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *sig_in, /* i : i signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Word16 *sig_out, /* o : postfiltered output */ Loading @@ -2684,6 +2692,7 @@ void PostShortTerm_fx( const Word16 formant_fac_fx /* i : Strength of post-filter*/ ); #ifndef HARMONIZE_TBE3 void PostShortTerm_ivas_enc_fx( Word16 *sig_in, /* i : i signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Loading @@ -2705,7 +2714,7 @@ void PostShortTerm_ivas_dec_fx( Word16 *mem_zero, /* i/o: null memory to compute h_st*/ const Word16 formant_fac_fx /* i : Strength of post-filter*/ ); #endif void flip_spectrum_and_decimby4_fx( const Word16 i[], /* i : i spectrum */ Word16 output[], /* o : output spectrum */ Loading Loading @@ -5547,14 +5556,15 @@ void swb_tbe_dec_fx( void fb_tbe_dec_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ Word16 Q_fb_exc, const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ const Word16 Q_fb_exc, /* i : Q-factor of fb_exc[] */ Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word32 *hb_synth, /* o : high-band synthesis */ Word16 hb_synth_exp, Word16 *fb_synth_ref, Word16 Q_fb_synth_ref, Word16 output_frame ); Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */ const Word16 hb_synth_exp, /* i : Q-factor of hb_synth[] */ Word16 *fb_synth_ref, /* o : Q_fb_synth_ref */ Word16 Q_fb_synth_ref, /* i : Q-factor of fb_synth_ref[] */ const Word16 output_frame /* i : output frame length */ ); void tbe_read_bitstream_fx( Decoder_State *st_fx /* i/o: encoder state structure */ Loading @@ -5564,8 +5574,8 @@ void GenTransition_fx( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ const Word32 output_Fs, /* i : output sampling rate */ Word16 rf_flag, /* i : RF flag */ Word32 total_bitrate /* i : total bitrate */ const Word16 rf_flag, /* i : RF flag */ const Word32 total_bitrate /* i : total bitrate */ ); void GenTransition_fx32( Loading lib_com/swb_tbe_com_fx.c +111 −26 Original line number Diff line number Diff line Loading @@ -26,7 +26,11 @@ static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode ); static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length ); #ifdef HARMONIZE_TBE3 static void Calc_st_filt_tbe_fx( const Word16 element_mode, const Word16 enc_dec, Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); #else static void Calc_st_filt_tbe_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); #endif static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); static void Hilbert_transform_sp_fx( Word16 tmp_R[], Word16 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); static void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind ); Loading Loading @@ -630,7 +634,12 @@ void flip_spectrum_fx( * * computes 1st parcor from composed filter impulse response *---------------------------------------------------------------------------*/ void Calc_rc0_h( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ ) Loading @@ -638,10 +647,41 @@ void Calc_rc0_h( Word32 L_acc; Word16 *ptrs; Word16 acf0, acf1; #ifdef HARMONIZE_TBE3 Word16 tmp2; #endif Word16 temp, sh_acf; Word16 i; /* computation of the autocorrelation function acf */ #ifdef HARMONIZE_TBE3 IF( element_mode != EVS_MONO && enc_dec == ENC ) { L_acc = L_mult( h[0], h[0] ); // TBV: shouldn't it be "shr( h[0], 2 )" ? FOR( i = 1; i < LONG_H_ST; i++ ) { tmp2 = shr( h[i], 2 ); L_acc = L_mac( L_acc, tmp2, tmp2 ); } sh_acf = norm_l( L_acc ); L_acc = L_shl( L_acc, sh_acf ); acf0 = extract_h( L_acc ); ptrs = h; temp = *ptrs++; move16(); L_acc = L_mult( temp, *ptrs ); FOR( i = 1; i < LONG_H_ST - 1; i++ ) { temp = shr( *ptrs++, 2 ); move16(); L_acc = L_mac( L_acc, temp, shr( *ptrs, 2 ) ); } } ELSE #endif { L_acc = L_mult( h[0], h[0] ); FOR( i = 1; i < LONG_H_ST; i++ ) { Loading @@ -662,6 +702,7 @@ void Calc_rc0_h( move16(); L_acc = L_mac( L_acc, temp, *ptrs ); } } L_acc = L_shl( L_acc, sh_acf ); acf1 = extract_h( L_acc ); Loading Loading @@ -750,6 +791,10 @@ static void Calc_rc0_h_ivas_enc_fx( } static void Calc_st_filt_tbe_fx( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ Word16 *parcor0, /* o : 1st parcor calcul. on composed filter */ Loading @@ -764,10 +809,27 @@ static void Calc_st_filt_tbe_fx( Word16 g0, temp; Word16 i; temp = sub( 2, norm_s( apond2[0] ) ); #ifdef HARMONIZE_TBE3 IF( element_mode != EVS_MONO && enc_dec == ENC ) { /* compute i.r. of composed filter apond2 / apond1 */ syn_filt_fx( temp, apond1, LPC_SHB_ORDER, apond2, h, LONG_H_ST, mem_zero, 0 ); } ELSE #endif { /* compute i.r. of composed filter apond2 / apond1 */ Syn_filt_s( temp, apond1, LPC_SHB_ORDER, apond2, h, LONG_H_ST, mem_zero, 0 ); } /* compute 1st parcor */ #ifdef HARMONIZE_TBE3 Calc_rc0_h( element_mode, enc_dec, h, parcor0 ); #else Calc_rc0_h( h, parcor0 ); #endif /* compute g0 */ L_g0 = L_mult0( 1, abs_s( h[0] ) ); Loading @@ -791,6 +853,7 @@ static void Calc_st_filt_tbe_fx( return; } #ifndef HARMONIZE_TBE3 static void Calc_st_filt_tbe_ivas_enc_fx( Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ Loading Loading @@ -832,6 +895,7 @@ static void Calc_st_filt_tbe_ivas_enc_fx( return; } #endif static void filt_mu_fx( const Word16 *sig_in, /* i : signal (beginning at sample -1) */ Loading Loading @@ -992,7 +1056,18 @@ static void scale_st_swb( return; } /*-------------------------------------------------------------------* * PostShortTerm() * * Short term processing *-------------------------------------------------------------------*/ void PostShortTerm_fx( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *sig_in, /* i : input signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Word16 *sig_out, /* o : postfiltered output */ Loading @@ -1006,7 +1081,6 @@ void PostShortTerm_fx( Word16 apond1_fx[LPC_SHB_ORDER + 1]; /* denominator coeff.*/ Word16 apond2_fx[LONG_H_ST]; /* numerator coeff. */ Word16 sig_ltp_fx[L_SUBFR16k + 1]; /* residual signal */ /*Word16 lpccoeff_fx[LPC_SHB_ORDER+1];//Q12 */ Word16 g1_fx, g2_fx, parcor0_fx; /*Q15 */ Word16 tmp; Loading @@ -1023,24 +1097,34 @@ void PostShortTerm_fx( /* Compute weighted LPC coefficients */ weight_a_fx( lpccoeff, apond1_fx, g1_fx, LPC_SHB_ORDER ); weight_a_fx( lpccoeff, apond2_fx, g2_fx, LPC_SHB_ORDER ); /* o: apond1_fx, apond2_fx in Q12 */ weight_a_fx( lpccoeff, apond2_fx, g2_fx, LPC_SHB_ORDER ); /* apond1_fx, apond2_fx in Q12 */ /* Compute A(gamma2) residual */ Residu3_10_fx( apond2_fx, sig_in, sig_ltp_fx + 1, L_SUBFR16k, 0 ); /* o: sig_ltp_fx in Q_bwe_exc */ Residu3_10_fx( apond2_fx, sig_in, sig_ltp_fx + 1, L_SUBFR16k, 0 ); /* sig_ltp_fx in Q_bwe_exc */ /* Save last output of 1/A(gamma1) */ sig_ltp_fx[0] = *ptr_mem_stp; move16(); /* 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 ); #else Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* o: parcor0 in Q15 */ /* i/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 IF( element_mode != EVS_MONO && enc_dec == ENC ) { syn_filt_fx( 0, apond1_fx, LPC_SHB_ORDER, sig_ltp_fx + 1, sig_ltp_fx + 1, L_SUBFR16k, mem_stp, 1 ); } ELSE #endif { Syn_filt_s( 0, apond1_fx, LPC_SHB_ORDER, sig_ltp_fx + 1, sig_ltp_fx + 1, L_SUBFR16k, mem_stp, 1 ); } /* (1 + mu z-1) tilt filtering */ filt_mu_fx( sig_ltp_fx, sig_out, parcor0_fx, L_SUBFR16k ); Loading @@ -1052,6 +1136,7 @@ void PostShortTerm_fx( return; } #ifndef HARMONIZE_TBE3 void PostShortTerm_ivas_enc_fx( Word16 *sig_in, /* i : input signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Loading Loading @@ -1171,7 +1256,7 @@ void PostShortTerm_ivas_dec_fx( return; } #endif /*-------------------------------------------------------------------* * flip_spectrum_and_decimby4() Loading lib_dec/dec_post_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -1309,7 +1309,11 @@ static void calc_st_filt_local_fx( E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, M ); /* compute 1st parcor */ #ifdef HARMONIZE_TBE3 Calc_rc0_h( EVS_MONO, DEC, h, parcor0 ); #else Calc_rc0_h( h, parcor0 ); #endif /* compute g0 */ L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12 Loading lib_dec/swb_tbe_dec_fx.c +34 −39 Original line number Diff line number Diff line Loading @@ -3386,7 +3386,6 @@ static void dequantizeSHBparams_fx( hBWE_TD = st_fx->hBWE_TD; /* LSFs */ IF( EQ_16( extl, WB_TBE ) ) { IF( EQ_32( extl_brate, WB_TBE_0k35 ) ) Loading Loading @@ -3491,7 +3490,7 @@ static void dequantizeSHBparams_fx( idx_shb_fr_gain = (Word16) get_next_indice_fx( st_fx, NUM_BITS_SHB_ENER_SF ); } temp_shb_ener_sf_fx = usdequant_fx( idx_shb_fr_gain, 0, 86 ); /* 86 = 0.042f in Q11 = Qin-1 */ /* o: temp_shb_ener_sf_fx in Q12 */ /* temp_shb_ener_sf_fx in Q12 */ /* *Q_shb_ener_sf = Pow(10.0, temp_shb_ener_sf_fx ); */ /* = pow(2, 3.321928*temp_shb_ener_sf_fx) */ Loading @@ -3514,12 +3513,9 @@ static void dequantizeSHBparams_fx( idx_res_gs[i] = (Word16) get_next_indice_fx( st_fx, NUM_BITS_SHB_RES_GS ); move16(); } Q_shb_res_gshape[i] = usdequant_fx( idx_res_gs[i], 2048 /*0.125f Q14*/, /*2048 = 0.125 in Q14 */ 1024 /*0.125f Q13*/ /*1024 = 0.125 in Q13 */ ); Q_shb_res_gshape[i] = usdequant_fx( idx_res_gs[i], 2048 /*0.125f Q14*/, 1024 /*0.125f Q13*/ ); move16(); /* o: Q_shb_res_gshape in Q14 */ /* Q_shb_res_gshape in Q14 */ } IF( EQ_16( st_fx->codec_mode, MODE2 ) ) Loading @@ -3533,7 +3529,7 @@ static void dequantizeSHBparams_fx( } *Q_mixFactors = usdequant_fx( idx_mixFac, 4096 /* 0.125 in Q15 */, 2048 /* 0.125 in Q14 */ ); move16(); /* o: Q_mixFactors in Q15 */ /* Q_mixFactors in Q15 */ } ELSE { Loading Loading @@ -3792,14 +3788,14 @@ static void dequantizeSHBparams_fx( void fb_tbe_dec_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ Word16 Q_fb_exc, const Word16 Q_fb_exc, /* i : Q-factor of fb_exc[] */ Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word16 hb_synth_exp, Word16 *fb_synth_ref, /*Q_fb_synth_ref*/ Word16 Q_fb_synth_ref, Word16 output_frame ) const Word16 hb_synth_exp, /* i : Q-factor of hb_synth[] */ Word16 *fb_synth_ref, /* o : Q_fb_synth_ref */ Word16 Q_fb_synth_ref, /* i : Q-factor of fb_synth_ref[] */ const Word16 output_frame /* i : output frame length */ ) { Word16 i; Word16 ratio = 0; Loading Loading @@ -3847,8 +3843,7 @@ void fb_tbe_dec_fx( fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, st->element_mode ); synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, st->element_mode ); test(); IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) ) Loading Loading @@ -3982,6 +3977,8 @@ void tbe_read_bitstream_fx( hBWE_TD->idxGain = (Word16) get_next_indice_fx( st_fx, 4 ); move16(); } return; } Loading @@ -3997,8 +3994,8 @@ void GenTransition_fx( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ const Word32 output_Fs, /* i : output sampling rate */ Word16 rf_flag, /* i : RF flag */ Word32 total_bitrate /* i : total bitrate */ const Word16 rf_flag, /* i : RF flag */ const Word32 total_bitrate /* i : total bitrate */ ) { Word16 i, length; Loading Loading @@ -5271,19 +5268,16 @@ void swb_tbe_dec_ivas_fx( { Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1 vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ /* i: mixFactors_fx in Q15 */ /* o: vind in Q0 */ /* mixFactors_fx in Q15, vind in Q0 */ } ELSE { vind = shl( mixFactors_fx, 3 - 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*8*/ /* i: mixFactors_fx in Q15 */ /* o: vind in Q0 */ /* mixFactors_fx in Q15, vind in Q0 */ } /* Determine formant PF strength */ formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */ formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); /* lpc_shb_fx Q12, formant_fac_fx Q15 */ IF( GT_32( st->total_brate, ACELP_32k ) ) { Loading @@ -5308,7 +5302,7 @@ void swb_tbe_dec_ivas_fx( Lmax = 0; move32(); FOR( cnt = 0; cnt < sig_len; cnt++ ) FOR( cnt = 0; cnt < sig_len; cnt++ ) // note: this differs from the encoder where the length is always L_FRAME32k #else Lmax = 0; move32(); Loading @@ -5324,6 +5318,7 @@ void swb_tbe_dec_ivas_fx( move16(); } Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); /* Account for any outliers in the memories from previous frame for rescaling to avoid saturation */ find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ Loading Loading @@ -5465,6 +5460,7 @@ void swb_tbe_dec_ivas_fx( test(); #ifdef HARMONIZE_TBE3 test(); IF( st->element_mode == EVS_MONO || ( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) ) #else IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) Loading @@ -5474,17 +5470,12 @@ void swb_tbe_dec_ivas_fx( { /* TD BWE post-processing */ #ifdef HARMONIZE_TBE3 IF( st->element_mode == EVS_MONO ) { PostShortTerm_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, PostShortTerm_fx( st->element_mode, DEC, &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); } ELSE #endif { #else PostShortTerm_ivas_dec_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); } #endif } Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ Loading Loading @@ -6149,8 +6140,12 @@ void swb_tbe_dec_ivas_fx( } test(); #ifdef HARMONIZE_TBE3 IF( !st->bfi && st->prev_bfi ) // note: this is likely a bug in EVS #else test(); IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) ) #endif { #ifdef HARMONIZE_TBE3 IF( st->element_mode == EVS_MONO ) Loading lib_enc/evs_enc_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -476,7 +476,11 @@ ivas_error evs_enc_fx( test(); IF( NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) ) { #ifdef HARMONIZE_TBE3 swb_tbe_enc_fx( st, NULL, shb_speech, bwe_exc_extended, voice_factors, fb_exc, &Q_fb_exc, Q_new, Q_shb_spch, st->voicing_fx, pitch_buf ); #else swb_tbe_enc_fx( st, st->coder_type, shb_speech, bwe_exc_extended, voice_factors, fb_exc, &Q_fb_exc, Q_new, Q_shb_spch, st->voicing_fx, pitch_buf ); #endif IF( EQ_16( st->extl, FB_TBE ) ) { Loading Loading
lib_com/prot_fx.h +23 −13 Original line number Diff line number Diff line Loading @@ -2669,11 +2669,19 @@ void flip_and_downmix_generic_fx( ); void Calc_rc0_h( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ ); void PostShortTerm_fx( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *sig_in, /* i : i signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Word16 *sig_out, /* o : postfiltered output */ Loading @@ -2684,6 +2692,7 @@ void PostShortTerm_fx( const Word16 formant_fac_fx /* i : Strength of post-filter*/ ); #ifndef HARMONIZE_TBE3 void PostShortTerm_ivas_enc_fx( Word16 *sig_in, /* i : i signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Loading @@ -2705,7 +2714,7 @@ void PostShortTerm_ivas_dec_fx( Word16 *mem_zero, /* i/o: null memory to compute h_st*/ const Word16 formant_fac_fx /* i : Strength of post-filter*/ ); #endif void flip_spectrum_and_decimby4_fx( const Word16 i[], /* i : i spectrum */ Word16 output[], /* o : output spectrum */ Loading Loading @@ -5547,14 +5556,15 @@ void swb_tbe_dec_fx( void fb_tbe_dec_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part */ Word16 Q_fb_exc, const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ const Word16 Q_fb_exc, /* i : Q-factor of fb_exc[] */ Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word32 *hb_synth, /* o : high-band synthesis */ Word16 hb_synth_exp, Word16 *fb_synth_ref, Word16 Q_fb_synth_ref, Word16 output_frame ); Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */ const Word16 hb_synth_exp, /* i : Q-factor of hb_synth[] */ Word16 *fb_synth_ref, /* o : Q_fb_synth_ref */ Word16 Q_fb_synth_ref, /* i : Q-factor of fb_synth_ref[] */ const Word16 output_frame /* i : output frame length */ ); void tbe_read_bitstream_fx( Decoder_State *st_fx /* i/o: encoder state structure */ Loading @@ -5564,8 +5574,8 @@ void GenTransition_fx( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ const Word32 output_Fs, /* i : output sampling rate */ Word16 rf_flag, /* i : RF flag */ Word32 total_bitrate /* i : total bitrate */ const Word16 rf_flag, /* i : RF flag */ const Word32 total_bitrate /* i : total bitrate */ ); void GenTransition_fx32( Loading
lib_com/swb_tbe_com_fx.c +111 −26 Original line number Diff line number Diff line Loading @@ -26,7 +26,11 @@ static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode ); static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length ); #ifdef HARMONIZE_TBE3 static void Calc_st_filt_tbe_fx( const Word16 element_mode, const Word16 enc_dec, Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); #else static void Calc_st_filt_tbe_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero ); #endif static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); static void Hilbert_transform_sp_fx( Word16 tmp_R[], Word16 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id ); static void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind ); Loading Loading @@ -630,7 +634,12 @@ void flip_spectrum_fx( * * computes 1st parcor from composed filter impulse response *---------------------------------------------------------------------------*/ void Calc_rc0_h( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *h, /* i : impulse response of composed filter */ Word16 *rc0 /* o : 1st parcor */ ) Loading @@ -638,10 +647,41 @@ void Calc_rc0_h( Word32 L_acc; Word16 *ptrs; Word16 acf0, acf1; #ifdef HARMONIZE_TBE3 Word16 tmp2; #endif Word16 temp, sh_acf; Word16 i; /* computation of the autocorrelation function acf */ #ifdef HARMONIZE_TBE3 IF( element_mode != EVS_MONO && enc_dec == ENC ) { L_acc = L_mult( h[0], h[0] ); // TBV: shouldn't it be "shr( h[0], 2 )" ? FOR( i = 1; i < LONG_H_ST; i++ ) { tmp2 = shr( h[i], 2 ); L_acc = L_mac( L_acc, tmp2, tmp2 ); } sh_acf = norm_l( L_acc ); L_acc = L_shl( L_acc, sh_acf ); acf0 = extract_h( L_acc ); ptrs = h; temp = *ptrs++; move16(); L_acc = L_mult( temp, *ptrs ); FOR( i = 1; i < LONG_H_ST - 1; i++ ) { temp = shr( *ptrs++, 2 ); move16(); L_acc = L_mac( L_acc, temp, shr( *ptrs, 2 ) ); } } ELSE #endif { L_acc = L_mult( h[0], h[0] ); FOR( i = 1; i < LONG_H_ST; i++ ) { Loading @@ -662,6 +702,7 @@ void Calc_rc0_h( move16(); L_acc = L_mac( L_acc, temp, *ptrs ); } } L_acc = L_shl( L_acc, sh_acf ); acf1 = extract_h( L_acc ); Loading Loading @@ -750,6 +791,10 @@ static void Calc_rc0_h_ivas_enc_fx( } static void Calc_st_filt_tbe_fx( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ Word16 *parcor0, /* o : 1st parcor calcul. on composed filter */ Loading @@ -764,10 +809,27 @@ static void Calc_st_filt_tbe_fx( Word16 g0, temp; Word16 i; temp = sub( 2, norm_s( apond2[0] ) ); #ifdef HARMONIZE_TBE3 IF( element_mode != EVS_MONO && enc_dec == ENC ) { /* compute i.r. of composed filter apond2 / apond1 */ syn_filt_fx( temp, apond1, LPC_SHB_ORDER, apond2, h, LONG_H_ST, mem_zero, 0 ); } ELSE #endif { /* compute i.r. of composed filter apond2 / apond1 */ Syn_filt_s( temp, apond1, LPC_SHB_ORDER, apond2, h, LONG_H_ST, mem_zero, 0 ); } /* compute 1st parcor */ #ifdef HARMONIZE_TBE3 Calc_rc0_h( element_mode, enc_dec, h, parcor0 ); #else Calc_rc0_h( h, parcor0 ); #endif /* compute g0 */ L_g0 = L_mult0( 1, abs_s( h[0] ) ); Loading @@ -791,6 +853,7 @@ static void Calc_st_filt_tbe_fx( return; } #ifndef HARMONIZE_TBE3 static void Calc_st_filt_tbe_ivas_enc_fx( Word16 *apond2, /* i : coefficients of numerator */ Word16 *apond1, /* i : coefficients of denominator */ Loading Loading @@ -832,6 +895,7 @@ static void Calc_st_filt_tbe_ivas_enc_fx( return; } #endif static void filt_mu_fx( const Word16 *sig_in, /* i : signal (beginning at sample -1) */ Loading Loading @@ -992,7 +1056,18 @@ static void scale_st_swb( return; } /*-------------------------------------------------------------------* * PostShortTerm() * * Short term processing *-------------------------------------------------------------------*/ void PostShortTerm_fx( #ifdef HARMONIZE_TBE3 const Word16 element_mode, /* i : element mode */ const Word16 enc_dec, /* i : encoder/decoder flag */ #endif Word16 *sig_in, /* i : input signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Word16 *sig_out, /* o : postfiltered output */ Loading @@ -1006,7 +1081,6 @@ void PostShortTerm_fx( Word16 apond1_fx[LPC_SHB_ORDER + 1]; /* denominator coeff.*/ Word16 apond2_fx[LONG_H_ST]; /* numerator coeff. */ Word16 sig_ltp_fx[L_SUBFR16k + 1]; /* residual signal */ /*Word16 lpccoeff_fx[LPC_SHB_ORDER+1];//Q12 */ Word16 g1_fx, g2_fx, parcor0_fx; /*Q15 */ Word16 tmp; Loading @@ -1023,24 +1097,34 @@ void PostShortTerm_fx( /* Compute weighted LPC coefficients */ weight_a_fx( lpccoeff, apond1_fx, g1_fx, LPC_SHB_ORDER ); weight_a_fx( lpccoeff, apond2_fx, g2_fx, LPC_SHB_ORDER ); /* o: apond1_fx, apond2_fx in Q12 */ weight_a_fx( lpccoeff, apond2_fx, g2_fx, LPC_SHB_ORDER ); /* apond1_fx, apond2_fx in Q12 */ /* Compute A(gamma2) residual */ Residu3_10_fx( apond2_fx, sig_in, sig_ltp_fx + 1, L_SUBFR16k, 0 ); /* o: sig_ltp_fx in Q_bwe_exc */ Residu3_10_fx( apond2_fx, sig_in, sig_ltp_fx + 1, L_SUBFR16k, 0 ); /* sig_ltp_fx in Q_bwe_exc */ /* Save last output of 1/A(gamma1) */ sig_ltp_fx[0] = *ptr_mem_stp; move16(); /* 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 ); #else Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero ); /* o: parcor0 in Q15 */ /* i/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 IF( element_mode != EVS_MONO && enc_dec == ENC ) { syn_filt_fx( 0, apond1_fx, LPC_SHB_ORDER, sig_ltp_fx + 1, sig_ltp_fx + 1, L_SUBFR16k, mem_stp, 1 ); } ELSE #endif { Syn_filt_s( 0, apond1_fx, LPC_SHB_ORDER, sig_ltp_fx + 1, sig_ltp_fx + 1, L_SUBFR16k, mem_stp, 1 ); } /* (1 + mu z-1) tilt filtering */ filt_mu_fx( sig_ltp_fx, sig_out, parcor0_fx, L_SUBFR16k ); Loading @@ -1052,6 +1136,7 @@ void PostShortTerm_fx( return; } #ifndef HARMONIZE_TBE3 void PostShortTerm_ivas_enc_fx( Word16 *sig_in, /* i : input signal (pointer to current subframe */ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */ Loading Loading @@ -1171,7 +1256,7 @@ void PostShortTerm_ivas_dec_fx( return; } #endif /*-------------------------------------------------------------------* * flip_spectrum_and_decimby4() Loading
lib_dec/dec_post_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -1309,7 +1309,11 @@ static void calc_st_filt_local_fx( E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, M ); /* compute 1st parcor */ #ifdef HARMONIZE_TBE3 Calc_rc0_h( EVS_MONO, DEC, h, parcor0 ); #else Calc_rc0_h( h, parcor0 ); #endif /* compute g0 */ L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12 Loading
lib_dec/swb_tbe_dec_fx.c +34 −39 Original line number Diff line number Diff line Loading @@ -3386,7 +3386,6 @@ static void dequantizeSHBparams_fx( hBWE_TD = st_fx->hBWE_TD; /* LSFs */ IF( EQ_16( extl, WB_TBE ) ) { IF( EQ_32( extl_brate, WB_TBE_0k35 ) ) Loading Loading @@ -3491,7 +3490,7 @@ static void dequantizeSHBparams_fx( idx_shb_fr_gain = (Word16) get_next_indice_fx( st_fx, NUM_BITS_SHB_ENER_SF ); } temp_shb_ener_sf_fx = usdequant_fx( idx_shb_fr_gain, 0, 86 ); /* 86 = 0.042f in Q11 = Qin-1 */ /* o: temp_shb_ener_sf_fx in Q12 */ /* temp_shb_ener_sf_fx in Q12 */ /* *Q_shb_ener_sf = Pow(10.0, temp_shb_ener_sf_fx ); */ /* = pow(2, 3.321928*temp_shb_ener_sf_fx) */ Loading @@ -3514,12 +3513,9 @@ static void dequantizeSHBparams_fx( idx_res_gs[i] = (Word16) get_next_indice_fx( st_fx, NUM_BITS_SHB_RES_GS ); move16(); } Q_shb_res_gshape[i] = usdequant_fx( idx_res_gs[i], 2048 /*0.125f Q14*/, /*2048 = 0.125 in Q14 */ 1024 /*0.125f Q13*/ /*1024 = 0.125 in Q13 */ ); Q_shb_res_gshape[i] = usdequant_fx( idx_res_gs[i], 2048 /*0.125f Q14*/, 1024 /*0.125f Q13*/ ); move16(); /* o: Q_shb_res_gshape in Q14 */ /* Q_shb_res_gshape in Q14 */ } IF( EQ_16( st_fx->codec_mode, MODE2 ) ) Loading @@ -3533,7 +3529,7 @@ static void dequantizeSHBparams_fx( } *Q_mixFactors = usdequant_fx( idx_mixFac, 4096 /* 0.125 in Q15 */, 2048 /* 0.125 in Q14 */ ); move16(); /* o: Q_mixFactors in Q15 */ /* Q_mixFactors in Q15 */ } ELSE { Loading Loading @@ -3792,14 +3788,14 @@ static void dequantizeSHBparams_fx( void fb_tbe_dec_fx( Decoder_State *st, /* i/o: encoder state structure */ const Word16 fb_exc[], /* i : FB excitation from the SWB part Q_fb_exc */ Word16 Q_fb_exc, const Word16 Q_fb_exc, /* i : Q-factor of fb_exc[] */ Word16 *hb_synth16, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word32 *hb_synth, /* o : high-band synthesis Q(15 - hb_synth_exp) */ Word16 hb_synth_exp, Word16 *fb_synth_ref, /*Q_fb_synth_ref*/ Word16 Q_fb_synth_ref, Word16 output_frame ) const Word16 hb_synth_exp, /* i : Q-factor of hb_synth[] */ Word16 *fb_synth_ref, /* o : Q_fb_synth_ref */ Word16 Q_fb_synth_ref, /* i : Q-factor of fb_synth_ref[] */ const Word16 output_frame /* i : output frame length */ ) { Word16 i; Word16 ratio = 0; Loading Loading @@ -3847,8 +3843,7 @@ void fb_tbe_dec_fx( fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, st->element_mode ); synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, st->element_mode ); test(); IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) ) Loading Loading @@ -3982,6 +3977,8 @@ void tbe_read_bitstream_fx( hBWE_TD->idxGain = (Word16) get_next_indice_fx( st_fx, 4 ); move16(); } return; } Loading @@ -3997,8 +3994,8 @@ void GenTransition_fx( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ Word16 *output_HB, /* o : synthesized HB transitions signal st_fx->prev_Q_bwe_syn2 */ const Word32 output_Fs, /* i : output sampling rate */ Word16 rf_flag, /* i : RF flag */ Word32 total_bitrate /* i : total bitrate */ const Word16 rf_flag, /* i : RF flag */ const Word32 total_bitrate /* i : total bitrate */ ) { Word16 i, length; Loading Loading @@ -5271,19 +5268,16 @@ void swb_tbe_dec_ivas_fx( { Word32 vind_temp = Mpy_32_32( L_shl( L_add( L_deposit_l( mixFactors_fx ), 1 ), 15 ), ( ( ( 1 << NUM_BITS_SHB_VF ) - 1 ) << 16 ) ); // check addition of 1 vind = extract_l( L_shr( vind_temp, 15 ) ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*7*/ /* i: mixFactors_fx in Q15 */ /* o: vind in Q0 */ /* mixFactors_fx in Q15, vind in Q0 */ } ELSE { vind = shl( mixFactors_fx, 3 - 15 ); /* 3 for mpy by 8.0f, -15 to bring it to Q0 */ /*mixFactors*8*/ /* i: mixFactors_fx in Q15 */ /* o: vind in Q0 */ /* mixFactors_fx in Q15, vind in Q0 */ } /* Determine formant PF strength */ formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); /* i:lpc_shb_fx Q12, o:formant_fac_fx Q15 */ formant_fac_fx = swb_formant_fac_fx( lpc_shb_fx[1], &hBWE_TD->tilt_mem_fx ); /* lpc_shb_fx Q12, formant_fac_fx Q15 */ IF( GT_32( st->total_brate, ACELP_32k ) ) { Loading @@ -5308,7 +5302,7 @@ void swb_tbe_dec_ivas_fx( Lmax = 0; move32(); FOR( cnt = 0; cnt < sig_len; cnt++ ) FOR( cnt = 0; cnt < sig_len; cnt++ ) // note: this differs from the encoder where the length is always L_FRAME32k #else Lmax = 0; move32(); Loading @@ -5324,6 +5318,7 @@ void swb_tbe_dec_ivas_fx( move16(); } Q_bwe_exc = add( Q_bwe_exc, add( Q_exc, Q_exc ) ); /* Account for any outliers in the memories from previous frame for rescaling to avoid saturation */ find_max_mem_dec( st, &n_mem, &n_mem2, &n_mem3 ); /* for >=24.4, use n_mem2 lpc_syn, shb_20sample, and mem_stp_swb_fx memory */ Loading Loading @@ -5465,6 +5460,7 @@ void swb_tbe_dec_ivas_fx( test(); #ifdef HARMONIZE_TBE3 test(); IF( st->element_mode == EVS_MONO || ( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) ) #else IF( NE_32( st->extl_brate, SWB_TBE_1k10 ) && NE_32( st->extl_brate, SWB_TBE_1k75 ) ) Loading @@ -5474,17 +5470,12 @@ void swb_tbe_dec_ivas_fx( { /* TD BWE post-processing */ #ifdef HARMONIZE_TBE3 IF( st->element_mode == EVS_MONO ) { PostShortTerm_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, PostShortTerm_fx( st->element_mode, DEC, &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); } ELSE #endif { #else PostShortTerm_ivas_dec_fx( &shaped_shb_excitation_fx[L_SHB_LAHEAD + i], lpc_shb_fx, &shaped_shb_excitationTemp_fx[i], hBWE_TD->mem_stp_swb_fx, hBWE_TD->ptr_mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ), hBWE_TD->mem_zero_swb_fx, formant_fac_fx ); } #endif } Copy( shaped_shb_excitationTemp_fx, &shaped_shb_excitation_fx[L_SHB_LAHEAD], L_FRAME16k ); /* Q_bwe_exc */ Loading Loading @@ -6149,8 +6140,12 @@ void swb_tbe_dec_ivas_fx( } test(); #ifdef HARMONIZE_TBE3 IF( !st->bfi && st->prev_bfi ) // note: this is likely a bug in EVS #else test(); IF( !st->bfi && ( st->prev_bfi || st->prev_use_partial_copy ) ) #endif { #ifdef HARMONIZE_TBE3 IF( st->element_mode == EVS_MONO ) Loading
lib_enc/evs_enc_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -476,7 +476,11 @@ ivas_error evs_enc_fx( test(); IF( NE_32( st->core_brate, FRAME_NO_DATA ) && NE_32( st->core_brate, SID_2k40 ) ) { #ifdef HARMONIZE_TBE3 swb_tbe_enc_fx( st, NULL, shb_speech, bwe_exc_extended, voice_factors, fb_exc, &Q_fb_exc, Q_new, Q_shb_spch, st->voicing_fx, pitch_buf ); #else swb_tbe_enc_fx( st, st->coder_type, shb_speech, bwe_exc_extended, voice_factors, fb_exc, &Q_fb_exc, Q_new, Q_shb_spch, st->voicing_fx, pitch_buf ); #endif IF( EQ_16( st->extl, FB_TBE ) ) { Loading