diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index e4dbd7e2a9530e465ca94197dd625124167ee4ae..7893d9b798e0484631c8250daf31ce842a161152 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -2962,7 +2962,7 @@ void lsf_syn_mem_backup_fx( return; } - +#ifndef CLEANUP_VBR_CAM_ENC /*-------------------------------------------------------------------* * lsf_syn_mem_backup_fx() * @@ -3046,6 +3046,7 @@ void lsf_syn_mem_backup_ivas_fx( return; } +#endif void lsf_update_memory( Word16 narrowband, /* i : narrowband flag */ @@ -3190,6 +3191,7 @@ void lsf_syn_mem_restore_fx( return; } +#ifndef CLEANUP_VBR_CAM_ENC void lsf_syn_mem_restore_ivas_fx( Encoder_State *st_fx, /* o: state structure */ Word16 btilt_code_fx, /* i: Q15 */ @@ -3267,6 +3269,7 @@ void lsf_syn_mem_restore_ivas_fx( return; } +#endif /* Returns: codebook index */ Word16 tcxlpc_get_cdk( diff --git a/lib_com/options.h b/lib_com/options.h index b7bb2305395dc7e6adfa09fc6f5eaa18b10dacd0..f81016d22ab419e69d1659aafced0fd2fa104443 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -114,6 +114,7 @@ #define FIX_1478_UNINIT_ON_BFI /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */ #define FIX_1487_ACCESS_OF_UNINIT_VAL_FROM_ARR_ISM_DTX /* FhG/VA: init nb_bits_metadata to zero */ #define CLEANUP_ACELP_ENC /* VA: basop issue 2304: Remove duplicated code in excitation encoding in the ACELP core */ +#define CLEANUP_VBR_CAM_ENC /* VA: basop issue 2299: Remove unused core-encoder VBR and CAM code */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 8285b23b0db5c948059513f7c15f512a1952c768..abb050c02ec7f9a2b17f7a25d946293ce351f86d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -927,6 +927,7 @@ void lsf_syn_mem_restore_fx( Word16 pstreaklen /* i:LSF quantizer */ ); +#ifndef CLEANUP_VBR_CAM_ENC void lsf_syn_mem_restore_ivas_fx( Encoder_State *st_fx, /* o: state structure */ Word16 btilt_code_fx, /* i: Q15 */ @@ -947,7 +948,7 @@ void lsf_syn_mem_restore_ivas_fx( Word16 streaklimit, /* i:LSF quantizer Q15 */ Word16 pstreaklen /* i:LSF quantizer */ ); - +#endif void lsf_update_memory( Word16 narrowband, /* i : narrowband flag */ const Word16 qisf[], /* i : quantized xSF coefficients */ @@ -3851,13 +3852,14 @@ void nelp_encoder_fx( Word16 *qIn1, Word16 reduce_gains ); +#ifndef CLEANUP_VBR_CAM_ENC void nelp_encoder_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state */ Word16 *in_fx, /* i : residual signal */ Word16 *exc_fx, /* o : NELP quantized excitation signal */ Word16 *qIn1, Word16 reduce_gains ); - +#endif void swb_bwe_enc_lr_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 L_m_core[], /* i : lowband synthesis */ @@ -10680,6 +10682,7 @@ Word16 ari_decode_14bits_sign_ivas( Word16 *res, Tastat *s ); +#ifndef CLEANUP_VBR_CAM_ENC void lsf_syn_mem_backup_ivas_fx( Encoder_State *st_fx, /* i: state structure */ Word16 *btilt_code_fx, /* i: tilt code Q15 */ @@ -10699,7 +10702,7 @@ void lsf_syn_mem_backup_ivas_fx( Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ Word16 *streaklimit, /* Q15 */ Word16 *pstreaklen ); - +#endif ivas_error config_acelp1_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 5a29164341d771772c58a91557d55d33464749cb..b612626cf8d9ed34c2a253ac14eede0580e822ff 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -709,6 +709,7 @@ ivas_error acelp_core_enc_fx( return error; } + /*-------------------------------------------------------------------* * acelp_core_enc_ivas_fx() * @@ -742,14 +743,20 @@ ivas_error acelp_core_enc_ivas_fx( Word32 int_fs; Word16 nb_bits; /* parameters handling */ +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR - back-up memories for LSF quantizer and synthesis filter */ Word16 pstreaklen; +#endif Word16 sid_bw = -1; move16(); +#ifndef CLEANUP_VBR_CAM_ENC Word16 next_force_sf_bck; +#endif Word16 uc_two_stage_flag; Word16 position; +#ifndef CLEANUP_VBR_CAM_ENC Word16 ppp_mode, nelp_mode; +#endif Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; /* bitstream */ @@ -764,18 +771,22 @@ ivas_error acelp_core_enc_ivas_fx( Word16 tmp_noise_fx; /* NB post-filter long-term noise energy*/ Word16 old_bwe_exc_fx[( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2]; /* excitation buffer Q_new */ Word16 *bwe_exc_fx; /* excitation for SWB TBE Q_new */ +#ifndef CLEANUP_VBR_CAM_ENC Word16 mem_MA_fx[M], mem_AR_fx[M], lsp_new_bck_fx[M], /*lsf_new_bck_fx[M],*/ lsp_mid_bck_fx[M], mem_syn_bck_fx[M]; Word32 Bin_E_fx[L_FFT], Bin_E_old_fx[L_FFT / 2]; Word16 clip_var_fx, mem_w0_bck_fx, streaklimit_fx; +#endif set16_fx( old_bwe_exc_fx, 0, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); set16_fx( old_exc_fx, 0, L_EXC ); set16_fx( Aq, 0, NB_SUBFR16k * ( M + 1 ) ); set16_fx( syn_fx, 0, L_FRAME16k ); +#ifndef CLEANUP_VBR_CAM_ENC Word16 tilt_code_bck_fx; Word32 gc_threshold_bck_fx; Word16 clip_var_bck_fx[6]; +#endif Word32 q_env_fx[NUM_ENV_CNG]; set32_fx( q_env_fx, 0, NUM_ENV_CNG ); set16_fx( exc2_fx, 0, L_FRAME16k ); @@ -898,6 +909,7 @@ ivas_error acelp_core_enc_ivas_fx( position = -1; move16(); +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR temporary variables */ pstreaklen = 0; move16(); @@ -924,10 +936,10 @@ ivas_error acelp_core_enc_ivas_fx( } move16(); move16(); +#endif test(); /* TD stereo */ - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; // Q0 @@ -1024,6 +1036,7 @@ ivas_error acelp_core_enc_ivas_fx( /*----------------------------------------------------------------* * Encoding of CNG frames *----------------------------------------------------------------*/ + test(); IF( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) { @@ -1115,11 +1128,13 @@ ivas_error acelp_core_enc_ivas_fx( move16(); st->hLPDmem->q_mem_syn = st->Q_syn; move16(); - // Scaling Aq to Q12 + + /* 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 ); @@ -1160,17 +1175,18 @@ ivas_error acelp_core_enc_ivas_fx( /*----------------------------------------------------------------* * Encoding of all other frames *----------------------------------------------------------------*/ + ELSE { + Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k ); + Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */ + st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp ); + move16(); /*-----------------------------------------------------------------* * Configure ACELP bit allocation *-----------------------------------------------------------------*/ - Word16 temp = getScaleFactor16( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k ); - Scale_sig( st->hGSCEnc->last_exc_dct_in_fx, L_FRAME16k, temp ); /* Q_last_exc_dct_in + temp */ - st->hGSCEnc->Q_last_exc_dct_in = add( st->hGSCEnc->Q_last_exc_dct_in, temp ); - move16(); nb_bits = 0; move16(); st->acelp_cfg.FEC_mode = 0; @@ -1178,11 +1194,15 @@ ivas_error acelp_core_enc_ivas_fx( uc_two_stage_flag = 0; move16(); +#ifndef CLEANUP_VBR_CAM_ENC test(); IF( !nelp_mode && !ppp_mode ) { +#endif config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); +#ifndef CLEANUP_VBR_CAM_ENC } +#endif /*-----------------------------------------------------------------* * After inactive period, use the most up-to-date ISPs @@ -1219,9 +1239,10 @@ ivas_error acelp_core_enc_ivas_fx( * A[z] calculation *-----------------------------------------------------------------*/ +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR & channel-aware mode - back-up memories for LSF quantizer and synthesis filter */ lsf_syn_mem_backup_ivas_fx( st, &tilt_code_bck_fx, &gc_threshold_bck_fx, clip_var_bck_fx, &next_force_sf_bck, lsp_new, lsp_mid, &clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, &mem_w0_bck_fx, &streaklimit_fx, &pstreaklen ); - +#endif IF( !tdm_lp_reuse_flag ) { lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, st->GSC_IVAS_mode, tdm_lsfQ_PCh, Q_new ); @@ -1260,11 +1281,13 @@ 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 + + /* 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 ) { @@ -1341,12 +1364,13 @@ ivas_error acelp_core_enc_ivas_fx( encod_gen_2sbfr_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); } } +#ifndef CLEANUP_VBR_CAM_ENC ELSE IF( nelp_mode ) { /* SC-VBR - NELP frames */ encod_nelp_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, &tmp_noise_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, Q_new, 0 ); } - +#endif ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames (Gauss. excitation) */ @@ -1364,6 +1388,7 @@ ivas_error acelp_core_enc_ivas_fx( encod_tran_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, tc_subfr, position, unbits, 0, Q_new ); #endif } +#ifndef CLEANUP_VBR_CAM_ENC ELSE IF( ppp_mode ) { /* SC-VBR - PPP frames */ @@ -1396,6 +1421,7 @@ ivas_error acelp_core_enc_ivas_fx( #endif } } +#endif ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ @@ -1420,8 +1446,8 @@ ivas_error acelp_core_enc_ivas_fx( /* 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 ); // 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 + 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 ) { @@ -1461,11 +1487,16 @@ ivas_error acelp_core_enc_ivas_fx( /*--------------------------------------------------------------------------------------* * Modify the excitation signal when the noise is stationary *--------------------------------------------------------------------------------------*/ + test(); test(); test(); +#ifdef CLEANUP_VBR_CAM_ENC + IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#else test(); IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( nelp_mode, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) +#endif { /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */ Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new @@ -1496,9 +1527,11 @@ ivas_error acelp_core_enc_ivas_fx( } /* end of active inp coding */ + /*-----------------------------------------------------------------* * Write ACELP unused bits *-----------------------------------------------------------------*/ + test(); test(); IF( NE_32( st->core_brate, SID_2k40 ) && st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, PPP_NELP_2k80 ) ) @@ -1527,9 +1560,13 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); +#ifdef CLEANUP_VBR_CAM_ENC + IF( ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) +#else test(); test(); IF( ( EQ_16( st->last_Opt_SC_VBR, 1 ) && st->Opt_SC_VBR == 0 ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) +#endif { st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); @@ -1540,8 +1577,12 @@ ivas_error acelp_core_enc_ivas_fx( test(); test(); test(); +#ifdef CLEANUP_VBR_CAM_ENC + IF( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) +#else test(); IF( !st->Opt_SC_VBR && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) +#endif { /* Apply a non linearity to the SHB excitation */ Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( Q_new, 1 ), sub( st->hBWE_TD->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc @@ -1612,6 +1653,7 @@ ivas_error acelp_core_enc_ivas_fx( st->hTdCngEnc->ho_16k_lsp[st->hTdCngEnc->ho_circ_ptr] = 1; } move16(); + /* efficient DTX hangover control */ IF( GT_16( st->hTdCngEnc->burst_ho_cnt, 1 ) ) { @@ -1619,6 +1661,7 @@ ivas_error acelp_core_enc_ivas_fx( } } +#ifndef CLEANUP_VBR_CAM_ENC /* SC-VBR update of average data rate */ IF( EQ_16( st->vad_flag, 1 ) ) { @@ -1628,6 +1671,7 @@ ivas_error acelp_core_enc_ivas_fx( update_average_rate_fx( st->hSC_VBR, st->core_brate ); } } +#endif pop_wmops(); return error; diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index e51dd4884a0c67da51b2261aa6754de2c62cd071..cf4c06203a2a6ada90da0d9b7d20ca928f0da4ca 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1501,6 +1501,7 @@ void CNG_enc_ivas_fx( { lsf_enc_ivas_fx( st_fx, lsf_new, lsp_new, NULL, NULL, 0, 0, NULL, Q_new ); } + /* Reset CNG history if CNG frame length is changed */ test(); test(); diff --git a/lib_enc/enc_nelp_fx.c b/lib_enc/enc_nelp_fx.c index 30756d19d6abcbf03857c417d4caaa5555cdb62d..60bbab86cf44d716adf84f63bb1806aac54d9245 100644 --- a/lib_enc/enc_nelp_fx.c +++ b/lib_enc/enc_nelp_fx.c @@ -171,6 +171,7 @@ void encod_nelp_fx( return; } +#ifndef CLEANUP_VBR_CAM_ENC void encod_nelp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -311,3 +312,4 @@ void encod_nelp_ivas_fx( return; } +#endif diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 66ce8e4e181aafca763104474960476c0395671c..9b62baea5c9b225d1231f70953a732dbb780ab29 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -233,6 +233,7 @@ ivas_error encod_ppp_fx( return error; } +#ifndef CLEANUP_VBR_CAM_ENC ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -415,3 +416,4 @@ ivas_error encod_ppp_ivas_fx( return error; } +#endif diff --git a/lib_enc/nelp_enc_fx.c b/lib_enc/nelp_enc_fx.c index 9122be431e58c675afd23259c8c2f78f30d5892e..60e2b29fecb787f30721aad04d9f0dd692a69c70 100644 --- a/lib_enc/nelp_enc_fx.c +++ b/lib_enc/nelp_enc_fx.c @@ -1032,6 +1032,7 @@ void nelp_encoder_fx( return; } +#ifndef CLEANUP_VBR_CAM_ENC void nelp_encoder_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state */ @@ -1766,3 +1767,4 @@ void nelp_encoder_ivas_fx( return; } +#endif diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index ce74ed5a54e1855f4286db7b5ef598254971f40a..e16ae844bb8dc274745a1baf85c09e936029c5be 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -1863,6 +1863,7 @@ void encod_nelp_fx( Word16 Q_new, Word16 shift ); +#ifndef CLEANUP_VBR_CAM_ENC void encod_nelp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : input speech Q_new-1 */ @@ -1878,7 +1879,7 @@ void encod_nelp_ivas_fx( Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new */ Word16 Q_new, Word16 shift ); - +#endif Word16 encod_tran_fx( #ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: state structure */ @@ -2061,6 +2062,7 @@ ivas_error encod_ppp_fx( const Word16 shift /* i : Shift needed to obtain 12 bits vectors */ ); +#ifndef CLEANUP_VBR_CAM_ENC ivas_error encod_ppp_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q_new*/ @@ -2075,7 +2077,7 @@ ivas_error encod_ppp_ivas_fx( Word16 *bwe_exc, /* o : excitation for SWB TBE Q_new*/ Word16 Q_new, Word16 shift ); - +#endif void encod_gen_voic_fx( #ifndef CLEANUP_ACELP_ENC Encoder_State *st_fx, /* i/o: state structure */