diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 172dadf82da9d517192d902c04d101cc1f3c6453..87b323d0a98edcd61b34d804e630c3980db98088 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1769,35 +1769,35 @@ static const Word16 filter_LP30_300K_fx[LFE_PLC_FDEL + 1] = const Resampling_cfg resampling_cfg_tbl[] = { /* fin fout up.fact. den.fac. len.out filter coefs. filter length/2 filter mem./2 flags */ - { 8000, 8000, 12800, 12800, 8, 8, 5, 256, /*filter5_39s320_120,*/ filter5_39s320_120_fx, 15, 15, RS_INV_FAC, RS_INV_FAC }, - { 12800, 12800, 8000, 8000, 5, 5, 8, 160, /*filter5_39s320_120,*/ filter5_39s320_120_fx, L_FILT_UP8k, L_FILT_UP8k, RS_INV_FAC, RS_INV_FAC }, - { 16000, 16000, 8000, 8000, 6, 6, 12, 160, /*filter_LP12_180H,*/ filter_LP12_180H_fx, 180 / 6, 180 / 6, 0, 0 }, - { 12800, 12800, 16000, 16000, 15, 15, 12, 320, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP16k, L_FILT_UP16k, 0, 0 }, - { 12800, 12800, 32000, 32000, 15, 15, 6, 640, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP32k, L_FILT_UP32k, 0, 0 }, - { 12800, 12800, 48000, 48000, 15, 15, 4, 960, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP48k, L_FILT_UP48k, 0, 0 }, + { 8000, 12800, 8, 5, 256, /*filter5_39s320_120,*/ filter5_39s320_120_fx, 15, RS_INV_FAC }, + { 12800, 8000, 5, 8, 160, /*filter5_39s320_120,*/ filter5_39s320_120_fx, L_FILT_UP8k, RS_INV_FAC }, + { 16000, 8000, 6, 12, 160, /*filter_LP12_180H,*/ filter_LP12_180H_fx, 180 / 6, 0 }, + { 12800, 16000, 15, 12, 320, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP16k, 0 }, + { 12800, 32000, 15, 6, 640, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP32k, 0 }, + { 12800, 48000, 15, 4, 960, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT_UP48k, 0 }, - { 16000, 16000, 12800, 12800, 12, 12, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT16k, L_FILT16k, 0, 0 }, - { 16000, 16000, 32000, 32000, 12, 12, 6, 640, /*filter_LP12_180H, */ filter_LP12_180H_fx, L_FILT16k, L_FILT16k, 0, 0 }, - { 16000, 16000, 48000, 48000, 12, 12, 4, 960, /*filter_LP12_180H,*/ filter_LP12_180H_fx, L_FILT16k, L_FILT16k, 0, 0 }, - - { 32000, 32000, 12800, 12800, 6, 6, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, - { 32000, 32000, 16000, 16000, 6, 6, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, - { 32000, 32000, 25600, 25600, 12, 12, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, - { 32000, 32000, 48000, 48000, 3, 3, 2, 960, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT32k, L_FILT32k, 0, 0 }, - - { 48000, 48000, 12800, 12800, 4, 4, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, - { 48000, 48000, 16000, 16000, 4, 4, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, - { 48000, 48000, 25600, 25600, 8, 8, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, - { 48000, 48000, 32000, 32000, 2, 2, 3, 640, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT48k, L_FILT48k, 0, 0 }, + { 16000, 12800, 12, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_fx, L_FILT16k, 0, }, + { 16000, 32000, 12, 6, 640, /*filter_LP12_180H, */ filter_LP12_180H_fx, L_FILT16k, 0, }, + { 16000, 48000, 12, 4, 960, /*filter_LP12_180H,*/ filter_LP12_180H_fx, L_FILT16k, 0, }, + + { 32000, 12800, 6, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT32k, 0, }, + { 32000, 16000, 6, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT32k, 0, }, + { 32000, 25600, 12, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT32k, 0, }, + { 32000, 48000, 3, 2, 960, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT32k, 0, }, + + { 48000, 12800, 4, 15, 256, /*filter_LP15_180H,*/ filter_LP15_180H_13b_fx, L_FILT48k, 0, }, + { 48000, 16000, 4, 12, 320, /*filter_LP12_180H,*/ filter_LP12_180H_13b_fx, L_FILT48k, 0, }, + { 48000, 25600, 8, 15, 512, /*filter_LP15_360H,*/ filter_LP15_360H_13b_fx, L_FILT48k, 0, }, + { 48000, 32000, 2, 3, 640, /*filter_LP3_90H,*/ filter_LP3_90H_fx, L_FILT48k, 0, }, /* configs with NB 4kHz low-pass */ - { 16000, 16000, 12800, 12800, 12, 12, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_fx, L_FILT16k, L_FILT16k, 0, 0 }, - { 32000, 32000, 12800, 12800, 6, 6, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT32k, L_FILT32k, 0, 0 }, - { 48000, 48000, 12800, 12800, 4, 4, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT48k, L_FILT48k, 0, 0 }, + { 16000, 12800, 12, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_fx, L_FILT16k, 0, }, + { 32000, 12800, 6, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT32k, 0, }, + { 48000, 12800, 4, 15, 256, /*filter_LP24_90H,*/ filter_LP24_90H_13b_fx, L_FILT48k, 0, }, /* entry for LFE PLC */ - { 1600, 1600, 48000, 48000, 30, 30, 1, 960, /*filter_LP30_300K,*/ filter_LP30_300K_fx, LFE_PLC_FDEL/30,LFE_PLC_FDEL / 30, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, /* 0, */ 0, 0, 0, 0, 0 } /* trailing entry (just to calculate the length of this table) */ + { 1600, 48000, 30, 1, 960, /*filter_LP30_300K,*/ filter_LP30_300K_fx, LFE_PLC_FDEL / 30, 0, }, + { 0, 0, 0, 0, 0, /* 0, */ 0, 0, 0, } /* trailing entry (just to calculate the length of this table) */ }; //den fac value for last entry is calculated as den.fac = (num.fac*fin)/fout diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 33661fb581a9db3b345637c5505c79c3b1c7d62d..10bce5bb2af3fc6903d463624d8cd1d533049d60 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -49,13 +49,8 @@ #define INTERP_EXP 0 typedef struct { - Word32 fin; /* input frequency */ - Word32 fin_fx; /* input frequency Q0 */ - - Word32 fout; /* output frequency */ - Word32 fout_fx; /* output frequency Q0 */ - - Word16 fac_num; /* numerator of resampling factor */ + Word32 fin_fx; /* input frequency Q0 */ + Word32 fout_fx; /* output frequency Q0 */ Word16 fac_num_fx; /* numerator of resampling factor Q0 */ Word16 fac_den_fx; /* denominator of resampling factor Q0 */ @@ -63,12 +58,9 @@ typedef struct const Word16 *filter_fx; /* resampling filter coefficients Q14 */ - Word16 filt_len; /* number of filter coeff. */ Word16 filt_len_fx; /* number of filter coeff. Q0 */ - - UWord16 flags; /* flags from config. table */ - UWord16 flags_fx; /* flags from config. table Q0 */ - // UNS_Word16 flags_fx; /* flags from config. table Q0 */ + UWord16 flags_fx; /* flags from config. table Q0 */ + // UNS_Word16 flags_fx; /* flags from config. table Q0 */ } Resampling_cfg; diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 968cc8359120850e8eb2596ae92a9464a0694200..ada0d243ea88b7c08fdb6ac8bd5d8720f9eb7f8f 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -213,14 +213,14 @@ void syn_filt_fx( FOR( i = 0; i < l; i++ ) { - s = L_mult( a0, x[i] ); + s = L_mult( a0, x[i] ); // Qx + Qa - shift + 1 FOR( j = 1; j <= m; j++ ) { - s = L_msu_sat( s, shr( a[j], shift ), yy[i - j] ); + s = L_msu_sat( s, a[j], yy[i - j] ); // Qa + Qx - shift + 1 } - s = L_shl_sat( s, q ); - yy[i] = extract_h( s ); + s = L_shl_sat( s, q ); // Qx + (Qa + q)Q15 - shift + 1 = Qx - shift + Q16 + yy[i] = extract_h( s ); // Qx - shift move16(); y[i] = extract_h( s ); move16(); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 7820061089f45aa3855e68c6f776f249a735f7a5..d2d5ac4e6583ab86396685bb38c2ae67610dc01e 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1123,7 +1123,11 @@ ivas_error acelp_core_enc_ivas_fx( move16(); st->hLPDmem->q_mem_syn = st->Q_syn; move16(); - + // Scaling Aq to Q12 + FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) + { + Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); + } /* synthesis at 12.8kHz sampling rate */ syn_12k8_fx( st->L_frame, Aq, exc3_fx, syn1_fx, hLPDmem->mem_syn3, 1, sub( Q_new, 1 ), st->Q_syn ); @@ -1275,6 +1279,11 @@ ivas_error acelp_core_enc_ivas_fx( st->stab_fac_fx = lsf_stab_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); // Q15 move16(); } + // Scaling Aq to Q12 + FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) + { + Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); + } test(); IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) { @@ -1313,12 +1322,6 @@ ivas_error acelp_core_enc_ivas_fx( v_multc_fixed_16_16( res_fx, att_fx, res_fx, st->L_frame ); } - // Scaling Aq and Aw to Q12 - FOR( Word16 k = 0; k < NB_SUBFR16k; k++ ) - { - Scale_sig( &Aq[( M + 1 ) * k], M + 1, sub( norm_s( Aq[( M + 1 ) * k] ), 2 ) ); - Scale_sig( &Aw[( M + 1 ) * k], M + 1, sub( norm_s( Aw[( M + 1 ) * k] ), 2 ) ); - } /*-----------------------------------------------------------------* * Determine TC subframe classification *-----------------------------------------------------------------*/ @@ -1418,17 +1421,12 @@ ivas_error acelp_core_enc_ivas_fx( encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); } - FOR( i = 0; i < NB_SUBFR16k; i++ ) - { - Scale_sig( &Aq[i * ( M + 1 )], ( M + 1 ), sub( Q12, sub( Q14, norm_s( Aq[i * ( M + 1 )] ) ) ) ); // Q12 - } - /* update mem_syn1_flt for ACELP core switching */ Copy( hLPDmem->mem_syn, hLPDmem->mem_syn1_fx, M ); // Q_syn /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // st->Q_syn - + Copy( syn_fx + sub( st->L_frame, L_SYN_MEM ), hLPDmem->mem_syn_r, L_SYN_MEM ); // hLPDmem->q_mem_syn + // st->Q_syn = Q_new - 1; Scale_sig( syn_fx, L_FRAME16k, sub( st->Q_syn, Q_new - 1 ) ); // Q_syn /* save and delay synthesis to be used by SWB BWE */ IF( st->hBWE_FD != NULL ) diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index cd23c1a6f4035e6a60218dc53dbfe5b06ba74467..b0c67abf528e2aef3bf40e609cfaba8e803b5f70 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -23,7 +23,7 @@ void encod_unvoiced_fx( const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* o : core synthesis Q_new*/ + Word16 *syn_fx, /* o : core synthesis Q_new -1 */ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 1e66c148868960ae61e8dbcdbfe15f84b7cff136..d5898cd4aa6ebb5c02b75dd5f3d82f5f414620b5 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -398,11 +398,6 @@ void stereo_tcx_core_enc( Q_exc = Q_new; st->prev_Q_new = Q_exc; - Scale_sig( st->synth, st->L_frame, st->Q_syn ); - IF( st->tcxonly == 0 ) - { - st->wspeech_enc[st->L_frame - 1] = shl( st->wspeech_enc[st->L_frame - 1], st->Q_syn ); - } IF( st->hTdCngEnc ) { FOR( Word16 ii = 0; ii < HO_HIST_SIZE; ii++ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 10d020ee3928e6c84324b352e5722b7e5c71f2c3..3698eba021737cf1efac9de47b6afb10e1d28550 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2043,7 +2043,7 @@ void encod_unvoiced_ivas_fx( const Word16 Es_pred, /* i : predicted scaled innov. energy Q8*/ const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC Q0*/ const Word16 *res_fx, /* i : residual signal Q_new*/ - Word16 *syn_fx, /* o : core synthesis Q_new*/ + Word16 *syn_fx, /* o : core synthesis Q_new - 1*/ Word16 *tmp_noise_fx, /* o : long-term noise energy Q0*/ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 44f415dc72a3a19a7ab46eefd21661bec8f5ce8b..3fe7d30fbb80af1bc543ee935e02425c39ec8cff 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -591,7 +591,7 @@ void swb_bwe_enc_ivas_fx( ELSE { SWB_BWE_encoding_ivas_fx( 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_exp, Q_synth ); + SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_exp, new_input_fx_exp ); }