Loading lib_com/core_com_config_fx.c +0 −8 Original line number Diff line number Diff line Loading @@ -997,11 +997,7 @@ void init_tcx_cfg_ivas_fx( IF( hTcxCfg->fIsTNSAllowed ) { #ifdef FIX_2388_INITTNSCONFIGURATION InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #else InitTnsConfigs_ivas_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #endif SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } Loading Loading @@ -1256,11 +1252,7 @@ void init_tcx_cfg_fx( IF( hTcxCfg->fIsTNSAllowed ) { #ifdef FIX_2388_INITTNSCONFIGURATION InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #else InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #endif SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } Loading lib_com/gs_gains_fx.c +6 −179 Original line number Diff line number Diff line Loading @@ -70,19 +70,13 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const /* _ None */ /*========================================================================*/ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Word16 Comp_and_apply_gain_fx( #else void Comp_and_apply_gain_fx( #endif Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX const Word16 Flag_adj_q_exc, /* i : Flag allowing Q_exc adjustment */ #endif Word16 Qexc_diff, Word16 Q_exc ) { Loading @@ -90,11 +84,9 @@ void Comp_and_apply_gain_fx( Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Word16 Q_adapt; Word16 Q_exc_diffQ[L_FRAME16k]; Word32 exc_diffQ32[L_FRAME16k]; #endif Word32 L32; /* Recreate excitation for local synthesis and decoder */ Loading Loading @@ -139,7 +131,6 @@ void Comp_and_apply_gain_fx( Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX IF( Flag_adj_q_exc != 0 ) { FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) Loading @@ -155,7 +146,6 @@ void Comp_and_apply_gain_fx( } } ELSE #endif { FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { Loading @@ -166,7 +156,6 @@ void Comp_and_apply_gain_fx( } } } #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Q_adapt = Q_exc; move16(); test(); Loading @@ -185,113 +174,8 @@ void Comp_and_apply_gain_fx( } } return Q_adapt; #else return; #endif } #ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 *Q_exc ) { Word16 i, i_band; Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; Word32 L32; Word16 Q_exc_diffQ[L_FRAME16k]; /* Recreate excitation for local synthesis and decoder */ StartBin = 0; move16(); NB_Qbins = 0; move16(); tmp_exp = add( 14, sub( *Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/ FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { StartBin = add( StartBin, NB_Qbins ); NB_Qbins = mfreq_bindiv_loc[i_band]; move16(); IF( EQ_16( ReUseGain, 1 ) ) { y_gain = Ener_per_bd_yQ[i_band]; /*Q13*/ move16(); FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { L32 = L_mult( exc_diffQ[i], y_gain ); /*Q_exc+16-tmp_exp */ exc_diffQ[i] = round_fx_sat( L32 ); /*Q_exc-tmp_exp */ move16(); IF( exc_diffQ[i] ) { Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp ); } ELSE { Q_exc_diffQ[i] = *Q_exc; } move16(); } } ELSE { /*-----------------------------------------------------------------* * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) *-----------------------------------------------------------------*/ L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); /*Q13*/ move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( *Q_exc, Qexc_diff ) ); FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ exc_diffQ[i] = round_fx_sat( L32 ); /*Q_exc-tmp_exp */ move16(); IF( exc_diffQ[i] ) { Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp ); } ELSE { Q_exc_diffQ[i] = *Q_exc; } move16(); } } } FOR( i = 0; i < StartBin + NB_Qbins; i++ ) { *Q_exc = s_min( *Q_exc, add( Q_exc_diffQ[i], norm_s( exc_diffQ[i] ) ) ); move16(); } FOR( i = 0; i < StartBin + NB_Qbins; i++ ) { exc_diffQ[i] = shl( exc_diffQ[i], sub( *Q_exc, Q_exc_diffQ[i] ) ); /*Q_exc*/ move16(); } return; } #endif /*========================================================================*/ /* FUNCTION : Ener_per_band_comp_fx() */ Loading Loading @@ -343,57 +227,6 @@ void Ener_per_band_comp_fx( Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ #ifdef FIX_1904_HARM_GSC_ENC const Word16 Eflag, /* i : flag of highest band */ const Word16 L_frame /* i : frame length */ #else const Word16 Eflag /* i : flag of highest band */ #endif ) { const Word16 *pt_fx; Word16 j; pt_fx = exc_diff_fx; FOR( j = 0; j < 2; j++ ) { y_gain4_fx[j] = Comp_band_log_ener( pt_fx, 8, Q_exc, 1 ); /*Q12*/ move16(); pt_fx += 8; } FOR( j = 1; j < Mband - 2; j++ ) { y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 16, Q_exc, 0 ); /*Q12*/ move16(); pt_fx += 16; } IF( EQ_16( Eflag, 1 ) ) { y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ move16(); pt_fx += 32; } #ifdef FIX_1904_HARM_GSC_ENC IF( EQ_16( L_frame, L_FRAME16k ) ) { y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ move16(); y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/ move16(); } #endif return; } #ifndef FIX_1904_HARM_GSC_ENC void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag, /* i : flag of highest band */ const Word16 L_frame /* i : frame length */ ) Loading Loading @@ -429,12 +262,10 @@ void Ener_per_band_comp_ivas_fx( move16(); y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/ move16(); pt_fx += 64; } return; } #endif /*-------------------------------------------------------------------* Loading Loading @@ -511,11 +342,7 @@ static void GSC_gain_adj( } /*mimic ACELP decay of energy for low rates*/ #ifndef FIX_2406_FIX_GAIN_ON_INACTIVE FOR( i = 0; i < MBANDS_GN; i++ ) #else FOR( i = 0; i < Mbands_gn; i++ ) #endif { old_y_gain[i] = y_gain_tmp[i]; move16(); Loading lib_com/gs_inact_switching_fx.c +0 −12 Original line number Diff line number Diff line Loading @@ -77,11 +77,7 @@ void Inac_switch_ematch_fx( test(); IF( ( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) ) ) && bfi == 0 ) { #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) Loading @@ -95,11 +91,7 @@ void Inac_switch_ematch_fx( /* Find spectrum and energy per band for GC and VC frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) Loading @@ -113,11 +105,7 @@ void Inac_switch_ematch_fx( /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif /* More agressive smoothing in the first 50 frames */ pt_exc = dct_exc_tmp; Loading lib_com/gs_noisefill_fx.c +0 −446 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_com/gs_preech_fx.c +2 −118 Original line number Diff line number Diff line Loading @@ -56,12 +56,8 @@ void pre_echo_att_fx( const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ #ifdef FIX_1904_HARM_GSC_ENC const Word16 L_frame, /* i : Frame length Q0*/ const Word16 element_mode /* i : Current IVAS element mode*/ #else const Word16 L_frame /* i : Frame length Q0*/ #endif ) { Word32 etmp_fx; Loading @@ -73,9 +69,7 @@ void pre_echo_att_fx( Word16 tmp, n1, n2, exp, frac1, frac2; Word32 etmp1_fx; Word16 att_len; #ifdef FIX_1904_HARM_GSC_ENC Word16 etmp_e, tmp_e; #endif test(); IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ Loading Loading @@ -115,7 +109,6 @@ void pre_echo_att_fx( IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) { /* Find the average energy before the attack */ #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { etmp_fx = sum32_fx( finc_fx, attack_pos_fx ); Loading @@ -133,7 +126,6 @@ void pre_echo_att_fx( ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */ } ELSE #endif { L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ Loading Loading @@ -180,7 +172,6 @@ void pre_echo_att_fx( * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { Word16 exp_etmp = sub( 15, Q_new ); Loading @@ -193,7 +184,6 @@ void pre_echo_att_fx( *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ } ELSE #endif { etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ Loading @@ -204,109 +194,3 @@ void pre_echo_att_fx( return; } #ifndef FIX_1904_HARM_GSC_ENC void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ ) { Word32 etmp_fx; Word32 finc_fx[ATT_LENGHT16k] = { 0 }; move16(); Word16 ratio_fx; Word16 attack_pos_fx, i; Word32 L_tmp; Word16 tmp, tmp_e; Word32 etmp1_fx; Word16 etmp_e; Word16 att_len; test(); IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ { /*-------------------------------------------------------------------------* * Find where the onset (attack) occurs by computing the energy per section * The inverse weighting aims to favor the first maxima in case of * gradual onset *-------------------------------------------------------------------------*/ att_len = ATT_LENGHT; /* Q0 */ move16(); if ( EQ_16( L_frame, L_FRAME16k ) ) { att_len = ATT_LENGHT16k; /* Q0 */ move16(); } FOR( i = 0; i < att_len; i++ ) { L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */ L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */ finc_fx[i] = L_tmp; move32(); /*2*Q_new+1 */ } attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx ); /* Scaled the maximum energy and allowed 6 dB increase*/ etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ etmp1_fx = etmp_fx; move32(); *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); move32(); /*2*Q_new+1 */ /* If the maximum normalized energy > last frame energy + 6dB */ test(); IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) { /* Find the average energy before the attack */ etmp_fx = sum32_fx( finc_fx, attack_pos_fx ); etmp_e = sub( 31, add( shl( Q_new, 1 ), 1 ) ); etmp_fx = L_add( etmp_fx, L_shr( 21474836 /*0.01 in Q31*/, etmp_e ) ); /* etmp = etmp + 0.01; (exp = etmp_e) */ etmp_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( etmp_fx, L_mult0( attack_pos_fx, ATT_SEG_LEN ), &tmp_e ) ); tmp_e = add( tmp_e, sub( etmp_e, 31 ) ); etmp_e = tmp_e; move16(); /* Find the correction factor and apply it before the attack */ tmp = BASOP_Util_Divide3232_Scale( *Last_frame_ener_fx, etmp_fx, &tmp_e ); /* numerator Q = 2 * Q_new + 1; denominator Q = 31 - tmp_e */ tmp_e = add( tmp_e, sub( sub( 31, etmp_e ), add( shl( Q_new, 1 ), 1 ) ) ); /* tmp_e = tmp_e + (31 - tmp_e) - (2 * Q_new + 1) */ tmp = Sqrt16( tmp, &tmp_e ); ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */ /* Pre-echo atttenuation should never increase the energy */ ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) { /*exc_fx[i] *= ratio_fx;*/ exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) ); move16(); } } *Last_frame_ener_fx = etmp1_fx; /* 2 * Q_new + 1 */ move32(); } ELSE { /*-------------------------------------------------------* * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ Word16 exp_etmp = sub( 15, Q_new ); etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ IF( EQ_16( L_frame, L_FRAME16k ) ) { etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ } *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ move32(); /*2*Q_new+1*/ } return; } #endif Loading
lib_com/core_com_config_fx.c +0 −8 Original line number Diff line number Diff line Loading @@ -997,11 +997,7 @@ void init_tcx_cfg_ivas_fx( IF( hTcxCfg->fIsTNSAllowed ) { #ifdef FIX_2388_INITTNSCONFIGURATION InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #else InitTnsConfigs_ivas_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #endif SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } Loading Loading @@ -1256,11 +1252,7 @@ void init_tcx_cfg_fx( IF( hTcxCfg->fIsTNSAllowed ) { #ifdef FIX_2388_INITTNSCONFIGURATION InitTnsConfigs_fx( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #else InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag ); #endif SetAllowTnsOnWhite( hTcxCfg->tnsConfig, (Word8) EQ_16( element_mode, IVAS_CPE_MDCT ) ); } Loading
lib_com/gs_gains_fx.c +6 −179 Original line number Diff line number Diff line Loading @@ -70,19 +70,13 @@ static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const /* _ None */ /*========================================================================*/ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Word16 Comp_and_apply_gain_fx( #else void Comp_and_apply_gain_fx( #endif Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o: Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX const Word16 Flag_adj_q_exc, /* i : Flag allowing Q_exc adjustment */ #endif Word16 Qexc_diff, Word16 Q_exc ) { Loading @@ -90,11 +84,9 @@ void Comp_and_apply_gain_fx( Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Word16 Q_adapt; Word16 Q_exc_diffQ[L_FRAME16k]; Word32 exc_diffQ32[L_FRAME16k]; #endif Word32 L32; /* Recreate excitation for local synthesis and decoder */ Loading Loading @@ -139,7 +131,6 @@ void Comp_and_apply_gain_fx( Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX IF( Flag_adj_q_exc != 0 ) { FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) Loading @@ -155,7 +146,6 @@ void Comp_and_apply_gain_fx( } } ELSE #endif { FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { Loading @@ -166,7 +156,6 @@ void Comp_and_apply_gain_fx( } } } #ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX Q_adapt = Q_exc; move16(); test(); Loading @@ -185,113 +174,8 @@ void Comp_and_apply_gain_fx( } } return Q_adapt; #else return; #endif } #ifndef FIX_2338_HARM_GSC_GAIN_COMP void Comp_and_apply_gain_ivas_fx( Word16 exc_diffQ[], /* i/o: Quantized excitation */ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */ Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */ Word16 Mbands_gn, /* i : number of bands */ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */ Word16 Qexc_diff, Word16 *Q_exc ) { Word16 i, i_band; Word16 StartBin, NB_Qbins; Word16 y_gain; Word16 L16, frac, exp1, tmp_exp; Word32 L32; Word16 Q_exc_diffQ[L_FRAME16k]; /* Recreate excitation for local synthesis and decoder */ StartBin = 0; move16(); NB_Qbins = 0; move16(); tmp_exp = add( 14, sub( *Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/ FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { StartBin = add( StartBin, NB_Qbins ); NB_Qbins = mfreq_bindiv_loc[i_band]; move16(); IF( EQ_16( ReUseGain, 1 ) ) { y_gain = Ener_per_bd_yQ[i_band]; /*Q13*/ move16(); FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { L32 = L_mult( exc_diffQ[i], y_gain ); /*Q_exc+16-tmp_exp */ exc_diffQ[i] = round_fx_sat( L32 ); /*Q_exc-tmp_exp */ move16(); IF( exc_diffQ[i] ) { Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp ); } ELSE { Q_exc_diffQ[i] = *Q_exc; } move16(); } } ELSE { /*-----------------------------------------------------------------* * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) *-----------------------------------------------------------------*/ L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); /*Q13*/ move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( *Q_exc, Qexc_diff ) ); FOR( i = StartBin; i < NB_Qbins + StartBin; i++ ) { L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */ exc_diffQ[i] = round_fx_sat( L32 ); /*Q_exc-tmp_exp */ move16(); IF( exc_diffQ[i] ) { Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp ); } ELSE { Q_exc_diffQ[i] = *Q_exc; } move16(); } } } FOR( i = 0; i < StartBin + NB_Qbins; i++ ) { *Q_exc = s_min( *Q_exc, add( Q_exc_diffQ[i], norm_s( exc_diffQ[i] ) ) ); move16(); } FOR( i = 0; i < StartBin + NB_Qbins; i++ ) { exc_diffQ[i] = shl( exc_diffQ[i], sub( *Q_exc, Q_exc_diffQ[i] ) ); /*Q_exc*/ move16(); } return; } #endif /*========================================================================*/ /* FUNCTION : Ener_per_band_comp_fx() */ Loading Loading @@ -343,57 +227,6 @@ void Ener_per_band_comp_fx( Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ #ifdef FIX_1904_HARM_GSC_ENC const Word16 Eflag, /* i : flag of highest band */ const Word16 L_frame /* i : frame length */ #else const Word16 Eflag /* i : flag of highest band */ #endif ) { const Word16 *pt_fx; Word16 j; pt_fx = exc_diff_fx; FOR( j = 0; j < 2; j++ ) { y_gain4_fx[j] = Comp_band_log_ener( pt_fx, 8, Q_exc, 1 ); /*Q12*/ move16(); pt_fx += 8; } FOR( j = 1; j < Mband - 2; j++ ) { y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 16, Q_exc, 0 ); /*Q12*/ move16(); pt_fx += 16; } IF( EQ_16( Eflag, 1 ) ) { y_gain4_fx[j + 1] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ move16(); pt_fx += 32; } #ifdef FIX_1904_HARM_GSC_ENC IF( EQ_16( L_frame, L_FRAME16k ) ) { y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ move16(); y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/ move16(); } #endif return; } #ifndef FIX_1904_HARM_GSC_ENC void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag, /* i : flag of highest band */ const Word16 L_frame /* i : frame length */ ) Loading Loading @@ -429,12 +262,10 @@ void Ener_per_band_comp_ivas_fx( move16(); y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/ move16(); pt_fx += 64; } return; } #endif /*-------------------------------------------------------------------* Loading Loading @@ -511,11 +342,7 @@ static void GSC_gain_adj( } /*mimic ACELP decay of energy for low rates*/ #ifndef FIX_2406_FIX_GAIN_ON_INACTIVE FOR( i = 0; i < MBANDS_GN; i++ ) #else FOR( i = 0; i < Mbands_gn; i++ ) #endif { old_y_gain[i] = y_gain_tmp[i]; move16(); Loading
lib_com/gs_inact_switching_fx.c +0 −12 Original line number Diff line number Diff line Loading @@ -77,11 +77,7 @@ void Inac_switch_ematch_fx( test(); IF( ( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) ) ) && bfi == 0 ) { #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) Loading @@ -95,11 +91,7 @@ void Inac_switch_ematch_fx( /* Find spectrum and energy per band for GC and VC frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) Loading @@ -113,11 +105,7 @@ void Inac_switch_ematch_fx( /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif /* More agressive smoothing in the first 50 frames */ pt_exc = dct_exc_tmp; Loading
lib_com/gs_noisefill_fx.c +0 −446 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib_com/gs_preech_fx.c +2 −118 Original line number Diff line number Diff line Loading @@ -56,12 +56,8 @@ void pre_echo_att_fx( const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ #ifdef FIX_1904_HARM_GSC_ENC const Word16 L_frame, /* i : Frame length Q0*/ const Word16 element_mode /* i : Current IVAS element mode*/ #else const Word16 L_frame /* i : Frame length Q0*/ #endif ) { Word32 etmp_fx; Loading @@ -73,9 +69,7 @@ void pre_echo_att_fx( Word16 tmp, n1, n2, exp, frac1, frac2; Word32 etmp1_fx; Word16 att_len; #ifdef FIX_1904_HARM_GSC_ENC Word16 etmp_e, tmp_e; #endif test(); IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ Loading Loading @@ -115,7 +109,6 @@ void pre_echo_att_fx( IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) { /* Find the average energy before the attack */ #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { etmp_fx = sum32_fx( finc_fx, attack_pos_fx ); Loading @@ -133,7 +126,6 @@ void pre_echo_att_fx( ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */ } ELSE #endif { L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ Loading Loading @@ -180,7 +172,6 @@ void pre_echo_att_fx( * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { Word16 exp_etmp = sub( 15, Q_new ); Loading @@ -193,7 +184,6 @@ void pre_echo_att_fx( *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ } ELSE #endif { etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ Loading @@ -204,109 +194,3 @@ void pre_echo_att_fx( return; } #ifndef FIX_1904_HARM_GSC_ENC void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ ) { Word32 etmp_fx; Word32 finc_fx[ATT_LENGHT16k] = { 0 }; move16(); Word16 ratio_fx; Word16 attack_pos_fx, i; Word32 L_tmp; Word16 tmp, tmp_e; Word32 etmp1_fx; Word16 etmp_e; Word16 att_len; test(); IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ { /*-------------------------------------------------------------------------* * Find where the onset (attack) occurs by computing the energy per section * The inverse weighting aims to favor the first maxima in case of * gradual onset *-------------------------------------------------------------------------*/ att_len = ATT_LENGHT; /* Q0 */ move16(); if ( EQ_16( L_frame, L_FRAME16k ) ) { att_len = ATT_LENGHT16k; /* Q0 */ move16(); } FOR( i = 0; i < att_len; i++ ) { L_tmp = sum2_fx( &exc_fx[i * 4], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/ tmp = div_s( sub( att_len, i ), att_len ); /*Q15 */ L_tmp = Mult_32_16( L_tmp, tmp ); /*2*Q_new+1 */ finc_fx[i] = L_tmp; move32(); /*2*Q_new+1 */ } attack_pos_fx = maximum_32_fx( finc_fx, att_len, &etmp_fx ); /* Scaled the maximum energy and allowed 6 dB increase*/ etmp_fx = L_shr( etmp_fx, add( 2 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */ etmp1_fx = etmp_fx; move32(); *Last_frame_ener_fx = L_shl_sat( *Last_frame_ener_fx, 2 ); move32(); /*2*Q_new+1 */ /* If the maximum normalized energy > last frame energy + 6dB */ test(); IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) { /* Find the average energy before the attack */ etmp_fx = sum32_fx( finc_fx, attack_pos_fx ); etmp_e = sub( 31, add( shl( Q_new, 1 ), 1 ) ); etmp_fx = L_add( etmp_fx, L_shr( 21474836 /*0.01 in Q31*/, etmp_e ) ); /* etmp = etmp + 0.01; (exp = etmp_e) */ etmp_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( etmp_fx, L_mult0( attack_pos_fx, ATT_SEG_LEN ), &tmp_e ) ); tmp_e = add( tmp_e, sub( etmp_e, 31 ) ); etmp_e = tmp_e; move16(); /* Find the correction factor and apply it before the attack */ tmp = BASOP_Util_Divide3232_Scale( *Last_frame_ener_fx, etmp_fx, &tmp_e ); /* numerator Q = 2 * Q_new + 1; denominator Q = 31 - tmp_e */ tmp_e = add( tmp_e, sub( sub( 31, etmp_e ), add( shl( Q_new, 1 ), 1 ) ) ); /* tmp_e = tmp_e + (31 - tmp_e) - (2 * Q_new + 1) */ tmp = Sqrt16( tmp, &tmp_e ); ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */ /* Pre-echo atttenuation should never increase the energy */ ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) { /*exc_fx[i] *= ratio_fx;*/ exc_fx[i] = round_fx( L_shl( L_mac( -8192, exc_fx[i], ratio_fx ), 2 ) ); move16(); } } *Last_frame_ener_fx = etmp1_fx; /* 2 * Q_new + 1 */ move32(); } ELSE { /*-------------------------------------------------------* * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ Word16 exp_etmp = sub( 15, Q_new ); etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ IF( EQ_16( L_frame, L_FRAME16k ) ) { etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ } *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ move32(); /*2*Q_new+1*/ } return; } #endif