diff --git a/lib_com/options.h b/lib_com/options.h index 00fd028cf58629320fce47e3ed1d27862a484104..7fc786a4d3d0118a97d707475d033940e3e8651b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,6 +106,7 @@ #define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ #define FIX_2330_CLANG_18_WARNINGS_REND /* FhG: Fix renderer warnings */ #define FIX_BASOP_2350_HARM_0B_BWE /* VA: basop issue 2350: harmonization of the 0b BWE */ +#define FIX_2349_HARM_FIND_UV /* VA: basop issue 2349: harmonization of find_uv() function */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index 8466a5f43bcfba779a5bcecced5e0e9bef41f3f9..a2dc8803bb05c4e9376ecc63ed296d32ac92f9f0 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -85,7 +85,7 @@ void hf_synth_reset_fx( void hf_synth_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ #ifdef FIX_BASOP_2350_HARM_0B_BWE - const Word16 element_mode, /* i : element mode Q0*/ + const Word16 element_mode, /* i : element mode Q0*/ #endif const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ @@ -93,8 +93,8 @@ void hf_synth_fx( const Word16 *exc, /* i : excitation at 12.8 kHz Q_exc*/ Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ - const Word16 Q_exc, /* i : excitation scaling */ - const Word16 Q_syn2 /* i : synthesis scaling */ + const Word16 Q_exc, /* i : excitation scaling */ + const Word16 Q_syn2 /* i : synthesis scaling */ ) { const Word16 *p_Aq; @@ -194,18 +194,12 @@ static void hf_synthesis_fx( L_tmp = Isqrt_lc( L_tmp, &exp1 ); scale = round_fx( L_tmp ); /* Q18 when Q_exc=-1, HF_exc in Q-3 */ - /* moved after the else */ - /* exp2 = sub( hBWE_zero->memExp1, exp1 ); - hBWE_zero->memExp1 = exp1; - move16(); */ /*-----------------------------------------------------------------* * calculate energy scaling factor to respect tilt of synth12k8 * (tilt: 1=voiced, -1=unvoiced) *-----------------------------------------------------------------*/ + hp400_12k8_fx( synth, L_SUBFR, hBWE_zero->mem_hp400_fx ); - /* i: mem_hp400 in Q_syn */ - /* i: synth in Q_syn */ - /* o: synth in Q_syn-3 */ L_tmp = L_mac( 1L, synth[0], synth[0] ); /* 2*(Q_syn-3)+1 */ FOR( i = 1; i < L_SUBFR; i++ ) @@ -235,6 +229,7 @@ static void hf_synthesis_fx( /*-----------------------------------------------------------------* * modify energy of white noise according to synthesis tilt *-----------------------------------------------------------------*/ + /* tmp = 1.0 - fac */ tmp = add_sat( 1, sub( 32767 /* 1 in Q15 */, tmp ) ); test(); @@ -325,10 +320,12 @@ static void hf_synthesis_fx( Q_tmp = sub( Q_tmp, exp1 ); } #endif + /*-----------------------------------------------------------------* * modify HF excitation according to both calculated scaling factors * high pass filtering (0.94ms of delay) *-----------------------------------------------------------------*/ + exp2 = sub( hBWE_zero->memExp1, exp1 ); hBWE_zero->memExp1 = exp1; move16(); @@ -342,15 +339,9 @@ static void hf_synthesis_fx( * synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz *-----------------------------------------------------------------*/ - /*weight_a( Aq, Ap, 0.6f, M );*/ weight_a_lc_fx( Aq, Ap, Gamma_19661_Tbl_fx, M ); - /* o: Ap in Q14 */ Syn_filt_s( 0, Ap, M, HF_exc, HF_syn, L_SUBFR16k, hBWE_zero->mem_syn_hf_fx, 1 ); - /* i: Ap in Q14 */ - /* i: HF_exc in Q0 */ - /* o: HF_syn in Q0 */ - /* i/o: mem_syn_hf in Q0 */ Scale_sig( HF_syn, L_SUBFR16k, ( add( Q_syn, exp1 ) ) ); /* bring HF_syn to (Q_syn+exp1) */ @@ -389,10 +380,12 @@ static void hf_synthesis_fx( { Copy( HF_syn, upsampled_HF_syn, L_SUBFR16k ); /* Q_syn */ } + Vr_add( synth16k, upsampled_HF_syn, synth16k, output_subfr ); return; } + #ifndef FIX_BASOP_2350_HARM_0B_BWE void hf_synth_ivas_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* i/o: handle to 0 bit BWE parameters */ @@ -610,6 +603,7 @@ static void hf_synthesis_ivas_fx( * dB loss: -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB * (gain=4.0) *-------------------------------------------------------------------*/ + static void filt_6k_7k_scale_fx( Word16 signal[], /* i/o: signal Qx*/ Word16 lg, /* i : length of input Q0*/ @@ -641,9 +635,13 @@ static void filt_6k_7k_scale_fx( signal[i] = round_fx_sat( L_tmp ); /* Q0 */ move16(); } + Copy( x + lg, mem, L_FIR - 1 ); /* Qx - 2 */ + + return; } + /*-------------------------------------------------------------------* * hf_synth_amr_wb_init() * @@ -680,7 +678,7 @@ void hf_synth_amr_wb_init_fx( move16(); hAmrwb_IO->OptCrit_old_fx = 32768; move32(); /*1.0f in Q15*/ - ; + return; } @@ -691,6 +689,7 @@ void hf_synth_amr_wb_init_fx( * reset of HF synthesis filters * - needed in switching scenarios *-------------------------------------------------------------------*/ + void hf_synth_amr_wb_reset_fx( ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ AMRWB_IO_DEC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO data handle */ @@ -736,6 +735,7 @@ void hf_synth_amr_wb_reset_fx( return; } + /*-------------------------------------------------------------------* * hf_synth_amr_wb() * @@ -743,8 +743,8 @@ void hf_synth_amr_wb_reset_fx( *-------------------------------------------------------------------*/ void hf_synth_amr_wb_fx( - AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ - ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ + AMRWB_IO_DEC_HANDLE hAmrwb_IO, /* i/o: AMR-WB IO data handle */ + ZERO_BWE_DEC_HANDLE hBWE_zero, /* o : zero BWE decoder handle */ const Word32 core_brate, /* i : core bitrate Q0*/ const Word16 output_frame, /* i : output frame length Q0*/ const Word16 *Aq, /* i : quantized Az : Q12*/ @@ -985,7 +985,6 @@ void hf_synth_amr_wb_fx( tmp = sub( 18022 /* 1.1f in Q14 */, tmp ); /*Q14 */ fmerit_w = round_fx( L_shl( L_mult( fmerit_w, tmp ), 1 ) ); /*Q: 14+14+1+1-16 = 14 */ - L_tmp = L_deposit_l( fmerit_w ); /*Q14 */ L_tmp = Isqrt( L_tmp ); /*Q(31-7) */ tmp = round_fx( L_tmp ); /*Q8 */ @@ -1303,6 +1302,8 @@ void hf_synth_amr_wb_fx( return; } + + static void hf_synthesis_amr_wb_fx( const Word32 core_brate, /* i : core bitrate : Q0*/ const Word16 output_subfr, /* i : output sub-frame length : Q0*/ @@ -1328,6 +1329,7 @@ static void hf_synthesis_amr_wb_fx( Word32 L_tmp; Word16 q1, q2, q3, shift; Word16 *pt1, *pt2, flag; + IF( EQ_32( core_brate, ACELP_23k85 ) ) { ener = dot_prod_satcontr( exc, exc, Q_exc, Q_exc, &q1, L_SUBFR ); @@ -1463,6 +1465,7 @@ static void hf_synthesis_amr_wb_fx( return; } + static Word16 EnhanceClass_fx( const Word16 qq_fx, /* Qx */ const Word16 pp_fx, /* Qx */ @@ -1525,10 +1528,12 @@ static Word16 EnhanceClass_fx( *unvoicing_flag = 0; move16(); } + test(); return ( *unvoicing_flag && GT_16( qq_fx, pp_fx ) ); } + static void envelope_fx( AMRWB_IO_DEC_HANDLE hAmrwb_IO, const Word32 core_brate, /* i : core bitrate Q0*/ @@ -1552,7 +1557,6 @@ static void envelope_fx( const Word16 *pt2, *pt3; Word16 Aq[M + 1]; - /* Aq has dynamic scaling go back to Q12 to make sure there's no overflow while calculating qx,qy*/ shift = sub( norm_s( Aq_dyn_scal[0] ), 2 ); @@ -1746,7 +1750,6 @@ static void envelope_fx( } qy = round_fx( L_shr( L_tmp, 1 ) ); /*Q(10+q1)*/ - L_tmp = L_mult( qx, qx ); /* Q21 + 2q1 */ L_tmp = L_mac( L_tmp, qy, qy ); /* Q21 + 2q1 */ qq = round_fx( Isqrt( L_shr( L_tmp, add( 11, shl( q1, 1 ) ) ) ) ); /*Q10*/ @@ -1813,16 +1816,17 @@ static void envelope_fx( rr = s_min( est_level1, est_level2 ); } - q1 = norm_s( pp ); tmp = div_s( shl( 1, sub( 14, q1 ) ), pp ); /*Q(29-q1-10) */ L_tmp = L_mult( rr, tmp ); /*Q(30-q1-10+10) */ *sub_gain = s_min( 20480 /* 5.0f in Q12 */, round_fx_sat( L_shl_sat( L_tmp, sub( q1, 2 ) ) ) ); /*Q12 */ move16(); + return; } + /*---------------------------------------------------------------------* * AdaptiveStartBand_fx() * diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index a0fa4dbbd163b2de097f81659d929125cf00aaf7..78c3d9f3ac80071fd5a1460bcc52373f3c896ae8 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -1,14 +1,15 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ + #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -//#include "prot_fx.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ #include "rom_com.h" /* Function prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -23,9 +24,10 @@ * energy is trailing off after a spike *-------------------------------------------------------------------*/ -static Word16 find_ener_decrease_fx( /* o : maximum energy ratio Q10*/ - const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ - const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ +/*! r: maximum energy ratio Q10*/ +static Word16 find_ener_decrease_fx( + const Word16 ind_deltaMax, /* i : index of the beginning of maximum energy search Q0*/ + const Word32 *pt_enr_ssf /* i : Pointer to the energy buffer Qx*/ ) { Word16 i, j, end, flag; @@ -65,7 +67,6 @@ static Word16 find_ener_decrease_fx( /* o : maximum minEnr = L_min( minEnr, pt_enr_ssf[i] ); /* Qx */ } - minEnr = L_add_sat( minEnr, 100000 ); exp0 = norm_l( minEnr ); wtmp0 = extract_h( L_shl( minEnr, exp0 ) ); @@ -77,12 +78,14 @@ static Word16 find_ener_decrease_fx( /* o : maximum return dE2; } + /*-------------------------------------------------------------------* * find_uv_fx() * * Decision about coder type *-------------------------------------------------------------------*/ +#ifndef FIX_2349_HARM_FIND_UV Word16 find_uv_fx( /* o : coding type */ Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ @@ -572,7 +575,11 @@ Word16 find_uv_fx( /* o : coding type * * Decision about coder type *-------------------------------------------------------------------*/ -Word16 find_uv_ivas_fx( /* o : coding type */ +Word16 find_uv_ivas_fx( /* o : coding type */ +#else +/*! r: coder type */ +Word16 find_uv_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -587,6 +594,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, +#ifdef FIX_2349_HARM_FIND_UV + const Word16 shift, +#endif const Word16 q_hp_E ) { Word16 coder_type, i; @@ -607,6 +617,17 @@ Word16 find_uv_ivas_fx( /* o : coding typ SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; Word16 Last_Resort; Word16 vadnoise; + Word16 Q_in, loc_lp_noise; + + Q_in = Q_new; + move16(); + +#ifdef FIX_2349_HARM_FIND_UV + if ( st_fx->element_mode == EVS_MONO ) + { + Q_in = sub( Q_new, 1 ); + } +#endif IF( hSC_VBR != NULL ) { @@ -637,7 +658,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ pt_enr_ssf = enr_ssf + 2 * NB_SSF; FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ ) { - emaximum_fx( Q_new, pt_speech, SSF, pt_enr_ssf ); + emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf ); pt_speech += ( SSF / 2 ); pt_enr_ssf++; } @@ -675,7 +696,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ pt_enr_ssf1++; } - IF( hStereoClassif != NULL ) + IF( hStereoClassif != NULL ) /* IVAS only */ { IF( st_fx->idchan == 0 ) { @@ -712,11 +733,23 @@ Word16 find_uv_ivas_fx( /* o : coding typ Ltmp0 = L_mult( st_fx->voicing_fx[0], 10923 /* 1/3 in Q15 */ ); /* Q31 */ Ltmp0 = L_mac( Ltmp0, st_fx->voicing_fx[1], 10923 /* 1/3 in Q15 */ ); /* Q31 */ mean_voi3 = mac_r_sat( Ltmp0, st_fx->voicing_fx[2], 10923 /* 1/3 in Q15 */ ); /*Q15*/ + /*-----------------------------------------------------------------* * Total frame energy difference (dE3) *-----------------------------------------------------------------*/ +#ifdef FIX_2349_HARM_FIND_UV + IF( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */ + { + dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/ + } + ELSE + { + dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ + } +#else dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/ +#endif /*-----------------------------------------------------------------* * Energy decrease after spike (dE2) @@ -806,6 +839,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ } E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) ); +#ifdef FIX_2349_HARM_FIND_UV + if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ + { + E_min_th = L_shl( E_MIN_FX, Q_new ); + } +#endif test(); test(); @@ -830,6 +869,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ move16(); ee1_th = 608; /*9.5 Q6*/ move16(); + test(); test(); IF( st_fx->Opt_SC_VBR || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) ) /* Allow the low energy flag for the secondary channel */ @@ -837,15 +877,28 @@ Word16 find_uv_ivas_fx( /* o : coding typ ee1_th = 544; /*8.5f Q6*/ move16(); +#ifdef FIX_2349_HARM_FIND_UV + IF( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */ + { + loc_lp_noise = st_fx->lp_noise_fx; + } + ELSE + { + loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); + } +#else + loc_lp_noise = extract_h( st_fx->lp_noise_32fx ); +#endif + /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */ IF( st_fx->input_bwidth != NB ) { /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, loc_lp_noise ); // Q24 IF( Last_Resort == 0 ) { /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, loc_lp_noise ); // Q24 } relE_thres = round_fx( L_tmp ); } @@ -853,7 +906,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ { /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 + L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, loc_lp_noise ); // Q24 relE_thres = round_fx( L_tmp ); } relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ @@ -889,22 +942,41 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); test(); - IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ - ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ - ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ - ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ - /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ - ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ - ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ - ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ - flag_low_relE ) + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) &&*/ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 237568 /* 29.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 237568 /* 29.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) || /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + flag_low_relE ) /* low relative frame energy (only for SC-VBR) */ { coder_type = UNVOICED; move16(); } } +#ifdef FIX_2349_HARM_FIND_UV + ELSE IF( st_fx->element_mode == EVS_MONO ) + { + if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ + ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.8 in Q15 */ ) ) && /* normalized correlation low on look-ahead - onset detection */ + ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ + ( LT_32( ee[1], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ + ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ + /*( st_fx->music_hysteresis_fx == 0 ) && */ /* ... and in segment after AUDIO frames */ + ( LE_32( dE1, 245760 /* 30.0f in Q13 */ ) ) && /* Avoid on sharp energy spikes */ + ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) && /* + one frame hysteresis */ + ( st_fx->spike_hyst < 0 ) ) /* Avoid after sharp energy spikes followed by decay (e.g. castanets) */ + || ( flag_low_relE && ( LE_32( st_fx->old_dE1_fx, 245760 /* 30.0f in Q13 */ ) ) ) ) /* low relative frame energy (only for SC-VBR) */ + { + coder_type = UNVOICED; + move16(); + } + } +#endif ELSE { test(); @@ -917,7 +989,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ test(); test(); if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low */ - /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ + /* ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) ) && */ /* normalized correlation low on look-ahead - onset detection */ ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) && /* energy concentrated in high frequencies provided that some energy is present in HF... */ ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) && /* ... biased towards look-ahead to detect onsets */ ( tmp_offset_flag == 0 ) && /* Take care of voiced offsets */ @@ -935,6 +1007,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ /*-----------------------------------------------------------------* * Decision about VC *-----------------------------------------------------------------*/ + if ( st_fx->Opt_SC_VBR ) { hSC_VBR->set_ppp_generic = 0; @@ -1037,9 +1110,13 @@ Word16 find_uv_ivas_fx( /* o : coding typ move16(); /* Current frame cannot be compressed to pack the partial redundancy;*/ - IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) + IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) /* can happen only for EVS format */ { +#ifdef FIX_2349_HARM_FIND_UV + core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift ); +#else core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 ); +#endif } } } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index abe017232a738a9956728959d77aac8a89fce051..e8f0631bdc0b6bbd960c0679c2d5ed4f43b5bccf 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1264,8 +1264,14 @@ ivas_error pre_proc_front_ivas_fx( find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx, corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); +#ifdef FIX_2349_HARM_FIND_UV + st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, + &flag_spitch, last_core_orig, hStereoClassif, *Q_new, 0, fr_bands_fx_q ); // Q0 +#else st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx, &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0 +#endif + Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) ); /*-----------------------------------------------------------------* diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index 9e2e2f28707e27f0f899f4574b38c8267b920121..3e7207d0732f7cffc8e37d2569f6288ce8b250ec 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -507,8 +507,13 @@ void pre_proc_fx( find_tilt_fx( fr_bands, hNoiseEst->bckr_fx, ee, st->pitch, st->voicing_fx, lf_E, corr_shift, st->input_bwidth, st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR ); +#ifdef FIX_2349_HARM_FIND_UV + st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, 0L, corr_shift, relE, *Etot, hp_E, + &flag_spitch, last_core_orig, NULL, *Q_new, *shift, 31 ); // Q0 +#else st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig ); +#endif /*-----------------------------------------------------------------* * channel aware mode configuration * diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index f6fc25fde09e363ae9e01783c80d8582c86b7265..1fd16cd9304a7c79f1b94d0a8b98ca1b00c78026 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -217,8 +217,13 @@ void find_tilt_fx( Word16 Opt_vbr_mode /* Q0 */ ); +#ifndef FIX_2349_HARM_FIND_UV /* o : coding type */ Word16 find_uv_ivas_fx( +#else +/*! r: coder type */ +Word16 find_uv_fx( +#endif Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ @@ -233,8 +238,12 @@ Word16 find_uv_ivas_fx( const Word16 last_core_orig, /* i : original last core Q0*/ STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ const Word16 Q_new, +#ifdef FIX_2349_HARM_FIND_UV + const Word16 shift, +#endif const Word16 q_hp_E ); +#ifndef FIX_2349_HARM_FIND_UV /* o : coding type */ Word16 find_uv_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -251,7 +260,7 @@ Word16 find_uv_fx( const Word16 shift, const Word16 last_core_orig /* i : original last core Q0*/ ); - +#endif void fine_gain_quant_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *ord, /* i : Indices for energy order */