Loading lib_enc/evs_enc_fx.c +1 −1 Original line number Diff line number Diff line Loading @@ -520,7 +520,7 @@ ivas_error evs_enc_fx( { /* SWB BWE encoder */ #ifdef HARM_FD_BWE swb_bwe_enc_ivas_fx( st, EVS_MONO, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, 0, shb_speech, Q_shb_spch, sub( Q_new, 1 ) ); swb_bwe_enc_fx( st, EVS_MONO, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, 0, shb_speech, Q_shb_spch, sub( Q_new, 1 ) ); #else swb_bwe_enc_fx( st, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, shb_speech, st->coder_type, Q_shb_spch, sub( Q_new, 1 ) ); #endif Loading lib_enc/ivas_core_enc_fx.c +1 −1 Original line number Diff line number Diff line Loading @@ -750,7 +750,7 @@ ivas_error ivas_core_enc_fx( { /* SWB(FB) BWE encoder */ #ifdef HARM_FD_BWE swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, 0, sub( Q_new[n], 1 ) ); swb_bwe_enc_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, 0, sub( Q_new[n], 1 ) ); #else swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) ); #endif Loading lib_enc/prot_fx_enc.h +2 −0 Original line number Diff line number Diff line Loading @@ -558,6 +558,7 @@ void StableHighPitchDetect_fx( Word16 EspecdB[] ); void swb_bwe_enc_fx( #ifndef HARM_FD_BWE Encoder_State *st_fx, /* i/o: encoder state structure */ Word16 *old_input_12k8_fx, /* i : i signal @12.8kHz for SWB BWE */ Word16 *old_input_16k_fx, /* i : i signal @16kHz for SWB BWE */ Loading @@ -569,6 +570,7 @@ void swb_bwe_enc_fx( Word16 Q_slb_speech ); void swb_bwe_enc_ivas_fx( #endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Loading lib_enc/swb_bwe_enc_fx.c +236 −76 Original line number Diff line number Diff line Loading @@ -24,7 +24,11 @@ static Word16 WB_BWE_encoding_fx_32( Encoder_State *st_fx, const Word32 *yos_fx, static Word16 SWB_BWE_encoding_fx( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 coder_type, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); #ifdef HARM_FD_BWE static Word16 SWB_BWE_encoding_fx_32( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx_16, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); #else static Word16 SWB_BWE_encoding_fx_32( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); #endif /*-------------------------------------------------------------------* Loading Loading @@ -212,6 +216,7 @@ void wb_bwe_enc_ivas_fx( /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis *---------------------------------------------------------------------*/ set16_fx( old_input_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); Loading Loading @@ -258,13 +263,18 @@ void wb_bwe_enc_ivas_fx( return; } /*-------------------------------------------------------------------* * swb_bwe_enc() * * SWB BWE encoder (only for 32kHz signals) *-------------------------------------------------------------------*/ #ifdef HARM_FD_BWE void swb_bwe_enc_fx( #else void swb_bwe_enc_ivas_fx( #endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Loading Loading @@ -566,13 +576,23 @@ IF( st_fx->element_mode == EVS_MONO ) /* SWB BWE encoding */ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #else SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, SWB_fenv_fx, tilt_nb_fx, 80, st_fx->coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #endif } ELSE { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #else SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, SWB_fenv_fx, tilt_nb_fx, 6, st_fx->coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #endif } } ELSE Loading @@ -582,13 +602,23 @@ ELSE /* SWB BWE encoding */ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #else SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #endif } ELSE { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #else SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #endif } } #else Loading Loading @@ -641,7 +671,7 @@ IF( EQ_16( st_fx->extl, FB_BWE ) ) idxGain = usquant_fx( fb_ener_adjust_fx, &ener_adjust_quan_fx, 0, 512, shl( 1, NUM_BITS_FB_FRAMEGAIN ) ); } #ifdef HARM_FD_BWE #ifndef HARM_FD_BWE /* SWB BWE encoding */ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { Loading @@ -664,6 +694,7 @@ IF( EQ_16( st_fx->extl, FB_BWE ) ) return; } #ifndef HARM_FD_BWE /*-------------------------------------------------------------------* * swb_bwe_enc() * Loading Loading @@ -909,7 +940,7 @@ void swb_bwe_enc_fx( return; } #endif /*==========================================================================*/ /* FUNCTION : static Word16 WB_BWE_fenv_q_fx() */ Loading Loading @@ -1350,6 +1381,7 @@ static Word16 FD_BWE_class_fx( * freq_weights_fx() * *-------------------------------------------------------------------*/ static void freq_weights_fx( const Word16 Band_Ener[], /* i : Band energy Q8 */ const Word16 f_weighting[], /* i : weigting coefs. Q15 */ Loading Loading @@ -1418,6 +1450,7 @@ static void freq_weights_fx( * vqWithCand_w_fx() * *-------------------------------------------------------------------*/ static void vqWithCand_w_fx( const Word16 *x, /* i : input vector Q8 */ const Word16 *E_ROM_dico, /* i : codebook Q8 */ Loading Loading @@ -2621,10 +2654,9 @@ static Word16 WB_BWE_encoding_fx_32( Q_class = Q_synth; Q_energy = Q_synth; Q_fenv = sub( shl( Q_synth, 1 ), 2 ); move16(); move16(); move16(); Q_fenv = sub( shl( Q_synth, 1 ), 2 ); } ELSE #endif Loading Loading @@ -2656,9 +2688,6 @@ static Word16 WB_BWE_encoding_fx_32( Q_class = sub( add( Q_synth, scale ), Q16 ); Q_energy = sub( add( Q_synth_lf, scale ), Q16 ); Q_fenv = add( q_WB_fenv[i], 4 ); move16(); move16(); move16(); } #ifdef HARM_FD_BWE Loading Loading @@ -3157,7 +3186,10 @@ static Word16 SWB_BWE_encoding_fx_32( const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ const Word32 *yos_fx, /* i : MDCT coefficients of the windowed original input signal at 32kHz */ #ifdef HARM_FD_BWE const Word16 *yos_fx_16_orig, /* i : 16-bit MDCT coefficients of the windowed original input signal at 32kHz */ #endif const Word32 *yos_fx, /* i : 32-bit MDCT coefficients of the windowed original input signal at 32kHz */ Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ const Word16 tilt_nb_fx, /* i : SWB tilt */ const Word16 st_offset, /* i : start frequency offset for BWE envelope */ Loading Loading @@ -3193,6 +3225,9 @@ static Word16 SWB_BWE_encoding_fx_32( Word16 inner_frame; Word16 q_shift; Word16 yos_fx_16[L_FRAME_MAX]; #ifdef HARM_FD_BWE Word16 Q_class, Q_energy; #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; Loading @@ -3219,6 +3254,13 @@ static Word16 SWB_BWE_encoding_fx_32( move16(); } #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { Copy( yos_fx_16_orig, yos_fx_16, inner_frame ); } #endif /* HF transient detect */ IsTransient = detect_transient_fx( insig_hp_fx, L_FRAME16k, Q_shb, st_fx ); st_fx->EnergyLT_fx_exp = shl( Q_shb, 1 ); Loading @@ -3233,9 +3275,26 @@ static Word16 SWB_BWE_encoding_fx_32( energy_fx = L_deposit_l( 0 ); FOR( i = 0; i < L; i++ ) { energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2 * Q_insig_lp - 7 */ energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2*Q_slb_speech - 7 / 2*Q_insig_lp - 7 */ } #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { if ( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) { IsTransient_LF = 1; move16(); } hBWE_FD->EnergyLF_fx = energy_fx; hBWE_FD->EnergyLF_exp = sub( 31 + 7, shl( Q_insig_lp, 1 ) ); move32(); move16(); } ELSE #endif { if ( BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( energy_fx, 5958 /* 1/5.5f in Q15 */ ), sub( 31 + 7, shl( Q_insig_lp, 1 ) ), hBWE_FD->EnergyLF_fx, hBWE_FD->EnergyLF_exp ) > 0 ) { IsTransient_LF = 1; Loading @@ -3247,6 +3306,7 @@ static Word16 SWB_BWE_encoding_fx_32( move32(); move16(); } } /* tilt returned in Q24 go to Q11 */ tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); Loading @@ -3267,6 +3327,43 @@ static Word16 SWB_BWE_encoding_fx_32( push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); /* Energy for the different bands and global energies */ #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) { energy_fx = L_deposit_l( 0 ); FOR( n_coeff = swb_bwe_trans_subband[n_band] + st_offset; n_coeff < swb_bwe_trans_subband[n_band + 1] + st_offset; n_coeff++ ) { L_tmp = L_shr( L_mult0( yos_fx_16[n_coeff], yos_fx_16[n_coeff] ), 7 ); /*2*Q_synth-7 */ energy_fx = L_add( L_tmp, energy_fx ); /*2*Q_synth-7 */ } global_gain_fx = L_add( global_gain_fx, L_shr( energy_fx, sub( sub( shl( Q_synth, 1 ), 7 ), shl( Q_shb, 1 ) ) ) ); /*2*Q_shb */ L_SWB_fenv_fx[n_band] = energy_fx; move32(); } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) { expd = norm_s( swb_bwe_trans_subband_width[n_band] ); tmp = div_s( shl( 1, sub( 14, expd ) ), swb_bwe_trans_subband_width[n_band] ); /*Q(29-expd) */ L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], tmp ); /*2*Q_synth-7+29-expd - 15 */ exp = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( sub( 30, exp ), sub( add( shl( Q_synth, 1 ), 7 ), expd ) ); L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ tmp = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ SWB_fenv_fx[n_band] = sub( tmp, Mean_env_tr_fx[n_band] ); move16(); /*Q8 */ } } ELSE #endif { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) { Loading Loading @@ -3294,6 +3391,7 @@ static Word16 SWB_BWE_encoding_fx_32( move16(); } } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) Loading @@ -3310,6 +3408,7 @@ static Word16 SWB_BWE_encoding_fx_32( SWB_fenv_fx[n_band] = sub( tmp, Mean_env_tr_fx[n_band] ); move16(); /*Q8 */ } } WB_tenv_orig_fx = L_deposit_l( 0 ); WB_tenv_syn_fx = L_deposit_l( 1 ); Loading Loading @@ -3355,7 +3454,17 @@ static Word16 SWB_BWE_encoding_fx_32( expd = norm_l( WB_tenv_syn_fx ); den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) ); } ELSE #endif { expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); } scale = shr( sub( den, num ), 15 ); num = shl( num, scale ); Loading Loading @@ -3548,6 +3657,35 @@ static Word16 SWB_BWE_encoding_fx_32( ELSE { /* Energy for the different bands and global energies */ #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { energy_fx = L_deposit_l( 0 ); FOR( n_coeff = swb_bwe_subband[n_band] + st_offset; n_coeff < swb_bwe_subband[n_band + 1] + st_offset; n_coeff++ ) { L_tmp = L_shr( L_mult0( yos_fx_16[n_coeff], yos_fx_16[n_coeff] ), 5 ); /*2*Q_synth-5 */ energy_fx = L_add( L_tmp, energy_fx ); /*2*Q_synth-5 */ } IF( LT_16( n_band, sub( SWB_FENV, 2 ) ) ) { global_gain_fx = L_add( global_gain_fx, L_shr( energy_fx, sub( 2 * Q_synth - 5, 2 * Q_shb ) ) ); /*2*Q_shb */ } L_SWB_fenv_fx[n_band] = energy_fx; move32(); } Q_class = Q_synth; Q_energy = Q_synth_lf; move16(); move16(); } ELSE #endif { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { Loading @@ -3571,29 +3709,51 @@ static Word16 SWB_BWE_encoding_fx_32( move16(); } #ifdef HARM_FD_BWE scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); Q_class = sub( add( Q_synth, scale ), Q16 ); Q_energy = sub( add( Q_synth_lf, scale ), Q16 ); #endif } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ #ifdef HARM_FD_BWE mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, Q_class, Q_shb, st_fx ); #else scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( add( Q_synth, scale ), Q16 ), Q_shb, st_fx ); #endif push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); #ifdef HARM_FD_BWE energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, Q_energy ); #else energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); #endif FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], energy_factor_fx[n_band] ); /*q_SWB_fenv[n_band] */ L_tmp = Mult_32_16( L_tmp, swb_inv_bwe_subband_width_fx[n_band] ); /*q_SWB_fenv[n_band] */ L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], energy_factor_fx[n_band] ); /* 2*Q_synth-5 / q_SWB_fenv[n_band] */ L_tmp = Mult_32_16( L_tmp, swb_inv_bwe_subband_width_fx[n_band] ); /* 2*Q_synth-5 / q_SWB_fenv[n_band] */ IF( L_tmp != 0 ) { expn = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, expn ) ); #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { expn = sub( 30, add( expn, sub( shl( Q_synth, 1 ), 5 ) ) ); } ELSE #endif { expn = sub( 30, add( expn, q_SWB_fenv[n_band] ) ); } L_tmp = Mpy_32_16( expn, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ SWB_fenv_fx[n_band] = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ move16(); Loading Loading
lib_enc/evs_enc_fx.c +1 −1 Original line number Diff line number Diff line Loading @@ -520,7 +520,7 @@ ivas_error evs_enc_fx( { /* SWB BWE encoder */ #ifdef HARM_FD_BWE swb_bwe_enc_ivas_fx( st, EVS_MONO, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, 0, shb_speech, Q_shb_spch, sub( Q_new, 1 ) ); swb_bwe_enc_fx( st, EVS_MONO, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, 0, shb_speech, Q_shb_spch, sub( Q_new, 1 ) ); #else swb_bwe_enc_fx( st, old_inp_12k8, old_inp_16k, old_syn_12k8_16k, new_swb_speech, shb_speech, st->coder_type, Q_shb_spch, sub( Q_new, 1 ) ); #endif Loading
lib_enc/ivas_core_enc_fx.c +1 −1 Original line number Diff line number Diff line Loading @@ -750,7 +750,7 @@ ivas_error ivas_core_enc_fx( { /* SWB(FB) BWE encoder */ #ifdef HARM_FD_BWE swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, 0, sub( Q_new[n], 1 ) ); swb_bwe_enc_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, 0, sub( Q_new[n], 1 ) ); #else swb_bwe_enc_ivas_fx( st, last_element_mode, old_inp_12k8_fx[n], old_inp_16k_fx[n], old_syn_12k8_16k_fx[n], new_swb_speech_fx_16, st->q_inp, shb_speech_fx, sub( Q_new[n], 1 ) ); #endif Loading
lib_enc/prot_fx_enc.h +2 −0 Original line number Diff line number Diff line Loading @@ -558,6 +558,7 @@ void StableHighPitchDetect_fx( Word16 EspecdB[] ); void swb_bwe_enc_fx( #ifndef HARM_FD_BWE Encoder_State *st_fx, /* i/o: encoder state structure */ Word16 *old_input_12k8_fx, /* i : i signal @12.8kHz for SWB BWE */ Word16 *old_input_16k_fx, /* i : i signal @16kHz for SWB BWE */ Loading @@ -569,6 +570,7 @@ void swb_bwe_enc_fx( Word16 Q_slb_speech ); void swb_bwe_enc_ivas_fx( #endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Loading
lib_enc/swb_bwe_enc_fx.c +236 −76 Original line number Diff line number Diff line Loading @@ -24,7 +24,11 @@ static Word16 WB_BWE_encoding_fx_32( Encoder_State *st_fx, const Word32 *yos_fx, static Word16 SWB_BWE_encoding_fx( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 coder_type, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); #ifdef HARM_FD_BWE static Word16 SWB_BWE_encoding_fx_32( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx_16, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); #else static Word16 SWB_BWE_encoding_fx_32( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf ); #endif /*-------------------------------------------------------------------* Loading Loading @@ -212,6 +216,7 @@ void wb_bwe_enc_ivas_fx( /*---------------------------------------------------------------------* * Delay the original input signal to be synchronized with ACELP core synthesis *---------------------------------------------------------------------*/ set16_fx( old_input_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) + L_FRAME16k ); Sample_Delay_WB_BWE = NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ); move16(); Loading Loading @@ -258,13 +263,18 @@ void wb_bwe_enc_ivas_fx( return; } /*-------------------------------------------------------------------* * swb_bwe_enc() * * SWB BWE encoder (only for 32kHz signals) *-------------------------------------------------------------------*/ #ifdef HARM_FD_BWE void swb_bwe_enc_fx( #else void swb_bwe_enc_ivas_fx( #endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 last_element_mode, /* i : last element mode */ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */ Loading Loading @@ -566,13 +576,23 @@ IF( st_fx->element_mode == EVS_MONO ) /* SWB BWE encoding */ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #else SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, SWB_fenv_fx, tilt_nb_fx, 80, st_fx->coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #endif } ELSE { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #else SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, SWB_fenv_fx, tilt_nb_fx, 6, st_fx->coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth ); #endif } } ELSE Loading @@ -582,13 +602,23 @@ ELSE /* SWB BWE encoding */ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #else SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #endif } ELSE { #ifdef HARM_FD_BWE SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #else SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32, SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q ); #endif } } #else Loading Loading @@ -641,7 +671,7 @@ IF( EQ_16( st_fx->extl, FB_BWE ) ) idxGain = usquant_fx( fb_ener_adjust_fx, &ener_adjust_quan_fx, 0, 512, shl( 1, NUM_BITS_FB_FRAMEGAIN ) ); } #ifdef HARM_FD_BWE #ifndef HARM_FD_BWE /* SWB BWE encoding */ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { Loading @@ -664,6 +694,7 @@ IF( EQ_16( st_fx->extl, FB_BWE ) ) return; } #ifndef HARM_FD_BWE /*-------------------------------------------------------------------* * swb_bwe_enc() * Loading Loading @@ -909,7 +940,7 @@ void swb_bwe_enc_fx( return; } #endif /*==========================================================================*/ /* FUNCTION : static Word16 WB_BWE_fenv_q_fx() */ Loading Loading @@ -1350,6 +1381,7 @@ static Word16 FD_BWE_class_fx( * freq_weights_fx() * *-------------------------------------------------------------------*/ static void freq_weights_fx( const Word16 Band_Ener[], /* i : Band energy Q8 */ const Word16 f_weighting[], /* i : weigting coefs. Q15 */ Loading Loading @@ -1418,6 +1450,7 @@ static void freq_weights_fx( * vqWithCand_w_fx() * *-------------------------------------------------------------------*/ static void vqWithCand_w_fx( const Word16 *x, /* i : input vector Q8 */ const Word16 *E_ROM_dico, /* i : codebook Q8 */ Loading Loading @@ -2621,10 +2654,9 @@ static Word16 WB_BWE_encoding_fx_32( Q_class = Q_synth; Q_energy = Q_synth; Q_fenv = sub( shl( Q_synth, 1 ), 2 ); move16(); move16(); move16(); Q_fenv = sub( shl( Q_synth, 1 ), 2 ); } ELSE #endif Loading Loading @@ -2656,9 +2688,6 @@ static Word16 WB_BWE_encoding_fx_32( Q_class = sub( add( Q_synth, scale ), Q16 ); Q_energy = sub( add( Q_synth_lf, scale ), Q16 ); Q_fenv = add( q_WB_fenv[i], 4 ); move16(); move16(); move16(); } #ifdef HARM_FD_BWE Loading Loading @@ -3157,7 +3186,10 @@ static Word16 SWB_BWE_encoding_fx_32( const Word16 *insig_lp_fx, /* i : delayed original lowband input signal at 32kHz */ const Word16 *insig_hp_fx, /* i : delayed original highband input signal at 32kHz */ const Word16 *synth_fx, /* i : delayed ACELP core synthesis at 12.8kHz */ const Word32 *yos_fx, /* i : MDCT coefficients of the windowed original input signal at 32kHz */ #ifdef HARM_FD_BWE const Word16 *yos_fx_16_orig, /* i : 16-bit MDCT coefficients of the windowed original input signal at 32kHz */ #endif const Word32 *yos_fx, /* i : 32-bit MDCT coefficients of the windowed original input signal at 32kHz */ Word16 *SWB_fenv_fx, /* o : frequency-domain quantized BWE envelope */ const Word16 tilt_nb_fx, /* i : SWB tilt */ const Word16 st_offset, /* i : start frequency offset for BWE envelope */ Loading Loading @@ -3193,6 +3225,9 @@ static Word16 SWB_BWE_encoding_fx_32( Word16 inner_frame; Word16 q_shift; Word16 yos_fx_16[L_FRAME_MAX]; #ifdef HARM_FD_BWE Word16 Q_class, Q_energy; #endif FD_BWE_ENC_HANDLE hBWE_FD = st_fx->hBWE_FD; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; Loading @@ -3219,6 +3254,13 @@ static Word16 SWB_BWE_encoding_fx_32( move16(); } #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { Copy( yos_fx_16_orig, yos_fx_16, inner_frame ); } #endif /* HF transient detect */ IsTransient = detect_transient_fx( insig_hp_fx, L_FRAME16k, Q_shb, st_fx ); st_fx->EnergyLT_fx_exp = shl( Q_shb, 1 ); Loading @@ -3233,9 +3275,26 @@ static Word16 SWB_BWE_encoding_fx_32( energy_fx = L_deposit_l( 0 ); FOR( i = 0; i < L; i++ ) { energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2 * Q_insig_lp - 7 */ energy_fx = L_add( energy_fx, L_shr( L_mult0( insig_lp_fx[i + tmp], insig_lp_fx[i + tmp] ), 7 ) ); /*Q = 2*Q_slb_speech - 7 / 2*Q_insig_lp - 7 */ } #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { if ( GT_32( Mult_32_16( energy_fx, 5958 ), hBWE_FD->EnergyLF_fx ) ) { IsTransient_LF = 1; move16(); } hBWE_FD->EnergyLF_fx = energy_fx; hBWE_FD->EnergyLF_exp = sub( 31 + 7, shl( Q_insig_lp, 1 ) ); move32(); move16(); } ELSE #endif { if ( BASOP_Util_Cmp_Mant32Exp( Mpy_32_16_1( energy_fx, 5958 /* 1/5.5f in Q15 */ ), sub( 31 + 7, shl( Q_insig_lp, 1 ) ), hBWE_FD->EnergyLF_fx, hBWE_FD->EnergyLF_exp ) > 0 ) { IsTransient_LF = 1; Loading @@ -3247,6 +3306,7 @@ static Word16 SWB_BWE_encoding_fx_32( move32(); move16(); } } /* tilt returned in Q24 go to Q11 */ tilt_fx = round_fx_sat( L_shl_sat( calc_tilt_bwe_fx( insig_fx, 0, L_FRAME32k ), 3 ) ); Loading @@ -3267,6 +3327,43 @@ static Word16 SWB_BWE_encoding_fx_32( push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); /* Energy for the different bands and global energies */ #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) { energy_fx = L_deposit_l( 0 ); FOR( n_coeff = swb_bwe_trans_subband[n_band] + st_offset; n_coeff < swb_bwe_trans_subband[n_band + 1] + st_offset; n_coeff++ ) { L_tmp = L_shr( L_mult0( yos_fx_16[n_coeff], yos_fx_16[n_coeff] ), 7 ); /*2*Q_synth-7 */ energy_fx = L_add( L_tmp, energy_fx ); /*2*Q_synth-7 */ } global_gain_fx = L_add( global_gain_fx, L_shr( energy_fx, sub( sub( shl( Q_synth, 1 ), 7 ), shl( Q_shb, 1 ) ) ) ); /*2*Q_shb */ L_SWB_fenv_fx[n_band] = energy_fx; move32(); } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) { expd = norm_s( swb_bwe_trans_subband_width[n_band] ); tmp = div_s( shl( 1, sub( 14, expd ) ), swb_bwe_trans_subband_width[n_band] ); /*Q(29-expd) */ L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], tmp ); /*2*Q_synth-7+29-expd - 15 */ exp = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, exp ) ); exp = sub( sub( 30, exp ), sub( add( shl( Q_synth, 1 ), 7 ), expd ) ); L_tmp = Mpy_32_16( exp, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ tmp = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ SWB_fenv_fx[n_band] = sub( tmp, Mean_env_tr_fx[n_band] ); move16(); /*Q8 */ } } ELSE #endif { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) { Loading Loading @@ -3294,6 +3391,7 @@ static Word16 SWB_BWE_encoding_fx_32( move16(); } } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ FOR( n_band = 0; n_band < SWB_FENV_TRANS; n_band++ ) Loading @@ -3310,6 +3408,7 @@ static Word16 SWB_BWE_encoding_fx_32( SWB_fenv_fx[n_band] = sub( tmp, Mean_env_tr_fx[n_band] ); move16(); /*Q8 */ } } WB_tenv_orig_fx = L_deposit_l( 0 ); WB_tenv_syn_fx = L_deposit_l( 1 ); Loading Loading @@ -3355,7 +3454,17 @@ static Word16 SWB_BWE_encoding_fx_32( expd = norm_l( WB_tenv_syn_fx ); den = round_fx_sat( L_shl( WB_tenv_syn_fx, expd ) ); #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { expd = sub( sub( 30, expd ), sub( shl( st_fx->Q_syn2, 1 ), 7 ) ); } ELSE #endif { expd = sub( sub( 30, expd ), sub( shl( Q_insig_lp, 1 ), 7 ) ); } scale = shr( sub( den, num ), 15 ); num = shl( num, scale ); Loading Loading @@ -3548,6 +3657,35 @@ static Word16 SWB_BWE_encoding_fx_32( ELSE { /* Energy for the different bands and global energies */ #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { energy_fx = L_deposit_l( 0 ); FOR( n_coeff = swb_bwe_subband[n_band] + st_offset; n_coeff < swb_bwe_subband[n_band + 1] + st_offset; n_coeff++ ) { L_tmp = L_shr( L_mult0( yos_fx_16[n_coeff], yos_fx_16[n_coeff] ), 5 ); /*2*Q_synth-5 */ energy_fx = L_add( L_tmp, energy_fx ); /*2*Q_synth-5 */ } IF( LT_16( n_band, sub( SWB_FENV, 2 ) ) ) { global_gain_fx = L_add( global_gain_fx, L_shr( energy_fx, sub( 2 * Q_synth - 5, 2 * Q_shb ) ) ); /*2*Q_shb */ } L_SWB_fenv_fx[n_band] = energy_fx; move32(); } Q_class = Q_synth; Q_energy = Q_synth_lf; move16(); move16(); } ELSE #endif { global_gain_fx = L_deposit_l( 0 ); FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { Loading @@ -3571,29 +3709,51 @@ static Word16 SWB_BWE_encoding_fx_32( move16(); } #ifdef HARM_FD_BWE scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); Q_class = sub( add( Q_synth, scale ), Q16 ); Q_energy = sub( add( Q_synth_lf, scale ), Q16 ); #endif } global_gain_fx = L_shr( global_gain_fx, 1 ); /*2*Q_shb */ #ifdef HARM_FD_BWE mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, Q_class, Q_shb, st_fx ); #else scale = s_min( L_norm_arr( yos_fx, inner_frame ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ ); Copy_Scale_sig32_16( yos_fx, yos_fx_16, inner_frame, scale ); mode = FD_BWE_class_fx( yos_fx_16, global_gain_fx, tilt_nb_fx, sub( add( Q_synth, scale ), Q16 ), Q_shb, st_fx ); #endif push_indice( hBstr, IND_SWB_CLASS, mode, 2 ); #ifdef HARM_FD_BWE energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); energy_control_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, Q_energy ); #else energy_control_ivas_fx( st_fx, ACELP_CORE, mode, -1, yos_fx_16, st_offset, energy_factor_fx, sub( add( Q_synth_lf, scale ), Q16 ) ); #endif FOR( n_band = 0; n_band < SWB_FENV; n_band++ ) { L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], energy_factor_fx[n_band] ); /*q_SWB_fenv[n_band] */ L_tmp = Mult_32_16( L_tmp, swb_inv_bwe_subband_width_fx[n_band] ); /*q_SWB_fenv[n_band] */ L_tmp = Mult_32_16( L_SWB_fenv_fx[n_band], energy_factor_fx[n_band] ); /* 2*Q_synth-5 / q_SWB_fenv[n_band] */ L_tmp = Mult_32_16( L_tmp, swb_inv_bwe_subband_width_fx[n_band] ); /* 2*Q_synth-5 / q_SWB_fenv[n_band] */ IF( L_tmp != 0 ) { expn = norm_l( L_tmp ); tmp = Log2_norm_lc( L_shl( L_tmp, expn ) ); #ifdef HARM_FD_BWE IF( st_fx->element_mode == EVS_MONO ) { expn = sub( 30, add( expn, sub( shl( Q_synth, 1 ), 5 ) ) ); } ELSE #endif { expn = sub( 30, add( expn, q_SWB_fenv[n_band] ) ); } L_tmp = Mpy_32_16( expn, tmp, 24660 ); /* Q14 */ /*10log10(2) in Q13 */ SWB_fenv_fx[n_band] = round_fx( L_shl( L_tmp, 10 ) ); /* Q8 */ move16(); Loading